Spaces:
Build error
Build error
ChrisPreston
commited on
Commit
·
ebe9a08
1
Parent(s):
12b8772
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,86 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from utils.hparams import hparams
|
2 |
+
import scipy.io.wavfile as wav
|
3 |
+
import numpy as np
|
4 |
+
import matplotlib.pyplot as plt
|
5 |
+
import IPython.display as ipd
|
6 |
+
import utils
|
7 |
+
import librosa
|
8 |
+
import torchcrepe
|
9 |
+
from infer import *
|
10 |
+
import logging
|
11 |
+
from infer_tools.infer_tool import *
|
12 |
+
import gradio as gr
|
13 |
+
import json
|
14 |
+
|
15 |
+
logging.getLogger('numba').setLevel(logging.WARNING)
|
16 |
+
svc_model = None
|
17 |
+
project_name = "aqua"
|
18 |
+
wave_name = f"./temp.wav"
|
19 |
+
model_path = f'./aqua/clean_model_ckpt_steps_100000.ckpt'
|
20 |
+
config_path = f'./aqua/config.yaml'
|
21 |
+
spk_id = "aqua"
|
22 |
+
|
23 |
+
def infer(hubert_gpu, wav_fn, tran, accelerate, auto_key):
|
24 |
+
|
25 |
+
model = Svc(project_name, config_path, hubert_gpu, model_path, onnx=False)
|
26 |
+
|
27 |
+
if wav_fn is not None:
|
28 |
+
audio_path = wav_fn
|
29 |
+
else:
|
30 |
+
return "请先上传wav格式的音频文件", None, None
|
31 |
+
run_clip(raw_audio_path=audio_path, svc_model=model, key=tran, acc=accelerate, use_crepe=True,
|
32 |
+
spk_id=spk_id, auto_key=auto_key, project_name=project_name, out_path=wave_name)
|
33 |
+
|
34 |
+
au_out = wave_name
|
35 |
+
|
36 |
+
return "转换成功", au_out
|
37 |
+
|
38 |
+
app = gr.Blocks()
|
39 |
+
with app:
|
40 |
+
with gr.Tabs():
|
41 |
+
with gr.TabItem("推理"):
|
42 |
+
with gr.Blocks():
|
43 |
+
with gr.Blocks():
|
44 |
+
with gr.Box():
|
45 |
+
gr.Markdown(value="""**上传音频**""")
|
46 |
+
with gr.Row():
|
47 |
+
upload_input = gr.Audio(source="upload", label="源音频", type="filepath", elem_id="audio_inputs")
|
48 |
+
out_audio = gr.Audio(label="输出音频")
|
49 |
+
with gr.Blocks():
|
50 |
+
with gr.Box():
|
51 |
+
gr.Markdown(value="""**参数设置**""")
|
52 |
+
with gr.Row():
|
53 |
+
use_gpu = gr.Checkbox(label="启用GPU加速(需CUDA)", value=True)
|
54 |
+
auto = gr.Checkbox(label="启用自动变调", value=False)
|
55 |
+
with gr.Row():
|
56 |
+
acc_vaule = gr.Slider(1, 50, value=20, interactive=True, label="加速倍率")
|
57 |
+
with gr.Row():
|
58 |
+
pitch_vaule = gr.Slider(-96, 96, value=0, interactive=True, label="变调(半音)")
|
59 |
+
with gr.Row():
|
60 |
+
with gr.Column(scale=1):
|
61 |
+
infer_md = gr.Button("转换音频", variant="primary")
|
62 |
+
with gr.Blocks():
|
63 |
+
with gr.Box():
|
64 |
+
gr.Markdown(value="""**输出日志**""")
|
65 |
+
infer_msg = gr.Textbox(label="日志")
|
66 |
+
infer_md.click(infer, [use_gpu, upload_input, pitch_vaule, acc_vaule, auto], [infer_msg, out_audio])
|
67 |
+
with gr.TabItem("协议"):
|
68 |
+
gr.Markdown(value="""
|
69 |
+
此为上传文件推理用GUI,需要变声功能请使用变声器\n
|
70 |
+
原项目地址:https://github.com/openvpi/diff-svc\n
|
71 |
+
代码修改:@ChrisPreston\n
|
72 |
+
模型训练:@ChrisPreston\n
|
73 |
+
音源:Aqua Ch. 湊あくあ https://www.youtube.com/@MinatoAqua カバー株式会社\n
|
74 |
+
模型使用协议(重要):\n
|
75 |
+
1.请勿用于商业目的\n
|
76 |
+
2.请勿用于会影响主播本人的行为(比如冒充本人发表争议言论)\n
|
77 |
+
3.请勿用于血腥、暴力、性相关、政治相关内容\n
|
78 |
+
4.不允许二次分发模型\n
|
79 |
+
5.非个人使用场合请注明模型作者@ChrisPreston以及diff-svc原项目\n
|
80 |
+
6.允许用于个人娱乐场景下的游戏语音、直播活动,不得用于低创内容,用于直播前请与本人联系\n
|
81 |
+
联系方式:电邮:[email protected], b站:https://space.bilibili.com/18801308\n
|
82 |
+
免责声明:由于使用本模型造成的法律纠纷本人概不负责
|
83 |
+
""")
|
84 |
+
|
85 |
+
app.launch(share=False)
|
86 |
+
|