File size: 640 Bytes
fdda09f
 
 
 
 
 
 
c7cbfb2
fdda09f
c7cbfb2
 
 
fdda09f
c7cbfb2
fdda09f
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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()