Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1,23 +1,31 @@
|
|
1 |
import gradio as gr
|
2 |
-
from
|
3 |
-
from
|
|
|
4 |
|
5 |
-
|
6 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
|
8 |
-
|
9 |
-
|
10 |
-
|
|
|
|
|
|
|
11 |
|
12 |
iface = gr.Interface(
|
13 |
-
fn=
|
14 |
-
inputs=gr.inputs.Textbox(lines=
|
15 |
-
outputs=
|
16 |
-
|
17 |
-
|
18 |
-
],
|
19 |
-
title="Gerador de Áudio com IA",
|
20 |
-
description="Digite um texto para gerar áudio usando IA."
|
21 |
)
|
22 |
|
23 |
iface.launch()
|
|
|
1 |
import gradio as gr
|
2 |
+
from fairseq.checkpoint_utils import load_model_ensemble_and_task_from_hf_hub
|
3 |
+
from fairseq.models.text_to_speech.hub_interface import TTSHubInterface
|
4 |
+
import numpy as np
|
5 |
|
6 |
+
def load_tts_model():
|
7 |
+
models, cfg, task = load_model_ensemble_and_task_from_hf_hub(
|
8 |
+
"facebook/tts_transformer-zh-cv7_css10",
|
9 |
+
arg_overrides={"vocoder": "hifigan", "fp16": False}
|
10 |
+
)
|
11 |
+
model = models[0]
|
12 |
+
TTSHubInterface.update_cfg_with_data_cfg(cfg, task.data_cfg)
|
13 |
+
generator = task.build_generator(model, cfg)
|
14 |
+
return task, model, generator
|
15 |
|
16 |
+
task, model, generator = load_tts_model()
|
17 |
+
|
18 |
+
def synthesize_text(text):
|
19 |
+
sample = TTSHubInterface.get_model_input(task, text)
|
20 |
+
wav, rate = TTSHubInterface.get_prediction(task, model, generator, sample)
|
21 |
+
return np.array(wav), rate
|
22 |
|
23 |
iface = gr.Interface(
|
24 |
+
fn=synthesize_text,
|
25 |
+
inputs=gr.inputs.Textbox(lines=2, placeholder="Enter Chinese text here..."),
|
26 |
+
outputs=gr.outputs.Audio(label="Synthesized Speech"),
|
27 |
+
title="Text to Speech Synthesis",
|
28 |
+
description="A simple text-to-speech app using Fairseq TTS model."
|
|
|
|
|
|
|
29 |
)
|
30 |
|
31 |
iface.launch()
|