fr_tts / app.py
arunabks's picture
Update app.py
c59a1f8 verified
raw
history blame contribute delete
842 Bytes
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()