Spaces:
Configuration error
Configuration error
Commit
·
33de63c
1
Parent(s):
9dc665b
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,6 +1,43 @@
|
|
| 1 |
import gradio as gr
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
|
| 3 |
-
model_path = get_model_path()
|
| 4 |
demo = gr.Blocks()
|
| 5 |
with demo:
|
| 6 |
gr.Markdown("# **<p align='center'>DIFF-SVC Inference</p>**")
|
|
@@ -12,11 +49,12 @@ with demo:
|
|
| 12 |
</p>
|
| 13 |
"""
|
| 14 |
)
|
| 15 |
-
gr.File(label= 'Load your CKPT')
|
| 16 |
-
gr.File(label= 'Load your Config File')
|
| 17 |
-
|
| 18 |
audio_file = gr.Audio(label = 'Load your WAV', type="filepath")
|
| 19 |
gr.Slider(2, 20, value=4)
|
| 20 |
b1 = gr.Button("Render")
|
| 21 |
-
|
| 22 |
-
|
|
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
from utils.hparams import hparams
|
| 3 |
+
from preprocessing.data_gen_utils import get_pitch_parselmouth,get_pitch_crepe
|
| 4 |
+
import numpy as np
|
| 5 |
+
import matplotlib.pyplot as plt
|
| 6 |
+
import IPython.display as ipd
|
| 7 |
+
import utils
|
| 8 |
+
import librosa
|
| 9 |
+
import torchcrepe
|
| 10 |
+
from infer import *
|
| 11 |
+
import logging
|
| 12 |
+
from infer_tools.infer_tool import *
|
| 13 |
+
import io
|
| 14 |
+
def render_audio(audio_file):
|
| 15 |
+
print(audio_file)
|
| 16 |
+
############
|
| 17 |
+
logging.getLogger('numba').setLevel(logging.WARNING)
|
| 18 |
+
|
| 19 |
+
# 工程文件夹名,训练时用的那个
|
| 20 |
+
project_name = "Unnamed"
|
| 21 |
+
model_path = f'./checkpoints/Unnamed/model_ckpt_steps_192000.ckpt'
|
| 22 |
+
config_path=f'./checkpoints/Unnamed/config.yaml'
|
| 23 |
+
hubert_gpu=False
|
| 24 |
+
svc_model = Svc(project_name,config_path,hubert_gpu, model_path)
|
| 25 |
+
print('model loaded')
|
| 26 |
+
wav_fn = audio_file
|
| 27 |
+
demoaudio, sr = librosa.load(wav_fn)
|
| 28 |
+
key = -8 # 音高调整,支持正负(半音)
|
| 29 |
+
# 加速倍数
|
| 30 |
+
|
| 31 |
+
pndm_speedup = 20
|
| 32 |
+
wav_gen='queeeeee.wav'#直接改后缀可以保存不同格式音频,如flac可无损压缩
|
| 33 |
+
f0_tst, f0_pred, audio = run_clip(svc_model,file_path=wav_fn, key=key, acc=pndm_speedup, use_crepe=True, use_pe=True, thre=0.05,
|
| 34 |
+
use_gt_mel=False, add_noise_step=500,project_name=project_name,out_path=wav_gen)
|
| 35 |
+
|
| 36 |
+
|
| 37 |
+
|
| 38 |
+
def segment(audio):
|
| 39 |
+
pass # Implement your image segmentation model here...
|
| 40 |
|
|
|
|
| 41 |
demo = gr.Blocks()
|
| 42 |
with demo:
|
| 43 |
gr.Markdown("# **<p align='center'>DIFF-SVC Inference</p>**")
|
|
|
|
| 49 |
</p>
|
| 50 |
"""
|
| 51 |
)
|
| 52 |
+
ckpt_file = gr.File(label= 'Load your CKPT', type="file")
|
| 53 |
+
config_file = gr.File(label= 'Load your Config File', type="file")
|
|
|
|
| 54 |
audio_file = gr.Audio(label = 'Load your WAV', type="filepath")
|
| 55 |
gr.Slider(2, 20, value=4)
|
| 56 |
b1 = gr.Button("Render")
|
| 57 |
+
b1.click(fn=render_audio, inputs=audio_file)
|
| 58 |
+
|
| 59 |
+
|
| 60 |
+
demo.launch()
|