import gradio as gr from TTS.api import TTS # Load a CoquiTTS model tts = TTS("tts_models/en/ljspeech/tacotron2-DDC") def convert_text_to_speech(text): output_path = "output.wav" tts.tts_to_file(text=text, file_path=output_path) return output_path # Return file path instead of waveform data interface = gr.Interface( fn=convert_text_to_speech, inputs=gr.Textbox(label="Enter Text"), outputs=gr.Audio(label="Generated Speech"), title="Text to Speech Converter", description="Enter text and generate speech using Hugging Face's models.", ) interface.launch()