Spaces:
Running
on
Zero
Running
on
Zero
update
Browse files
app.py
CHANGED
@@ -1,23 +1,39 @@
|
|
1 |
import gradio as gr
|
2 |
-
|
|
|
|
|
3 |
|
4 |
-
# 加载一个 Hugging Face 预训练的 TTS 模型
|
5 |
-
tts = pipeline("text-to-speech", model="facebook/fastspeech2-en-ljspeech", device=0)
|
6 |
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
|
12 |
-
# 创建 Gradio 接口
|
13 |
iface = gr.Interface(
|
14 |
-
fn=tts_inference,
|
15 |
-
inputs=
|
16 |
-
|
|
|
|
|
|
|
|
|
17 |
title="TTS Demo",
|
18 |
description="Enter some text and listen to the generated speech."
|
19 |
)
|
20 |
|
21 |
-
# 启动 Gradio 应用
|
22 |
if __name__ == "__main__":
|
23 |
iface.launch()
|
|
|
1 |
import gradio as gr
|
2 |
+
import os
|
3 |
+
import torchaudio
|
4 |
+
from fireredtts.fireredtts import FireRedTTS
|
5 |
|
|
|
|
|
6 |
|
7 |
+
gpt_path = 'https://huggingface.co/fireredteam/FireRedTTS/resolve/main/fireredtts_gpt.pt'
|
8 |
+
speaker_path = 'https://huggingface.co/fireredteam/FireRedTTS/resolve/main/fireredtts_speaker.bin'
|
9 |
+
decoder_path = 'https://huggingface.co/fireredteam/FireRedTTS/resolve/main/fireredtts_token2wav.pt'
|
10 |
+
|
11 |
+
|
12 |
+
tts = FireRedTTS(
|
13 |
+
config_path="configs/config_24k.json",
|
14 |
+
pretrained_path='pretrained_models',
|
15 |
+
)
|
16 |
+
|
17 |
+
def tts_inference(text, prompt_wav='examples/prompt_1.wav', lang='zh'):
|
18 |
+
syn_audio = tts.synthesize(
|
19 |
+
prompt_wav=prompt_wav,
|
20 |
+
text=text,
|
21 |
+
lang=lang,
|
22 |
+
)
|
23 |
+
return syn_audio.detach().cpu()
|
24 |
+
|
25 |
|
|
|
26 |
iface = gr.Interface(
|
27 |
+
fn=tts_inference,
|
28 |
+
inputs=[
|
29 |
+
gr.Textbox(label="输入文本"),
|
30 |
+
# gr.Dropdown(["en-US-Wav2Vec2-Kendra", "en-US-Wav2Vec2-John"], label="选择声音"),
|
31 |
+
# gr.Slider(minimum=0.5, maximum=2.0, value=1.0, label="语速")
|
32 |
+
],
|
33 |
+
outputs=gr.Audio(label="生成的语音"),
|
34 |
title="TTS Demo",
|
35 |
description="Enter some text and listen to the generated speech."
|
36 |
)
|
37 |
|
|
|
38 |
if __name__ == "__main__":
|
39 |
iface.launch()
|