Spaces:
Sleeping
Sleeping
zhuowen
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -56,7 +56,7 @@ config = Config()
|
|
56 |
|
57 |
edge_output_filename = "edge_output.mp3"
|
58 |
tts_voice_list = asyncio.get_event_loop().run_until_complete(edge_tts.list_voices())
|
59 |
-
tts_voices = [
|
60 |
|
61 |
model_root = "weights"
|
62 |
models = [
|
@@ -66,20 +66,20 @@ if len(models) == 0:
|
|
66 |
raise ValueError("No model found in `weights` folder")
|
67 |
models.sort()
|
68 |
|
69 |
-
def tts_new(text,path):
|
70 |
url = "https://www.text-to-speech.cn/getSpeek.php"
|
71 |
|
72 |
payload = {
|
73 |
"user_id": str(random.randint(120100,2000000)),
|
74 |
"language": "中文(普通话,简体)",
|
75 |
-
"voice":
|
76 |
"text": text,
|
77 |
"role": "0",
|
78 |
"style": "0",
|
79 |
"styledegree": "1",
|
80 |
"volume": "75",
|
81 |
"predict": "0",
|
82 |
-
"rate":
|
83 |
"pitch": "0",
|
84 |
"kbitrate": "audio-16khz-128kbitrate-mono-mp3",
|
85 |
"silence": "",
|
@@ -219,7 +219,7 @@ def tts(
|
|
219 |
# tts_text, "-".join(tts_voice.split("-")[:-1]), rate=speed_str
|
220 |
# ).save(edge_output_filename)
|
221 |
# )
|
222 |
-
tts_new(tts_text,edge_output_filename)
|
223 |
t1 = time.time()
|
224 |
edge_time = t1 - t0
|
225 |
audio, sr = librosa.load(edge_output_filename, sr=16000, mono=True)
|
@@ -347,7 +347,7 @@ with app:
|
|
347 |
label="Edge-tts speaker (format: language-Country-Name-Gender)",
|
348 |
choices=tts_voices,
|
349 |
allow_custom_value=False,
|
350 |
-
value="
|
351 |
)
|
352 |
speed = gr.Slider(
|
353 |
minimum=-100,
|
@@ -358,7 +358,7 @@ with app:
|
|
358 |
interactive=True,
|
359 |
)
|
360 |
with gr.Column():
|
361 |
-
tts_text = gr.Textbox(label="Input Text", value="
|
362 |
with gr.Column():
|
363 |
but0 = gr.Button("Convert", variant="primary")
|
364 |
info_text = gr.Textbox(label="Output info")
|
|
|
56 |
|
57 |
edge_output_filename = "edge_output.mp3"
|
58 |
tts_voice_list = asyncio.get_event_loop().run_until_complete(edge_tts.list_voices())
|
59 |
+
tts_voices = ['zh-CN-XiaoxiaoMultilingualNeural','zh-CN-YunyiMultilingualNeural','zh-CN-XiaoyuMultilingualNeural','zh-CN-XiaochenMultilingualNeural']
|
60 |
|
61 |
model_root = "weights"
|
62 |
models = [
|
|
|
66 |
raise ValueError("No model found in `weights` folder")
|
67 |
models.sort()
|
68 |
|
69 |
+
def tts_new(text,path,voice='zh-CN-XiaoxiaoMultilingualNeural',rate=-8):
|
70 |
url = "https://www.text-to-speech.cn/getSpeek.php"
|
71 |
|
72 |
payload = {
|
73 |
"user_id": str(random.randint(120100,2000000)),
|
74 |
"language": "中文(普通话,简体)",
|
75 |
+
"voice": voice,
|
76 |
"text": text,
|
77 |
"role": "0",
|
78 |
"style": "0",
|
79 |
"styledegree": "1",
|
80 |
"volume": "75",
|
81 |
"predict": "0",
|
82 |
+
"rate": rate,
|
83 |
"pitch": "0",
|
84 |
"kbitrate": "audio-16khz-128kbitrate-mono-mp3",
|
85 |
"silence": "",
|
|
|
219 |
# tts_text, "-".join(tts_voice.split("-")[:-1]), rate=speed_str
|
220 |
# ).save(edge_output_filename)
|
221 |
# )
|
222 |
+
tts_new(tts_text,edge_output_filename,tts_voice,speed)
|
223 |
t1 = time.time()
|
224 |
edge_time = t1 - t0
|
225 |
audio, sr = librosa.load(edge_output_filename, sr=16000, mono=True)
|
|
|
347 |
label="Edge-tts speaker (format: language-Country-Name-Gender)",
|
348 |
choices=tts_voices,
|
349 |
allow_custom_value=False,
|
350 |
+
value="zh-CN-XiaoxiaoMultilingualNeural",
|
351 |
)
|
352 |
speed = gr.Slider(
|
353 |
minimum=-100,
|
|
|
358 |
interactive=True,
|
359 |
)
|
360 |
with gr.Column():
|
361 |
+
tts_text = gr.Textbox(label="Input Text", value="很高兴见到你")
|
362 |
with gr.Column():
|
363 |
but0 = gr.Button("Convert", variant="primary")
|
364 |
info_text = gr.Textbox(label="Output info")
|