Spaces:
Build error
Build error
| import gradio as gr | |
| from tortoise.api import TextToSpeech | |
| from tortoise.utils.audio import load_voice, load_voices | |
| import torchaudio | |
| tts = TextToSpeech() | |
| def generate_audio(text, voice="tom"): | |
| audio = tts.tts(text, voice=voice, preset="fast") | |
| output_file = "output.wav" | |
| torchaudio.save(output_file, audio.squeeze(0).cpu(), 24000) | |
| return output_file | |
| iface = gr.Interface( | |
| fn=generate_audio, | |
| inputs=[ | |
| gr.Textbox(label="Enter your text"), | |
| gr.Dropdown(["tom", "emma", "pat"], label="Voice", value="tom") | |
| ], | |
| outputs=gr.Audio(label="Generated Audio"), | |
| title="Tortoise TTS" | |
| ) | |
| iface.launch() |