Spaces:
Sleeping
Sleeping
| import os | |
| # Install espeak-ng before running the model | |
| os.system("apt-get update && apt-get install -y espeak-ng") | |
| from TTS.api import TTS | |
| import gradio as gr | |
| # Load Coqui TTS Model (VITS) | |
| tts = TTS("tts_models/en/ljspeech/vits", progress_bar=False).to("cpu") | |
| def text_to_speech(text): | |
| """Generate Speech from Text""" | |
| output_path = "output.wav" | |
| tts.tts_to_file(text=text, file_path=output_path) | |
| return output_path | |
| # Gradio UI | |
| gr.Interface( | |
| fn=text_to_speech, | |
| inputs=gr.Textbox(placeholder="Enter text to convert to speech"), | |
| outputs=gr.Audio(type="filepath"), | |
| title="Coqui TTS - Text to Speech", | |
| description="Enter text and listen to the generated speech.", | |
| ).launch() | |