Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
@@ -3,6 +3,7 @@
|
|
3 |
@author:XuMing([email protected])
|
4 |
@description:
|
5 |
"""
|
|
|
6 |
import os
|
7 |
import ssl
|
8 |
|
@@ -31,17 +32,24 @@ m.predict(
|
|
31 |
text_language="auto",
|
32 |
output_path="output_audio.wav"
|
33 |
)
|
34 |
-
assert os.path.exists("output_audio.wav")
|
35 |
|
36 |
|
37 |
-
def
|
38 |
-
|
39 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
40 |
|
41 |
|
42 |
with gr.Blocks(title="parrots WebUI") as app:
|
43 |
gr.Markdown(value="""
|
44 |
-
# <center>在线语音生成(parrots
|
45 |
|
46 |
### <center>parrots项目:https://github.com/shibing624/parrots\n
|
47 |
### <center>数据集下载:https://huggingface.co/datasets/XzJosh/audiodataset\n
|
@@ -54,7 +62,7 @@ with gr.Blocks(title="parrots WebUI") as app:
|
|
54 |
with gr.Group():
|
55 |
gr.Markdown(value="*请填写需要语音合成的文本")
|
56 |
with gr.Row():
|
57 |
-
text = gr.Textbox(label="需要合成的文本", value="", placeholder="
|
58 |
inference_button = gr.Button("合成语音", variant="primary")
|
59 |
output = gr.Audio(label="输出的语音")
|
60 |
inference_button.click(
|
|
|
3 |
@author:XuMing([email protected])
|
4 |
@description:
|
5 |
"""
|
6 |
+
import hashlib
|
7 |
import os
|
8 |
import ssl
|
9 |
|
|
|
32 |
text_language="auto",
|
33 |
output_path="output_audio.wav"
|
34 |
)
|
35 |
+
assert os.path.exists("output_audio.wav"), "output_audio.wav not found"
|
36 |
|
37 |
|
38 |
+
def get_text_hash(text: str):
|
39 |
+
return hashlib.md5(text.encode('utf-8')).hexdigest()
|
40 |
+
|
41 |
+
|
42 |
+
def do_tts_wav_predict(text: str, output_path: str = None):
|
43 |
+
if output_path is None:
|
44 |
+
output_path = f"output_audio_{get_text_hash(text)}.wav"
|
45 |
+
if not os.path.exists(output_path):
|
46 |
+
m.predict(text, text_language="auto", output_path=output_path)
|
47 |
+
return output_path
|
48 |
|
49 |
|
50 |
with gr.Blocks(title="parrots WebUI") as app:
|
51 |
gr.Markdown(value="""
|
52 |
+
# <center>在线语音生成(parrots)speaker:主播卖卖\n
|
53 |
|
54 |
### <center>parrots项目:https://github.com/shibing624/parrots\n
|
55 |
### <center>数据集下载:https://huggingface.co/datasets/XzJosh/audiodataset\n
|
|
|
62 |
with gr.Group():
|
63 |
gr.Markdown(value="*请填写需要语音合成的文本")
|
64 |
with gr.Row():
|
65 |
+
text = gr.Textbox(label="需要合成的文本(建议100字以内)", value="", placeholder="请输入短文本", lines=3)
|
66 |
inference_button = gr.Button("合成语音", variant="primary")
|
67 |
output = gr.Audio(label="输出的语音")
|
68 |
inference_button.click(
|