Spaces:
Runtime error
Runtime error
Download example_tts.py from KevinCosk/chatterbox: direct link, hf CLI and curl.
- Browser
- Download file 780 Bytes
-
https://huggingface.co/spaces/KevinCosk/chatterbox/resolve/main/example_tts.py
- Command line
-
hf download hf://spaces/KevinCosk/chatterbox/example_tts.py
-
curl -L -o example_tts.py https://huggingface.co/spaces/KevinCosk/chatterbox/resolve/main/example_tts.py
780 Bytes
| import torchaudio as ta | |
| import torch | |
| from chatterbox.tts import ChatterboxTTS | |
| # Automatically detect the best available device | |
| if torch.cuda.is_available(): | |
| device = "cuda" | |
| elif torch.backends.mps.is_available(): | |
| device = "mps" | |
| else: | |
| device = "cpu" | |
| print(f"Using device: {device}") | |
| model = ChatterboxTTS.from_pretrained(device=device) | |
| text = "Ezreal and Jinx teamed up with Ahri, Yasuo, and Teemo to take down the enemy's Nexus in an epic late-game pentakill." | |
| wav = model.generate(text) | |
| ta.save("test-1.wav", wav, model.sr) | |
| # If you want to synthesize with a different voice, specify the audio prompt | |
| AUDIO_PROMPT_PATH = "YOUR_FILE.wav" | |
| wav = model.generate(text, audio_prompt_path=AUDIO_PROMPT_PATH) | |
| ta.save("test-2.wav", wav, model.sr) | |