Skip to content

Instantly share code, notes, and snippets.

@eapache
Created December 29, 2024 04:38
Show Gist options
  • Save eapache/dfaa4e3b55ede3dc28ae7920b1337743 to your computer and use it in GitHub Desktop.
Save eapache/dfaa4e3b55ede3dc28ae7920b1337743 to your computer and use it in GitHub Desktop.
Simple tts playground script
print("Loading...")
import torch
from TTS.api import TTS
import sounddevice as sd
tts = TTS("tts_models/multilingual/multi-dataset/xtts_v2").to("cuda")
def play(string):
string = "\n".join([line for line in string.splitlines() if line.strip()])
if not string:
return
audio = tts.tts(text=string, speaker="Daisy Studious", language="en")
sd.play(audio, samplerate=22050)
sd.wait()
play("Hello world!")
try:
while True:
play(input("> "))
except KeyboardInterrupt:
print("\nExiting...")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment