TTS_Mongolian / gradio_app.py
Vijish's picture
Upload folder using huggingface_hub
cc62aa8 verified
raw
history blame
1.67 kB
import gradio as gr
from voice_processing import tts, get_model_names, voice_mapping
model_names = get_model_names()
def on_convert_click(model_name, tts_text, selected_voice, slang_rate, use_uploaded_voice, voice_upload):
# Use the imported 'tts' function from voice_processing
info, edge_tts_output_path, tts_output_data = tts(
model_name, tts_text, selected_voice, slang_rate, use_uploaded_voice, voice_upload
)
return info, edge_tts_output_path, tts_output_data
# Define Gradio interface
app = gr.Blocks()
with app:
# Define your Gradio components here
with gr.Row():
model_name = gr.Dropdown(label="Model", choices=model_names, value=model_names[0] if model_names else None)
tts_voice = gr.Dropdown(label="Speaker", choices=list(voice_mapping.keys()), value="Mongolian Male")
slang_rate = gr.Slider(minimum=0, maximum=1, label="Slang rate", value=0.75, interactive=True)
with gr.Row():
use_uploaded_voice = gr.Checkbox(label="Use uploaded voice file", value=False)
voice_upload = gr.File(label="Upload voice file")
tts_text = gr.Textbox(label="Input Text", value="Текстыг оруулна уу.")
but0 = gr.Button("Convert", variant="primary")
with gr.Row():
info_text = gr.Textbox(label="Output info")
edge_tts_output = gr.Audio(label="Voice", type="filepath")
tts_output = gr.Audio(label="Result")
but0.click(
on_convert_click,
inputs=[model_name, tts_text, tts_voice, slang_rate, use_uploaded_voice, voice_upload],
outputs=[info_text, edge_tts_output, tts_output]
)
# Launch the app
app.launch()