Kangarroar commited on
Commit
a16e3be
1 Parent(s): b99a0d1

Delete initial.py

Browse files
Files changed (1) hide show
  1. initial.py +0 -101
initial.py DELETED
@@ -1,101 +0,0 @@
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
- import tempfile
15
- ##Render function
16
- def render_audio(audio_file):
17
- print(audio_file)
18
- print(ckpt)
19
- print(yaml)
20
- ############
21
- logging.getLogger('numba').setLevel(logging.WARNING)
22
-
23
- # 工程文件夹名,训练时用的那个
24
- project_name = "Unnamed"
25
- model_path = ckpt
26
- config_path= yaml
27
- hubert_gpu=True
28
- svc_model = Svc(project_name,config_path,hubert_gpu, model_path)
29
- print('model loaded')
30
- wav_fn = audio_file
31
- demoaudio, sr = librosa.load(wav_fn)
32
- key = -8 # 音高调整,支持正负(半音)
33
- # 加速倍数
34
-
35
- pndm_speedup = 20
36
- wav_gen='queeeeee.wav'#直接改后缀可以保存不同格式音频,如flac可无损压缩
37
- 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,
38
- use_gt_mel=False, add_noise_step=500,project_name=project_name,out_path=wav_gen)
39
- ############################################
40
- #Transform ckpt binary into .ckpt
41
- def transform_binary(ckpt_file):
42
- # Create a temporary file and write the binary contents to it
43
- temp_file = tempfile.NamedTemporaryFile(suffix='.ckpt', delete=False)
44
- temp_file.write(ckpt_file)
45
- print("CKPT Path is:", temp_file.name)
46
- global ckpt
47
- ckpt = temp_file.name
48
-
49
- print(ckpt)
50
- print(ckpt)
51
- print(ckpt)
52
- return temp_file.name
53
-
54
- #Transform yaml binary into .yaml
55
- def transform_binary2(yaml_file):
56
- # Create a temporary file and write the binary contents to it
57
- temp_file = tempfile.NamedTemporaryFile(suffix='.yaml', delete=False)
58
- temp_file.write(yaml_file)
59
- print("YAML Path is:", temp_file.name)
60
- global yaml
61
- yaml = temp_file.name
62
- print(yaml)
63
- print(yaml)
64
- return temp_file.name
65
-
66
- #Play audio
67
- def play(audio_file):
68
- print(audio_file)
69
- upload_input = gr.inputs.File()
70
- output_label = gr.outputs.Label()
71
-
72
- demo = gr.Blocks()
73
- with demo:
74
- gr.Markdown("# **<p align='center'>DIFF-SVC Inference</p>**")
75
-
76
- gr.Markdown(
77
- """
78
- <p style='text-align: center'>
79
- Render whatever model you want with this space!
80
- </p>
81
- """
82
- )
83
- ckpt_file = gr.File(label= 'Load your CKPT', type="binary")
84
- yaml_file = gr.File(label= 'Load your YAML', type="binary")
85
- audio_file = gr.Audio(label = 'Load your WAV', type="filepath")
86
- #Button 1
87
- b1 = gr.Button("Decompile CKPT")
88
- b1.click(transform_binary, inputs=ckpt_file)
89
- #Button 2
90
- b2 = gr.Button("Decompile YAML")
91
- b2.click(transform_binary2, inputs=yaml_file)
92
- #Button 4
93
- b4 = gr.Button("Render")
94
- b4.click(fn=render_audio, inputs=[audio_file])
95
- def spam():
96
- print(yaml)
97
- print(ckpt)
98
- #b5 = gr.Button("SPAM ME")
99
- #b5.click(fn=spam)
100
-
101
- demo.launch()