File size: 1,496 Bytes
6127b48
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
30
31
32
33
34
35
36
37
38
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()