Spaces:
Running
Running
kevinwang676
commited on
Commit
·
93c3d3d
1
Parent(s):
d6570c8
Update app.py
Browse files
app.py
CHANGED
@@ -9,6 +9,11 @@ from modelscope.models.audio.tts import SambertHifigan
|
|
9 |
from modelscope.pipelines import pipeline
|
10 |
from modelscope.utils.constant import Tasks
|
11 |
|
|
|
|
|
|
|
|
|
|
|
12 |
# model_0
|
13 |
|
14 |
model_dir = os.path.abspath("./pretrain_work_dir")
|
@@ -108,6 +113,21 @@ def extend(audio):
|
|
108 |
|
109 |
return "upsample.wav"
|
110 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
111 |
|
112 |
app = gr.Blocks()
|
113 |
|
@@ -125,11 +145,13 @@ with app:
|
|
125 |
with gr.Row():
|
126 |
out = gr.Audio(label="为您生成的专属音频")
|
127 |
out1 = gr.Audio(label="更高采样率的专属音频")
|
|
|
128 |
btn2 = gr.Button("一键提高采样率")
|
129 |
|
130 |
btn.click(fn=infer, inputs=[inp], outputs=[out])
|
131 |
btn1.click(fn=infer1, inputs=[inp], outputs=[out])
|
132 |
btn2.click(fn=extend, inputs=[out], outputs=[out1])
|
|
|
133 |
|
134 |
gr.Markdown("### <center>注意❗:请不要生成会对个人以及组织造成侵害的内容,此程序仅供科研、学习及个人娱乐使用。</center>")
|
135 |
gr.HTML('''
|
|
|
9 |
from modelscope.pipelines import pipeline
|
10 |
from modelscope.utils.constant import Tasks
|
11 |
|
12 |
+
import torch
|
13 |
+
import torchaudio
|
14 |
+
from denoiser import pretrained
|
15 |
+
from denoiser.dsp import convert_audio
|
16 |
+
|
17 |
# model_0
|
18 |
|
19 |
model_dir = os.path.abspath("./pretrain_work_dir")
|
|
|
113 |
|
114 |
return "upsample.wav"
|
115 |
|
116 |
+
# denoise
|
117 |
+
|
118 |
+
model1 = pretrained.dns64().cuda()
|
119 |
+
|
120 |
+
def denoise(audio):
|
121 |
+
|
122 |
+
wav, sr = torchaudio.load(audio)
|
123 |
+
wav = convert_audio(wav.cuda(), sr, model1.sample_rate, model1.chin)
|
124 |
+
with torch.no_grad():
|
125 |
+
denoised = model1(wav[None])[0]
|
126 |
+
|
127 |
+
write("denoised.wav", model1.sample_rate, denoised.data.cpu().numpy())
|
128 |
+
|
129 |
+
return "denoised.wav"
|
130 |
+
|
131 |
|
132 |
app = gr.Blocks()
|
133 |
|
|
|
145 |
with gr.Row():
|
146 |
out = gr.Audio(label="为您生成的专属音频")
|
147 |
out1 = gr.Audio(label="更高采样率的专属音频")
|
148 |
+
out2 = gr.Audio(label="降噪后的高采样率音频")
|
149 |
btn2 = gr.Button("一键提高采样率")
|
150 |
|
151 |
btn.click(fn=infer, inputs=[inp], outputs=[out])
|
152 |
btn1.click(fn=infer1, inputs=[inp], outputs=[out])
|
153 |
btn2.click(fn=extend, inputs=[out], outputs=[out1])
|
154 |
+
btn2.click(fn=denoise, inputs=[out1], outputs=[out2])
|
155 |
|
156 |
gr.Markdown("### <center>注意❗:请不要生成会对个人以及组织造成侵害的内容,此程序仅供科研、学习及个人娱乐使用。</center>")
|
157 |
gr.HTML('''
|