Spaces:
Sleeping
Sleeping
kevinwang676
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -54,6 +54,31 @@ from openai import OpenAI
|
|
54 |
|
55 |
import ffmpeg
|
56 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
57 |
|
58 |
def convert(api_key, text, tgt, voice, save_path):
|
59 |
model = "FreeVC (24kHz)"
|
@@ -251,25 +276,31 @@ def convert_from_srt(apikey, filename, audio_full, voice, multilingual):
|
|
251 |
merge_audios("output")
|
252 |
|
253 |
return "AI配音版.wav"
|
254 |
-
|
|
|
|
|
|
|
255 |
|
256 |
with gr.Blocks() as app:
|
257 |
-
gr.
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
|
|
|
|
|
|
273 |
gr.Markdown("### <center>注意❗:请勿生成会对任何个人或组织造成侵害的内容,请尊重他人的著作权和知识产权。用户对此程序的任何使用行为与程序开发者无关。</center>")
|
274 |
gr.HTML('''
|
275 |
<div class="footer">
|
|
|
54 |
|
55 |
import ffmpeg
|
56 |
|
57 |
+
html_denoise = """
|
58 |
+
<html>
|
59 |
+
<head>
|
60 |
+
</script>
|
61 |
+
<link rel="stylesheet" href="https://gradio.s3-us-west-2.amazonaws.com/2.6.2/static/bundle.css">
|
62 |
+
</head>
|
63 |
+
<body>
|
64 |
+
<div id="target"></div>
|
65 |
+
<script src="https://gradio.s3-us-west-2.amazonaws.com/2.6.2/static/bundle.js"></script>
|
66 |
+
<script
|
67 |
+
type="module"
|
68 |
+
src="https://gradio.s3-us-west-2.amazonaws.com/4.15.0/gradio.js"
|
69 |
+
></script>
|
70 |
+
<iframe
|
71 |
+
src="https://g-app-center-40055665-8145-0zp6jbv.openxlab.space"
|
72 |
+
frameBorder="0"
|
73 |
+
width="360"
|
74 |
+
height="900"
|
75 |
+
align="left"
|
76 |
+
></iframe>
|
77 |
+
|
78 |
+
</body>
|
79 |
+
</html>
|
80 |
+
"""
|
81 |
+
|
82 |
|
83 |
def convert(api_key, text, tgt, voice, save_path):
|
84 |
model = "FreeVC (24kHz)"
|
|
|
276 |
merge_audios("output")
|
277 |
|
278 |
return "AI配音版.wav"
|
279 |
+
|
280 |
+
restart_markdown = ("""
|
281 |
+
<h3 align="center"> 若此页面无法正常显示,请点击[此链接](https://openxlab.org.cn/apps/detail/Kevin676/OpenAI-TTS)唤醒该程序!谢谢🍻 </h3>
|
282 |
+
""")
|
283 |
|
284 |
with gr.Blocks() as app:
|
285 |
+
with gr.Tab("一键去除背景音🤗"):
|
286 |
+
gr.Markdown(restart_markdown)
|
287 |
+
input_webui = gr.HTML(html_denoise)
|
288 |
+
with gr.Tab("一键开启AI配音💕"):
|
289 |
+
gr.Markdown("# <center>🌊💕🎶 OpenAI TTS - SRT文件一键AI配音</center>")
|
290 |
+
gr.Markdown("### <center>🌟 只需上传SRT文件和原版配音文件即可,每次一集视频AI自动配音!Developed by Kevin Wang </center>")
|
291 |
+
with gr.Row():
|
292 |
+
with gr.Column():
|
293 |
+
inp0 = gr.Textbox(type='password', label='请输入您的OpenAI API Key')
|
294 |
+
inp1 = gr.File(file_count="single", label="请上传一集视频对应的SRT文件")
|
295 |
+
inp2 = gr.Audio(label="请上传一集视频的配音文件", type="filepath")
|
296 |
+
inp3 = gr.Dropdown(choices=['alloy', 'echo', 'fable', 'onyx', 'nova', 'shimmer'], label='请选择一个说话人提供基础音色', info="试听音色链接:https://platform.openai.com/docs/guides/text-to-speech/voice-options", value='alloy')
|
297 |
+
#inp4 = gr.Dropdown(label="请选择用于分离伴奏的模型", info="UVR-HP5去除背景音乐效果更好,但会对人声造成一定的损伤", choices=["UVR-HP2", "UVR-HP5"], value="UVR-HP5")
|
298 |
+
inp4 = gr.Checkbox(label="SRT文件是否为双语字幕", info="若为双语字幕,请打勾选择(SRT文件中需要先出现中文字幕,后英文字幕;中英字幕各占一行)")
|
299 |
+
btn = gr.Button("一键开启AI配音吧💕", variant="primary")
|
300 |
+
with gr.Column():
|
301 |
+
out1 = gr.Audio(label="为您生成的AI完整配音", type="filepath")
|
302 |
+
|
303 |
+
btn.click(convert_from_srt, [inp0, inp1, inp2, inp3, inp4], [out1])
|
304 |
gr.Markdown("### <center>注意❗:请勿生成会对任何个人或组织造成侵害的内容,请尊重他人的著作权和知识产权。用户对此程序的任何使用行为与程序开发者无关。</center>")
|
305 |
gr.HTML('''
|
306 |
<div class="footer">
|