Spaces:
Runtime error
Runtime error
File size: 678 Bytes
819225f |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
from tortoise.api import TextToSpeech
from tortoise.utils.audio import load_voice
import torchaudio
# Create TTS instance
tts = TextToSpeech()
# Load prebuilt voice profile
voice_samples, conditioning_latents = load_voice('train_dotrice')
# Run TTS
output = tts.tts_with_preset(
text="1. black e4 white e5 — The game begins classically. Both players stake their claim in the center.",
voice_samples=voice_samples,
conditioning_latents=conditioning_latents,
preset='fast'
)
# Save output using torchaudio directly
torchaudio.save("output.wav", output.squeeze(0).cpu(), 24000) # 24kHz sample rate
print("✅ Audio saved to output.wav")
|