Created
December 29, 2024 04:38
-
-
Save eapache/dfaa4e3b55ede3dc28ae7920b1337743 to your computer and use it in GitHub Desktop.
Simple tts playground script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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