File size: 1,052 Bytes
edb1a28
6bb339b
 
6ec4637
6bb339b
 
 
 
 
 
 
68f5f0b
6bb339b
edb1a28
 
 
d3c9157
edb1a28
 
 
6bb339b
edb1a28
 
57f6296
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
from fairseq.checkpoint_utils import load_model_ensemble_and_task_from_hf_hub
from fairseq.models.text_to_speech.hub_interface import TTSHubInterface
import IPython.display as ipd
import gradio as gr

models, cfg, task = load_model_ensemble_and_task_from_hf_hub(
    "facebook/tts_transformer-tr-cv7",
    arg_overrides={"vocoder": "hifigan", "fp16": False}
)
model = models[0]
TTSHubInterface.update_cfg_with_data_cfg(cfg, task.data_cfg)
generator = task.build_generator([model], cfg)

def tts(text):
    #text = "bu bir deneme yazısı"
    with tempfile.NamedTemporaryFile(suffix=".wav", delete=False) as fp:
        #coquiTTS.get_tts(text, fp, speaker = {"language" : language})
        sample = TTSHubInterface.get_model_input(task, text)
        wav, rate = TTSHubInterface.get_prediction(task, model, generator, sample)
        return ipd.Audio(wav, rate=rate)

outputs = gr.Audio(label="Output")
iface = gr.Interface(fn=greet, inputs=gr.inputs.Textbox(placeholder="Lütfen Cümle Giriniz...", lines=5), outputs=outputs)
iface.launch(share=True)