import gradio as gr from ttsmms import download, TTS # Download and load the Swahili TTS model dir_path = download("swh", "./data") # Change "swh" to another language if needed tts = TTS(dir_path) # Function to generate speech from text and return a .wav file def text_to_speech(text): wav_path = "./output.wav" tts.synthesis(text, wav_path=wav_path) return wav_path # Gradio UI gr.Interface( fn=text_to_speech, inputs=gr.Text(label="Enter Text"), outputs=gr.Audio(label="Generated Speech"), title="Swahili Text-to-Speech", description="Type text and listen to the generated Swahili speech.", ).launch()