File size: 842 Bytes
40ba100
e412365
40ba100
3e164d8
c59a1f8
 
8b93014
3e164d8
 
 
 
 
8b93014
3e164d8
8b93014
 
3e164d8
 
8b93014
3e164d8
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import gradio as gr
from TTS.api import TTS

# Load English and French TTS models
tts_en = TTS(model_name="tts_models/en/ljspeech/vits", progress_bar=False, gpu=False)
tts_fr = TTS(model_name="tts_models/fr/mai/tacotron2-DDC", progress_bar=False, gpu=False)

def tts(text, lang):
    if lang == "English":
        tts_model = tts_en
    else:
        tts_model = tts_fr
    output_path = "output.wav"
    tts_model.tts_to_file(text=text, file_path=output_path)
    return output_path

lang_choices = ["English", "French"]

gr.Interface(
    fn=tts,
    inputs=[
        gr.Textbox(label="Enter Text"),
        gr.Radio(lang_choices, label="Select Language")
    ],
    outputs=gr.Audio(type="filepath"),
    title="🗣️ Coqui TTS: English + French",
    description="Convert text to speech in English or French using Coqui TTS"
).launch()