TheStinger commited on
Commit
0281a51
1 Parent(s): e0f3d10

Upload 9 files

Browse files
Files changed (9) hide show
  1. .gitattributes +36 -35
  2. README.md +14 -13
  3. app.py +207 -0
  4. gitattributes +36 -0
  5. model.index +3 -0
  6. model.pth +3 -0
  7. packages.txt +1 -0
  8. requirements.txt +6 -0
  9. test.ogg +0 -0
.gitattributes CHANGED
@@ -1,35 +1,36 @@
1
- *.7z filter=lfs diff=lfs merge=lfs -text
2
- *.arrow filter=lfs diff=lfs merge=lfs -text
3
- *.bin filter=lfs diff=lfs merge=lfs -text
4
- *.bz2 filter=lfs diff=lfs merge=lfs -text
5
- *.ckpt filter=lfs diff=lfs merge=lfs -text
6
- *.ftz filter=lfs diff=lfs merge=lfs -text
7
- *.gz filter=lfs diff=lfs merge=lfs -text
8
- *.h5 filter=lfs diff=lfs merge=lfs -text
9
- *.joblib filter=lfs diff=lfs merge=lfs -text
10
- *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
- *.mlmodel filter=lfs diff=lfs merge=lfs -text
12
- *.model filter=lfs diff=lfs merge=lfs -text
13
- *.msgpack filter=lfs diff=lfs merge=lfs -text
14
- *.npy filter=lfs diff=lfs merge=lfs -text
15
- *.npz filter=lfs diff=lfs merge=lfs -text
16
- *.onnx filter=lfs diff=lfs merge=lfs -text
17
- *.ot filter=lfs diff=lfs merge=lfs -text
18
- *.parquet filter=lfs diff=lfs merge=lfs -text
19
- *.pb filter=lfs diff=lfs merge=lfs -text
20
- *.pickle filter=lfs diff=lfs merge=lfs -text
21
- *.pkl filter=lfs diff=lfs merge=lfs -text
22
- *.pt filter=lfs diff=lfs merge=lfs -text
23
- *.pth filter=lfs diff=lfs merge=lfs -text
24
- *.rar filter=lfs diff=lfs merge=lfs -text
25
- *.safetensors filter=lfs diff=lfs merge=lfs -text
26
- saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
- *.tar.* filter=lfs diff=lfs merge=lfs -text
28
- *.tar filter=lfs diff=lfs merge=lfs -text
29
- *.tflite filter=lfs diff=lfs merge=lfs -text
30
- *.tgz filter=lfs diff=lfs merge=lfs -text
31
- *.wasm filter=lfs diff=lfs merge=lfs -text
32
- *.xz filter=lfs diff=lfs merge=lfs -text
33
- *.zip filter=lfs diff=lfs merge=lfs -text
34
- *.zst filter=lfs diff=lfs merge=lfs -text
35
- *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
1
+ *.7z filter=lfs diff=lfs merge=lfs -text
2
+ *.arrow filter=lfs diff=lfs merge=lfs -text
3
+ *.bin filter=lfs diff=lfs merge=lfs -text
4
+ *.bz2 filter=lfs diff=lfs merge=lfs -text
5
+ *.ckpt filter=lfs diff=lfs merge=lfs -text
6
+ *.ftz filter=lfs diff=lfs merge=lfs -text
7
+ *.gz filter=lfs diff=lfs merge=lfs -text
8
+ *.h5 filter=lfs diff=lfs merge=lfs -text
9
+ *.joblib filter=lfs diff=lfs merge=lfs -text
10
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
+ *.mlmodel filter=lfs diff=lfs merge=lfs -text
12
+ *.model filter=lfs diff=lfs merge=lfs -text
13
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
14
+ *.npy filter=lfs diff=lfs merge=lfs -text
15
+ *.npz filter=lfs diff=lfs merge=lfs -text
16
+ *.onnx filter=lfs diff=lfs merge=lfs -text
17
+ *.ot filter=lfs diff=lfs merge=lfs -text
18
+ *.parquet filter=lfs diff=lfs merge=lfs -text
19
+ *.pb filter=lfs diff=lfs merge=lfs -text
20
+ *.pickle filter=lfs diff=lfs merge=lfs -text
21
+ *.pkl filter=lfs diff=lfs merge=lfs -text
22
+ *.pt filter=lfs diff=lfs merge=lfs -text
23
+ *.pth filter=lfs diff=lfs merge=lfs -text
24
+ *.rar filter=lfs diff=lfs merge=lfs -text
25
+ *.safetensors filter=lfs diff=lfs merge=lfs -text
26
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
28
+ *.tar filter=lfs diff=lfs merge=lfs -text
29
+ *.tflite filter=lfs diff=lfs merge=lfs -text
30
+ *.tgz filter=lfs diff=lfs merge=lfs -text
31
+ *.wasm filter=lfs diff=lfs merge=lfs -text
32
+ *.xz filter=lfs diff=lfs merge=lfs -text
33
+ *.zip filter=lfs diff=lfs merge=lfs -text
34
+ *.zst filter=lfs diff=lfs merge=lfs -text
35
+ *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ model.index filter=lfs diff=lfs merge=lfs -text
README.md CHANGED
@@ -1,13 +1,14 @@
1
- ---
2
- title: Ilarvctest
3
- emoji: 👀
4
- colorFrom: indigo
5
- colorTo: red
6
- sdk: gradio
7
- sdk_version: 4.36.1
8
- app_file: app.py
9
- pinned: false
10
- license: mit
11
- ---
12
-
13
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
1
+ ---
2
+ title: RVC⚡ZERO
3
+ emoji:
4
+ colorFrom: gray
5
+ colorTo: indigo
6
+ sdk: gradio
7
+ sdk_version: 4.28.3
8
+ app_file: app.py
9
+ license: mit
10
+ pinned: true
11
+ short_description: Voice conversion framework based on VITS
12
+ ---
13
+
14
+ Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
app.py ADDED
@@ -0,0 +1,207 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import requests
3
+ import random
4
+ import os
5
+ import zipfile # built in module for unzipping files (thank god)
6
+ import librosa
7
+ import time
8
+ from infer_rvc_python import BaseLoader
9
+ from pydub import AudioSegment
10
+
11
+ # fucking dogshit toggle
12
+ try:
13
+ import spaces
14
+ spaces_status = True
15
+ except ImportError:
16
+ spaces_status = False
17
+
18
+ converter = BaseLoader(only_cpu=False, hubert_path=None, rmvpe_path=None) # <- yeah so like this handles rvc
19
+
20
+ global pth_file
21
+ global index_file
22
+
23
+ pth_file = "model.pth"
24
+ index_file = "model.index"
25
+
26
+ #CONFIGS
27
+ TEMP_DIR = "temp"
28
+ MODEL_PREFIX = "model"
29
+ PITCH_ALGO_OPT = [
30
+ "pm",
31
+ "harvest",
32
+ "crepe",
33
+ "rmvpe",
34
+ "rmvpe+",
35
+ ]
36
+
37
+
38
+ os.makedirs(TEMP_DIR, exist_ok=True)
39
+
40
+ def unzip_file(file):
41
+ filename = os.path.basename(file).split(".")[0] # converts "model.zip" to "model" so we can do things
42
+ with zipfile.ZipFile(file, 'r') as zip_ref:
43
+ zip_ref.extractall(os.path.join(TEMP_DIR, filename)) # might not be very ram efficient...
44
+ return True
45
+
46
+
47
+ def progress_bar(total, current): # best progress bar ever trust me sunglasses emoji 😎
48
+ return "[" + "=" * int(current / total * 20) + ">" + " " * (20 - int(current / total * 20)) + "] " + str(int(current / total * 100)) + "%"
49
+
50
+ def download_from_url(url, filename=None):
51
+ if "huggingface" not in url:
52
+ return ["The URL must be from huggingface", "Failed", "Failed"]
53
+ if filename is None:
54
+ filename = os.path.join(TEMP_DIR, MODEL_PREFIX + str(random.randint(1, 1000)) + ".zip")
55
+ response = requests.get(url)
56
+ total = int(response.headers.get('content-length', 0)) # bytes to download (length of the file)
57
+ if total > 500000000:
58
+
59
+ return ["The file is too large. You can only download files up to 500 MB in size.", "Failed", "Failed"]
60
+ current = 0
61
+ with open(filename, "wb") as f:
62
+ for data in response.iter_content(chunk_size=4096): # download in chunks of 4096 bytes (4kb - helps with memory usage and speed)
63
+ f.write(data)
64
+ current += len(data)
65
+ print(progress_bar(total, current), end="\r") # \r is a carriage return, it moves the cursor to the start of the line so its like tqdm sunglasses emoji 😎
66
+
67
+ # unzip because the model is in a zip file lel
68
+
69
+ try:
70
+ unzip_file(filename)
71
+ except Exception as e:
72
+ return ["Failed to unzip the file", "Failed", "Failed"] # return early if it fails and like tell the user but its dogshit hahahahahahaha 😎 According to all known laws aviation, there is no way a bee should be able to fly.
73
+ unzipped_dir = os.path.join(TEMP_DIR, os.path.basename(filename).split(".")[0]) # just do what we did in unzip_file because we need the directory
74
+ pth_files = []
75
+ index_files = []
76
+ for root, dirs, files in os.walk(unzipped_dir): # could be done more efficiently because nobody stores models in subdirectories but like who cares (it's a futureproofing thing lel)
77
+ for file in files:
78
+ if file.endswith(".pth"):
79
+ pth_files.append(os.path.join(root, file))
80
+ elif file.endswith(".index"):
81
+ index_files.append(os.path.join(root, file))
82
+
83
+ print(pth_files, index_files) # debug print because im fucking stupid and i need to see what is going on
84
+ global pth_file
85
+ global index_file
86
+ pth_file = pth_files[0]
87
+ index_file = index_files[0]
88
+ return ["Downloaded as " + filename, pth_files[0], index_files[0]]
89
+
90
+ if spaces_status:
91
+ @spaces.GPU()
92
+ def convert_now(audio_files, random_tag, converter):
93
+ return converter(
94
+ audio_files,
95
+ random_tag,
96
+ overwrite=False,
97
+ parallel_workers=8
98
+ )
99
+ else:
100
+ def convert_now(audio_files, random_tag, converter):
101
+ return converter(
102
+ audio_files,
103
+ random_tag,
104
+ overwrite=False,
105
+ parallel_workers=8
106
+ )
107
+
108
+ def run(
109
+ audio_files,
110
+ file_m,
111
+ pitch_alg,
112
+ pitch_lvl,
113
+ file_index,
114
+ index_inf,
115
+ r_m_f,
116
+ e_r,
117
+ c_b_p,
118
+ ):
119
+ if not audio_files:
120
+ raise ValueError("The audio pls")
121
+
122
+ if isinstance(audio_files, str):
123
+ audio_files = [audio_files]
124
+
125
+ try:
126
+ duration_base = librosa.get_duration(filename=audio_files[0])
127
+ print("Duration:", duration_base)
128
+ except Exception as e:
129
+ print(e)
130
+
131
+ random_tag = "USER_"+str(random.randint(10000000, 99999999))
132
+
133
+ converter.apply_conf(
134
+ tag=random_tag,
135
+ file_model=file_m,
136
+ pitch_algo=pitch_alg,
137
+ pitch_lvl=pitch_lvl,
138
+ file_index=file_index,
139
+ index_influence=index_inf,
140
+ respiration_median_filtering=r_m_f,
141
+ envelope_ratio=e_r,
142
+ consonant_breath_protection=c_b_p,
143
+ resample_sr=44100 if audio_files[0].endswith('.mp3') else 0,
144
+ )
145
+ time.sleep(0.1)
146
+
147
+ result = convert_now(audio_files, random_tag, converter)
148
+
149
+ return result[0]
150
+
151
+ with gr.Blocks() as demo:
152
+ gr.Markdown("## Ilaria RVC 💖")
153
+ with gr.Tab("Inference"):
154
+ sound_gui = gr.Audio(value=None,type="filepath",autoplay=False,visible=True,)
155
+ pth_file_ui = gr.Textbox(label="Model pth file",value=pth_file,visible=False,interactive=False,) # gradio is fucking weird (im with stupid v)
156
+ index_file_ui = gr.Textbox(label="Index pth file",value=index_file,visible=False,interactive=False,) # gradio is fucking weird (im with stupid ^)
157
+ pitch_algo_conf = gr.Dropdown(PITCH_ALGO_OPT,value=PITCH_ALGO_OPT[4],label="Pitch algorithm",visible=True,interactive=True,)
158
+ pitch_lvl_conf = gr.Slider(label="Pitch level",minimum=-24,maximum=24,step=1,value=0,visible=True,interactive=True,)
159
+ index_inf_conf = gr.Slider(minimum=0,maximum=1,label="Index influence",value=0.75,)
160
+ respiration_filter_conf = gr.Slider(minimum=0,maximum=7,label="Respiration median filtering",value=3,step=1,interactive=True,)
161
+ envelope_ratio_conf = gr.Slider(minimum=0,maximum=1,label="Envelope ratio",value=0.25,interactive=True,)
162
+ consonant_protec_conf = gr.Slider(minimum=0,maximum=0.5,label="Consonant breath protection",value=0.5,interactive=True,)
163
+ button_conf = gr.Button("Convert",variant="primary",)
164
+ output_conf = gr.Audio(type="filepath",label="Output",)
165
+
166
+ button_conf.click(
167
+ run,
168
+ inputs=[
169
+ sound_gui,
170
+ pth_file_ui,
171
+ pitch_algo_conf,
172
+ pitch_lvl_conf,
173
+ index_file_ui, # put a bullet through my head
174
+ index_inf_conf,
175
+ respiration_filter_conf,
176
+ envelope_ratio_conf,
177
+ consonant_protec_conf,
178
+ ],
179
+ outputs=[output_conf],
180
+ )
181
+
182
+ with gr.Tab("Download Model"):
183
+ # markdown
184
+ gr.Markdown(
185
+ "Download the model from the following URL and upload it here. (Hugginface RVC model)"
186
+ )
187
+ model = gr.Textbox(lines=1, label="Model URL")
188
+ download_button = gr.Button("Download Model")
189
+ status = gr.Textbox(lines=1, label="Status", placeholder="Waiting....", interactive=False)
190
+ model_pth = gr.Textbox(lines=1, label="Model pth file", placeholder="Waiting....", interactive=False)
191
+ index_pth = gr.Textbox(lines=1, label="Index pth file", placeholder="Waiting....", interactive=False)
192
+ download_button.click(download_from_url, model, outputs=[status, model_pth, index_pth])
193
+ set_model_button = gr.Button("Set Model")
194
+ #set_model_button.click(
195
+
196
+ with gr.Tab("Credits"):
197
+ gr.Markdown(
198
+ """
199
+ Ilaria RVC made by [Ilaria](https://huggingface.co/TheStinger) suport her on [ko-fi](https://ko-fi.com/ilariaowo)
200
+
201
+ The Inference code is made by [r3gm](https://huggingface.co/r3gm) (his module helped form this space 💖)
202
+
203
+ made with ❤️ by [mikus](https://github.com/cappuch) - i hacked it up lel
204
+ """
205
+ )
206
+
207
+ demo.queue(api_open=False).launch(show_api=False) # idk ilaria if you want or dont want to
gitattributes ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *.7z filter=lfs diff=lfs merge=lfs -text
2
+ *.arrow filter=lfs diff=lfs merge=lfs -text
3
+ *.bin filter=lfs diff=lfs merge=lfs -text
4
+ *.bz2 filter=lfs diff=lfs merge=lfs -text
5
+ *.ckpt filter=lfs diff=lfs merge=lfs -text
6
+ *.ftz filter=lfs diff=lfs merge=lfs -text
7
+ *.gz filter=lfs diff=lfs merge=lfs -text
8
+ *.h5 filter=lfs diff=lfs merge=lfs -text
9
+ *.joblib filter=lfs diff=lfs merge=lfs -text
10
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
+ *.mlmodel filter=lfs diff=lfs merge=lfs -text
12
+ *.model filter=lfs diff=lfs merge=lfs -text
13
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
14
+ *.npy filter=lfs diff=lfs merge=lfs -text
15
+ *.npz filter=lfs diff=lfs merge=lfs -text
16
+ *.onnx filter=lfs diff=lfs merge=lfs -text
17
+ *.ot filter=lfs diff=lfs merge=lfs -text
18
+ *.parquet filter=lfs diff=lfs merge=lfs -text
19
+ *.pb filter=lfs diff=lfs merge=lfs -text
20
+ *.pickle filter=lfs diff=lfs merge=lfs -text
21
+ *.pkl filter=lfs diff=lfs merge=lfs -text
22
+ *.pt filter=lfs diff=lfs merge=lfs -text
23
+ *.pth filter=lfs diff=lfs merge=lfs -text
24
+ *.rar filter=lfs diff=lfs merge=lfs -text
25
+ *.safetensors filter=lfs diff=lfs merge=lfs -text
26
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
28
+ *.tar filter=lfs diff=lfs merge=lfs -text
29
+ *.tflite filter=lfs diff=lfs merge=lfs -text
30
+ *.tgz filter=lfs diff=lfs merge=lfs -text
31
+ *.wasm filter=lfs diff=lfs merge=lfs -text
32
+ *.xz filter=lfs diff=lfs merge=lfs -text
33
+ *.zip filter=lfs diff=lfs merge=lfs -text
34
+ *.zst filter=lfs diff=lfs merge=lfs -text
35
+ *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ model.index filter=lfs diff=lfs merge=lfs -text
model.index ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:af434a9142b070f7091dcdbbf957b7a01bbc96294add99d186ef1e0d4b226eac
3
+ size 83987395
model.pth ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:896fcee182ecdcea6645a691366ac50153bc63015f43c981da135a8cabe2f088
3
+ size 55028048
packages.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ ffmpeg
requirements.txt ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ torch==2.2.0
2
+ infer-rvc-python==1.1.0
3
+ edge-tts
4
+ pedalboard
5
+ noisereduce
6
+ numpy==1.23.5
test.ogg ADDED
Binary file (73.4 kB). View file