indic / app.py
azamat's picture
Init
6127b48
raw
history blame
1.5 kB
import os
import gradio as gr
models = [
"https://github.com/AI4Bharat/Indic-TTS/releases/download/v1-checkpoints-release/hi.zip",
"https://github.com/AI4Bharat/Indic-TTS/releases/download/v1-checkpoints-release/bn.zip"
]
for model in models:
os.system(f"wget {model}")
os.system(f"unzip {model.split('/')[-1]}")
os.system(f"rm -fr {{model.split('/')[-1]}}")
def convert(text, language, out = "out.wav"):
if language == "Hindi":
m = "hi"
else:
m = "bn"
os.system(f'python3 -m TTS.bin.synthesize --text "{text}" --model_path {m}/fastpitch/best_model.pth --config_path {m}/fastpitch/config.json --vocoder_path {m}/hifigan/best_model.pth --vocoder_config_path {m}/hifigan/config.json --speaker_idx "male" --out_path {out}')
return out
text = gr.Textbox(value = "यह कल का दिन अद्भुत था क्योंकि हम संगीत कार्यक्रम से वापस आ गए हैं।",
placeholder = "Enter a text to synthesize",
label = "Text")
language = gr.Dropdown(choices = ["Hindi", "Bangla"],
value = "Hindi",
type = "value",
label = "Language")
inputs = [text, language]
outputs = gr.outputs.Audio(label = "Output Audio", type = 'filepath')
title = "Indic Languages Speech Synthesis"
gr.Interface(convert, inputs, outputs, title=title, enable_queue=True).launch()