Spaces:
Running
Running
Mahiruoshi
commited on
Commit
•
b84a4ff
1
Parent(s):
34d6c3d
Update app.py
Browse files
app.py
CHANGED
@@ -166,7 +166,7 @@ def tts():
|
|
166 |
<title>TTS API Documentation</title>
|
167 |
</head>
|
168 |
<body>
|
169 |
-
<iframe src="
|
170 |
</body>
|
171 |
</html>
|
172 |
""")
|
@@ -192,89 +192,8 @@ def tts():
|
|
192 |
'Text': unique_filename .encode('utf-8')}
|
193 |
return wav_bytes, 200, headers
|
194 |
|
195 |
-
def gradio_interface():
|
196 |
-
return app.launch(share=False)
|
197 |
-
|
198 |
if __name__ == "__main__":
|
199 |
speaker_ids = hps.spk2id
|
200 |
speakers = list(speaker_ids.keys())
|
201 |
last_text = ""
|
202 |
-
|
203 |
-
for band in BandList:
|
204 |
-
with gr.TabItem(band):
|
205 |
-
for name in BandList[band]:
|
206 |
-
with gr.TabItem(name):
|
207 |
-
with gr.Row():
|
208 |
-
with gr.Column():
|
209 |
-
with gr.Row():
|
210 |
-
gr.Markdown(
|
211 |
-
'<div align="center">'
|
212 |
-
f'<img style="width:auto;height:400px;" src="https://mahiruoshi-bangdream-bert-vits2.hf.space/file/image/{name}.png">'
|
213 |
-
'</div>'
|
214 |
-
)
|
215 |
-
length_scale = gr.Slider(
|
216 |
-
minimum=0.1, maximum=2, value=1, step=0.01, label="语速调节"
|
217 |
-
)
|
218 |
-
with gr.Accordion(label="参数设定", open=False):
|
219 |
-
sdp_ratio = gr.Slider(
|
220 |
-
minimum=0, maximum=1, value=0.5, step=0.01, label="SDP/DP混合比"
|
221 |
-
)
|
222 |
-
noise_scale = gr.Slider(
|
223 |
-
minimum=0.1, maximum=2, value=0.6, step=0.01, label="感情调节"
|
224 |
-
)
|
225 |
-
noise_scale_w = gr.Slider(
|
226 |
-
minimum=0.1, maximum=2, value=0.667, step=0.01, label="音素长度"
|
227 |
-
)
|
228 |
-
speaker = gr.Dropdown(
|
229 |
-
choices=speakers, value=name, label="说话人"
|
230 |
-
)
|
231 |
-
'''
|
232 |
-
with gr.Accordion(label="切换模型", open=False):
|
233 |
-
modelstrs = gr.Dropdown(label = "模型", choices = modelPaths, value = modelPaths[0], type = "value")
|
234 |
-
btnMod = gr.Button("载入模型")
|
235 |
-
statusa = gr.TextArea()
|
236 |
-
btnMod.click(loadmodel, inputs=[modelstrs], outputs = [statusa])
|
237 |
-
'''
|
238 |
-
with gr.Column():
|
239 |
-
text = gr.TextArea(
|
240 |
-
label="输入纯日语或者中文",
|
241 |
-
placeholder="输入纯日语或者中文",
|
242 |
-
value="为什么要演奏春日影!",
|
243 |
-
)
|
244 |
-
style_text = gr.Textbox(label="辅助文本")
|
245 |
-
style_weight = gr.Slider(
|
246 |
-
minimum=0,
|
247 |
-
maximum=1,
|
248 |
-
value=0.7,
|
249 |
-
step=0.1,
|
250 |
-
label="Weight",
|
251 |
-
info="主文本和辅助文本的bert混合比率,0表示仅主文本,1表示仅辅助文本",
|
252 |
-
)
|
253 |
-
btn = gr.Button("点击生成", variant="primary")
|
254 |
-
audio_output = gr.Audio(label="Output Audio")
|
255 |
-
'''
|
256 |
-
btntran = gr.Button("快速中翻日")
|
257 |
-
translateResult = gr.TextArea("从这复制翻译后的文本")
|
258 |
-
btntran.click(translate, inputs=[text], outputs = [translateResult])
|
259 |
-
'''
|
260 |
-
btn.click(
|
261 |
-
infer,
|
262 |
-
inputs=[
|
263 |
-
text,
|
264 |
-
speaker,
|
265 |
-
style_text,
|
266 |
-
style_weight,
|
267 |
-
sdp_ratio,
|
268 |
-
noise_scale,
|
269 |
-
noise_scale_w,
|
270 |
-
length_scale,
|
271 |
-
],
|
272 |
-
outputs=[audio_output],
|
273 |
-
)
|
274 |
-
|
275 |
-
api_thread = Thread(target=Flaskapp.run, args=("0.0.0.0", 5000))
|
276 |
-
gradio_thread = Thread(target=gradio_interface)
|
277 |
-
gradio_thread.start()
|
278 |
-
print("推理页面已开启!")
|
279 |
-
api_thread.start()
|
280 |
-
print("api页面已开启!运行在5000端口")
|
|
|
166 |
<title>TTS API Documentation</title>
|
167 |
</head>
|
168 |
<body>
|
169 |
+
<iframe src="https://mahiruoshi-bangdream-bert-vits2.hf.space" style="width:100%; height:100vh; border:none;"></iframe>
|
170 |
</body>
|
171 |
</html>
|
172 |
""")
|
|
|
192 |
'Text': unique_filename .encode('utf-8')}
|
193 |
return wav_bytes, 200, headers
|
194 |
|
|
|
|
|
|
|
195 |
if __name__ == "__main__":
|
196 |
speaker_ids = hps.spk2id
|
197 |
speakers = list(speaker_ids.keys())
|
198 |
last_text = ""
|
199 |
+
Flaskapp.run(host="0.0.0.0", port=7860,debug=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|