Spaces:
Sleeping
Sleeping
Vladimir Alabov
commited on
Commit
β’
03d977c
1
Parent(s):
ef23aba
Refactor
Browse files- appnew.py +0 -334
- __init__.py β so_vits_svc_fork/__init__.py +0 -0
- __main__.py β so_vits_svc_fork/__main__.py +0 -0
- {cluster β so_vits_svc_fork/cluster}/__init__.py +0 -0
- {cluster β so_vits_svc_fork/cluster}/train_cluster.py +0 -0
- dataset.py β so_vits_svc_fork/dataset.py +0 -0
- default_gui_presets.json β so_vits_svc_fork/default_gui_presets.json +0 -0
- f0.py β so_vits_svc_fork/f0.py +0 -0
- gui.py β so_vits_svc_fork/gui.py +0 -0
- hparams.py β so_vits_svc_fork/hparams.py +0 -0
- {inference β so_vits_svc_fork/inference}/__init__.py +0 -0
- {inference β so_vits_svc_fork/inference}/core.py +0 -0
- {inference β so_vits_svc_fork/inference}/main.py +0 -0
- logger.py β so_vits_svc_fork/logger.py +0 -0
- {modules β so_vits_svc_fork/modules}/__init__.py +0 -0
- {modules β so_vits_svc_fork/modules}/attentions.py +0 -0
- {modules β so_vits_svc_fork/modules}/commons.py +0 -0
- {modules β so_vits_svc_fork/modules}/decoders/__init__.py +0 -0
- {modules β so_vits_svc_fork/modules}/decoders/f0.py +0 -0
- {modules β so_vits_svc_fork/modules}/decoders/hifigan/__init__.py +0 -0
- {modules β so_vits_svc_fork/modules}/decoders/hifigan/_models.py +0 -0
- {modules β so_vits_svc_fork/modules}/decoders/hifigan/_utils.py +0 -0
- {modules β so_vits_svc_fork/modules}/decoders/mb_istft/__init__.py +0 -0
- {modules β so_vits_svc_fork/modules}/decoders/mb_istft/_generators.py +0 -0
- {modules β so_vits_svc_fork/modules}/decoders/mb_istft/_loss.py +0 -0
- {modules β so_vits_svc_fork/modules}/decoders/mb_istft/_pqmf.py +0 -0
- {modules β so_vits_svc_fork/modules}/decoders/mb_istft/_stft.py +0 -0
- {modules β so_vits_svc_fork/modules}/decoders/mb_istft/_stft_loss.py +0 -0
- {modules β so_vits_svc_fork/modules}/descriminators.py +0 -0
- {modules β so_vits_svc_fork/modules}/encoders.py +0 -0
- {modules β so_vits_svc_fork/modules}/flows.py +0 -0
- {modules β so_vits_svc_fork/modules}/losses.py +0 -0
- {modules β so_vits_svc_fork/modules}/mel_processing.py +0 -0
- {modules β so_vits_svc_fork/modules}/modules.py +0 -0
- {modules β so_vits_svc_fork/modules}/synthesizers.py +0 -0
- {preprocessing β so_vits_svc_fork/preprocessing}/__init__.py +0 -0
- {preprocessing β so_vits_svc_fork/preprocessing}/config_templates/quickvc.json +0 -0
- {preprocessing β so_vits_svc_fork/preprocessing}/config_templates/so-vits-svc-4.0v1-legacy.json +0 -0
- {preprocessing β so_vits_svc_fork/preprocessing}/config_templates/so-vits-svc-4.0v1.json +0 -0
- {preprocessing β so_vits_svc_fork/preprocessing}/preprocess_classify.py +0 -0
- {preprocessing β so_vits_svc_fork/preprocessing}/preprocess_flist_config.py +0 -0
- {preprocessing β so_vits_svc_fork/preprocessing}/preprocess_hubert_f0.py +0 -0
- {preprocessing β so_vits_svc_fork/preprocessing}/preprocess_resample.py +0 -0
- {preprocessing β so_vits_svc_fork/preprocessing}/preprocess_speaker_diarization.py +0 -0
- {preprocessing β so_vits_svc_fork/preprocessing}/preprocess_split.py +0 -0
- {preprocessing β so_vits_svc_fork/preprocessing}/preprocess_utils.py +0 -0
- py.typed β so_vits_svc_fork/py.typed +0 -0
- train.py β so_vits_svc_fork/train.py +0 -0
- utils.py β so_vits_svc_fork/utils.py +0 -0
appnew.py
DELETED
@@ -1,334 +0,0 @@
|
|
1 |
-
from ipywidgets import widgets
|
2 |
-
import copy
|
3 |
-
import json
|
4 |
-
import glob
|
5 |
-
import os
|
6 |
-
import time
|
7 |
-
import threading
|
8 |
-
from IPython.display import Audio, display, HTML, FileLink
|
9 |
-
from pathlib import Path
|
10 |
-
import subprocess
|
11 |
-
import shutil
|
12 |
-
from google.colab import files
|
13 |
-
from ipywidgets import TwoByTwoLayout
|
14 |
-
import re
|
15 |
-
|
16 |
-
SEGMENT_LENGTH = 60
|
17 |
-
|
18 |
-
CUSTOM_MODELS_FILENAME = "customModels"
|
19 |
-
CUSTOM_MODELS_DIR = f"/drive/MyDrive/{CUSTOM_MODELS_FILENAME}"
|
20 |
-
|
21 |
-
MUSIC_EXTENSIONS = ['.mp3', '.wav', '.flac', '.aac', '.ogg']
|
22 |
-
|
23 |
-
SEGMENTS_DIRNAME = f"/content/segments"
|
24 |
-
INFERENCE_OUTPUT_DIRNAME = "/content/inference_output"
|
25 |
-
|
26 |
-
def progress(value, max=100):
|
27 |
-
return HTML("""
|
28 |
-
<progress
|
29 |
-
value='{value}'
|
30 |
-
max='{max}',
|
31 |
-
style='width: 100%'
|
32 |
-
>
|
33 |
-
{value}
|
34 |
-
</progress>
|
35 |
-
""".format(value=value, max=max))
|
36 |
-
|
37 |
-
def is_valid_filename(filename):
|
38 |
-
if re.search(r'[<>:"/\\|?*\x00-\x1f]', filename):
|
39 |
-
return False
|
40 |
-
if re.search(r'[-\s()]', filename):
|
41 |
-
return False
|
42 |
-
return True
|
43 |
-
|
44 |
-
def clean_filename(filename):
|
45 |
-
basename = os.path.basename(filename)
|
46 |
-
cleaned_basename = re.sub(r'[%<>:"/\\|?*\x00-\x1f]', '', basename)
|
47 |
-
cleaned_basename = re.sub(r'[-\s]+', '_', cleaned_basename)
|
48 |
-
cleaned_basename = re.sub(r'[\(\)]+', '', cleaned_basename)
|
49 |
-
cleaned_basename = cleaned_basename.replace("'", "").replace('"', '').replace("$", "")
|
50 |
-
cleaned_basename_arr = cleaned_basename.split()
|
51 |
-
for i in range(len(cleaned_basename_arr)):
|
52 |
-
if i != len(cleaned_basename_arr)-1:
|
53 |
-
cleaned_basename_arr[i] = cleaned_basename_arr[i].replace(".", "")
|
54 |
-
cleaned_basename = " ".join(cleaned_basename_arr)
|
55 |
-
return os.path.join(os.path.dirname(filename), cleaned_basename)
|
56 |
-
|
57 |
-
def get_audio_files():
|
58 |
-
audio_files = []
|
59 |
-
for root, dirs, files in os.walk("/content"):
|
60 |
-
for filename in files:
|
61 |
-
file_extension = os.path.splitext(filename)[1]
|
62 |
-
if file_extension.lower() in MUSIC_EXTENSIONS and "output" not in filename:
|
63 |
-
audio_files.append(filename)
|
64 |
-
|
65 |
-
return audio_files
|
66 |
-
|
67 |
-
def get_speakers():
|
68 |
-
speakers = []
|
69 |
-
|
70 |
-
for _,dirs,_ in os.walk(CUSTOM_MODELS_DIR):
|
71 |
-
for folder in dirs:
|
72 |
-
cur_speaker = {}
|
73 |
-
# Look for G_****.pth
|
74 |
-
g = glob.glob(os.path.join(CUSTOM_MODELS_DIR,folder,'G_*.pth'))
|
75 |
-
if not len(g):
|
76 |
-
continue
|
77 |
-
cur_speaker["model_path"] = g[0]
|
78 |
-
cur_speaker["model_folder"] = folder
|
79 |
-
|
80 |
-
# Look for *.pt (clustering model)
|
81 |
-
clst = glob.glob(os.path.join(CUSTOM_MODELS_DIR,folder,'*.pt'))
|
82 |
-
if not len(clst):
|
83 |
-
cur_speaker["cluster_path"] = ""
|
84 |
-
else:
|
85 |
-
cur_speaker["cluster_path"] = clst[0]
|
86 |
-
|
87 |
-
# Look for config.json
|
88 |
-
cfg = glob.glob(os.path.join(CUSTOM_MODELS_DIR,folder,'*.json'))
|
89 |
-
if not len(cfg):
|
90 |
-
continue
|
91 |
-
cur_speaker["cfg_path"] = cfg[0]
|
92 |
-
with open(cur_speaker["cfg_path"]) as f:
|
93 |
-
try:
|
94 |
-
cfg_json = json.loads(f.read())
|
95 |
-
except Exception as e:
|
96 |
-
print("Malformed config json in "+folder)
|
97 |
-
for name, i in cfg_json["spk"].items():
|
98 |
-
cur_speaker["name"] = name
|
99 |
-
cur_speaker["id"] = i
|
100 |
-
if not name.startswith('.'):
|
101 |
-
speakers.append(copy.copy(cur_speaker))
|
102 |
-
|
103 |
-
return sorted(speakers, key=lambda x:x["name"].lower())
|
104 |
-
|
105 |
-
def slice_audio(filepath):
|
106 |
-
assert os.path.exists(filepath), f"ΠΠ΅ ΡΠ΄Π°Π»ΠΎΡΡ Π½Π°ΠΉΡΠΈ {filepath}. Π£Π±Π΅Π΄ΠΈΡΠ΅ΡΡ, ΡΡΠΎ Π²Ρ Π²Π²Π΅Π»ΠΈ ΠΏΡΠ°Π²ΠΈΠ»ΡΠ½ΠΎΠ΅ ΠΈΠΌΡ ΡΠ°ΠΉΠ»Π°."
|
107 |
-
# Get the filename and extension of the input file
|
108 |
-
filename, extension = os.path.splitext(filepath)
|
109 |
-
filename = filename.split("/")[-1]
|
110 |
-
|
111 |
-
os.makedirs(SEGMENTS_DIRNAME, exist_ok=True)
|
112 |
-
|
113 |
-
# Set the output filename pattern
|
114 |
-
output_pattern = f"{SEGMENTS_DIRNAME}/{filename}_%d{extension}"
|
115 |
-
|
116 |
-
# Use ffmpeg to split the audio into segments
|
117 |
-
os.system(f"ffmpeg -i {filepath} -f segment -segment_time {SEGMENT_LENGTH} -c copy {output_pattern}")
|
118 |
-
|
119 |
-
|
120 |
-
def get_container_format(filename):
|
121 |
-
command = ["ffprobe", "-v", "error", "-select_streams", "v:0", "-show_entries", "format=format_name", "-of", "default=noprint_wrappers=1:nokey=1", filename]
|
122 |
-
process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
123 |
-
output, error = process.communicate()
|
124 |
-
if error:
|
125 |
-
raise ValueError(f"ΠΡΠΈΠ±ΠΊΠ° ΠΏΡΠΈ ΠΏΠΎΠ»ΡΡΠ΅Π½ΠΈΠΈ ΡΠΎΡΠΌΠ°ΡΠ° ΠΊΠΎΠ½ΡΠ΅ΠΉΠ½Π΅ΡΠ°: {error.decode()}")
|
126 |
-
return output.decode().strip()
|
127 |
-
|
128 |
-
def run_inference(speaker, f0_method, transpose, noise_scale, cluster_ratio, is_pitch_prediction_enabled):
|
129 |
-
loading_bar = display(progress(0, 100), display_id=True)
|
130 |
-
model_path = speaker["model_path"]
|
131 |
-
config_path = speaker["cfg_path"]
|
132 |
-
cluster_path = speaker["cluster_path"]
|
133 |
-
|
134 |
-
all_segs_paths = sorted(Path(SEGMENTS_DIRNAME).glob("*"))
|
135 |
-
|
136 |
-
for index, seg_path in enumerate(all_segs_paths):
|
137 |
-
max_load_value = float((index + 1)/len(all_segs_paths)) * 100
|
138 |
-
loading_bar.update(progress(max_load_value / 2, 100))
|
139 |
-
inference_cmd = f"svc infer {seg_path.absolute()} -m {model_path} -c {config_path} {f'-k {cluster_path} -r {cluster_ratio}' if cluster_path != '' and cluster_ratio > 0 else ''} -t {transpose} --f0-method {f0_method} -n {noise_scale} -o {INFERENCE_OUTPUT_DIRNAME}/{seg_path.name} {'' if is_pitch_prediction_enabled else '--no-auto-predict-f0'}"
|
140 |
-
# print(f"\nPerforming inference on... {seg_path.absolute()}\ninference cmd: {inference_cmd}")
|
141 |
-
result = subprocess.run(
|
142 |
-
inference_cmd.split(),
|
143 |
-
stdout=subprocess.PIPE,
|
144 |
-
stderr=subprocess.STDOUT,
|
145 |
-
text=True
|
146 |
-
)
|
147 |
-
loading_bar.update(progress(max_load_value, 100))
|
148 |
-
|
149 |
-
if result.stderr:
|
150 |
-
if "AttributeError" in result.stderr:
|
151 |
-
raise Exception(result.stderr + "Π£Π±Π΅Π΄ΠΈΡΠ΅ΡΡ, ΡΡΠΎ Π²Π°ΡΠ° ΠΌΠΎΠ΄Π΅Π»Ρ Π½Π΅ 4.0-v2. ΠΡΠΎΡ Π±Π»ΠΎΠΊΠ½ΠΎΡ ΡΠ°Π±ΠΎΡΠ°Π΅Ρ ΡΠΎΠ»ΡΠΊΠΎ Π½Π° ΠΌΠΎΠ΄Π΅Π»ΡΡ
4.0-v1.")
|
152 |
-
|
153 |
-
files_length = len(sorted(Path(SEGMENTS_DIRNAME).glob("*")))
|
154 |
-
if files_length == 0:
|
155 |
-
raise Exception("ΠΡΠΎΠΈΠ·ΠΎΡΠ»Π° Π½Π΅ΠΈΠ·Π²Π΅ΡΡΠ½Π°Ρ ΠΎΡΠΈΠ±ΠΊΠ°!")
|
156 |
-
|
157 |
-
|
158 |
-
def concatenate_segments(final_filename):
|
159 |
-
foldername = Path(INFERENCE_OUTPUT_DIRNAME)
|
160 |
-
assert foldername.exists(), "ΠΏΠ°ΠΏΠΊΠ° Π½Π΅ ΡΡΡΠ΅ΡΡΠ²ΡΠ΅Ρ. ΠΠ²Π΅Π΄ΠΈΡΠ΅ ΠΏΡΠ°Π²ΠΈΠ»ΡΠ½ΠΎΠ΅ ΠΈΠΌΡ ΠΏΠ°ΠΏΠΊΠΈ"
|
161 |
-
all_segs = [f for f in sorted(foldername.glob("**/*")) if f.is_file()]
|
162 |
-
print(all_segs)
|
163 |
-
try:
|
164 |
-
ext = all_segs[0].suffix
|
165 |
-
with open(foldername/"concat_list.txt", "w") as f:
|
166 |
-
for seg in all_segs:
|
167 |
-
f.write('file ' + str(seg.absolute()) + "\n")
|
168 |
-
os.system(f"ffmpeg -f concat -safe 0 -i {foldername}/concat_list.txt -codec copy {foldername}/{final_filename}")
|
169 |
-
except:
|
170 |
-
raise Exception(f'Π ΠΊΠ°ΡΠ°Π»ΠΎΠ³Π΅ {foldername} Π½Π΅ Π½Π°ΠΉΠ΄Π΅Π½ΠΎ Π½ΠΈ ΠΎΠ΄Π½ΠΎΠ³ΠΎ ΡΠ°ΠΉΠ»Π°')
|
171 |
-
|
172 |
-
def cleanup_dirs():
|
173 |
-
!rm -R {INFERENCE_OUTPUT_DIRNAME} &> /dev/null
|
174 |
-
!rm -R {SEGMENTS_DIRNAME} &> /dev/null
|
175 |
-
!rm -R ./so_vits_svc_fork.log &> /dev/null
|
176 |
-
|
177 |
-
class InferenceGui():
|
178 |
-
def __init__(self):
|
179 |
-
# Initialize the background watcher thread as None
|
180 |
-
speakers = get_speakers()
|
181 |
-
self.is_inferencing = False
|
182 |
-
self.final_filename = ""
|
183 |
-
self.speakers = speakers if speakers is not None else []
|
184 |
-
self.speaker_list = [x["name"] for x in self.speakers]
|
185 |
-
self.speaker_dropdown = widgets.Dropdown(
|
186 |
-
options = self.speaker_list,
|
187 |
-
description="AI ΠΌΠΎΠ΄Π΅Π»Ρ"
|
188 |
-
)
|
189 |
-
|
190 |
-
self.audio_files = get_audio_files()
|
191 |
-
self.audio_files_dropdown = widgets.Dropdown(
|
192 |
-
options = self.audio_files,
|
193 |
-
description="ΠΡΠ΄ΠΈΠΎΡΠ°ΠΉΠ»"
|
194 |
-
)
|
195 |
-
|
196 |
-
self.cluster_ratio_tx = widgets.FloatSlider(
|
197 |
-
value=1,
|
198 |
-
min=0,
|
199 |
-
max=1.0,
|
200 |
-
step=0.05,
|
201 |
-
description='Π‘ΠΎΠΎΡΠ½ΠΎΡΠ΅Π½ΠΈΠ΅ ΠΊΠ»Π°ΡΡΠ΅ΡΠΎΠ²',
|
202 |
-
disabled=False,
|
203 |
-
continuous_update=False,
|
204 |
-
orientation='horizontal',
|
205 |
-
readout=True,
|
206 |
-
)
|
207 |
-
|
208 |
-
self.noise_scale_tx = widgets.FloatSlider(
|
209 |
-
value=2,
|
210 |
-
min=-2,
|
211 |
-
max=2,
|
212 |
-
step=.4,
|
213 |
-
description='Π¨ΠΊΠ°Π»Π° ΡΡΠΌΠ°',
|
214 |
-
disabled=False,
|
215 |
-
continuous_update=False,
|
216 |
-
orientation='horizontal',
|
217 |
-
readout=True,
|
218 |
-
)
|
219 |
-
|
220 |
-
def convert_cb(btn):
|
221 |
-
if (self.is_inferencing):
|
222 |
-
return
|
223 |
-
self.convert()
|
224 |
-
self.convert_btn = widgets.Button(description="ΠΠΎΠ½Π²Π΅ΡΡΠΈΡΠΎΠ²Π°ΡΡ")
|
225 |
-
self.convert_btn.on_click(convert_cb)
|
226 |
-
|
227 |
-
def refresh_files(btn):
|
228 |
-
self.update_file_list_dropdown()
|
229 |
-
self.refresh_files_btn = widgets.Button(description="ΠΠ±Π½ΠΎΠ²ΠΈΡΡ Π°ΡΠ΄ΠΈΠΎΡΠ°ΠΉΠ»Ρ")
|
230 |
-
self.refresh_files_btn.on_click(refresh_files)
|
231 |
-
|
232 |
-
cluster_container = widgets.HBox([self.cluster_ratio_tx, widgets.Label(value="ΠΡΡΠ΅Π³ΡΠ»ΠΈΡΡΠΉΡΠ΅ ΡΠΎΠΎΡΠ½ΠΎΡΠ΅Π½ΠΈΠ΅ ΠΌΠ΅ΠΆΠ΄Ρ Π·Π²ΡΡΠ°Π½ΠΈΠ΅ΠΌ, ΠΏΠΎΡ
ΠΎΠΆΠΈΠΌ Π½Π° ΡΠ΅ΠΌΠ±Ρ ΡΠ΅Π»ΠΈ, ΠΈ ΡΠ΅ΡΠΊΠΎΡΡΡΡ ΠΈ Π°ΡΡΠΈΠΊΡΠ»ΠΈΡΠΎΠ²Π°Π½Π½ΠΎΡΡΡΡ, ΡΡΠΎΠ±Ρ Π½Π°ΠΉΡΠΈ ΠΏΠΎΠ΄Ρ
ΠΎΠ΄ΡΡΠΈΠΉ ΠΊΠΎΠΌΠΏΡΠΎΠΌΠΈΡΡ.")])
|
233 |
-
noise_scale_container = widgets.HBox([self.noise_scale_tx, widgets.Label(value="ΠΡΠ»ΠΈ Π²ΡΡ
ΠΎΠ΄Π½ΠΎΠΉ ΡΠΈΠ³Π½Π°Π» Π·Π²ΡΡΠΈΡ Π³ΡΠ»ΠΊΠΎ/ΠΌΠ΅ΡΠ°Π»Π»ΠΈΡΠ΅ΡΠΊΠΈ, ΠΏΠΎΠΏΡΠΎΠ±ΡΠΉΡΠ΅ ΡΠ²Π΅Π»ΠΈΡΠΈΡΡ ΠΌΠ°ΡΡΡΠ°Π± ΡΡΠΌΠ°. ΠΡΠ»ΠΈ ΠΏΠΎΡΠ²Π»ΡΡΡΡΡ Π°ΡΡΠ΅ΡΠ°ΠΊΡΡ, ΠΏΠΎΡ
ΠΎΠΆΠΈΠ΅ Π½Π° ΠΏΠ»ΠΎΡ
ΠΎΠ΅ ΡΡΠΌΠΎΠΏΠΎΠ΄Π°Π²Π»Π΅Π½ΠΈΠ΅ ΠΈΠ»ΠΈ ΠΏΠΎΠ³ΡΡΠΆΠ΅Π½ΠΈΠ΅ Π΄ΠΈΠ½Π°ΠΌΠΈΠΊΠ° Π² Π²ΠΎΠ΄Ρ, ΡΠΌΠ΅Π½ΡΡΠΈΡΠ΅ ΠΌΠ°ΡΡΡΠ°Π± ΡΡΠΌΠ°.")])
|
234 |
-
|
235 |
-
audio_files_container = widgets.HBox([
|
236 |
-
self.audio_files_dropdown,
|
237 |
-
self.refresh_files_btn
|
238 |
-
])
|
239 |
-
|
240 |
-
voice_cloning_tab = widgets.VBox([self.speaker_dropdown, audio_files_container, cluster_container, noise_scale_container])
|
241 |
-
|
242 |
-
buttons_container = widgets.HBox([self.convert_btn])
|
243 |
-
|
244 |
-
if (len(self.audio_files) == 0):
|
245 |
-
audio_file_error_widget = widgets.HBox([
|
246 |
-
widgets.Label(value='ΠΠΎΠΆΠ°Π»ΡΠΉΡΡΠ°, Π·Π°Π³ΡΡΠ·ΠΈΡΠ΅ Π°ΡΠ΄ΠΈΠΎΡΠ°ΠΉΠ» ΠΈ Π½Π°ΠΆΠΌΠΈΡΠ΅ ΠΊΠ½ΠΎΠΏΠΊΡ Π²ΠΎΡΠΏΡΠΎΠΈΠ·Π²Π΅Π΄Π΅Π½ΠΈΡ, ΡΡΠΎΠ±Ρ ΠΏΠΎΠ²ΡΠΎΡΠ½ΠΎ Π·Π°ΠΏΡΡΡΠΈΡΡ ΡΡΡ ΡΡΠ΅ΠΉΠΊΡ.')
|
247 |
-
])
|
248 |
-
display(audio_file_error_widget)
|
249 |
-
return
|
250 |
-
|
251 |
-
display(voice_cloning_tab)
|
252 |
-
display(buttons_container)
|
253 |
-
|
254 |
-
def update_file_list_dropdown(self):
|
255 |
-
self.audio_files = get_audio_files()
|
256 |
-
self.audio_files_dropdown.options = self.audio_files
|
257 |
-
|
258 |
-
def clean(self):
|
259 |
-
input_filepaths = [f for f in glob.glob('/content/**/*.*', recursive=True)
|
260 |
-
if any(f.endswith(ex) for ex in ['.wav','.flac','.mp3','.ogg','.opus'])]
|
261 |
-
for f in input_filepaths:
|
262 |
-
os.remove(f)
|
263 |
-
subprocess.run(['sudo', 'updatedb'])
|
264 |
-
self.update_file_list_dropdown()
|
265 |
-
|
266 |
-
|
267 |
-
def convert(self):
|
268 |
-
ts0 = time.time()
|
269 |
-
|
270 |
-
# Prevent a conversion process from one starting if one is already running
|
271 |
-
self.is_inferencing = True
|
272 |
-
|
273 |
-
speaker = next(x for x in self.speakers if x["name"] ==
|
274 |
-
self.speaker_dropdown.value)
|
275 |
-
model_path = os.path.join(os.getcwd(),speaker["model_path"])
|
276 |
-
config_path = os.path.join(os.getcwd(),speaker["cfg_path"])
|
277 |
-
cluster_path = os.path.join(os.getcwd(),speaker["cluster_path"])
|
278 |
-
file_path = os.path.join(os.getcwd(), str(self.audio_files_dropdown.value))
|
279 |
-
f0_method = "dio"
|
280 |
-
transpose = 0
|
281 |
-
noise_scale = int(self.noise_scale_tx.value)
|
282 |
-
cluster_ratio = float(self.cluster_ratio_tx.value)
|
283 |
-
is_pitch_prediction_enabled = True
|
284 |
-
|
285 |
-
if not speaker:
|
286 |
-
print("ΠΠΎΠΆΠ°Π»ΡΠΉΡΡΠ°, Π²ΡΠ±Π΅ΡΠΈΡΠ΅ ΠΌΠΎΠ΄Π΅Π»Ρ ΠΈΡΠΊΡΡΡΡΠ²Π΅Π½Π½ΠΎΠ³ΠΎ ΠΈΠ½ΡΠ΅Π»Π»Π΅ΠΊΡΠ°.")
|
287 |
-
return
|
288 |
-
if not self.audio_files_dropdown.value or self.audio_files_dropdown.value == "":
|
289 |
-
print("ΠΠΎΠΆΠ°Π»ΡΠΉΡΡΠ°, Π²ΡΠ±Π΅ΡΠΈΡΠ΅ Π°ΡΠ΄ΠΈΠΎΡΠ°ΠΉΠ» Π΄Π»Ρ ΠΊΠ»ΠΎΠ½ΠΈΡΠΎΠ²Π°Π½ΠΈΡ.")
|
290 |
-
return
|
291 |
-
|
292 |
-
if not is_valid_filename(file_path):
|
293 |
-
try:
|
294 |
-
new_filename = clean_filename(file_path)
|
295 |
-
os.rename(file_path, new_filename)
|
296 |
-
file_path = new_filename
|
297 |
-
except:
|
298 |
-
print("ΠΠΎΠΆΠ°Π»ΡΠΉΡΡΠ°, ΠΏΠΎΠ²ΡΠΎΡΠ½ΠΎ Π·Π°ΠΏΡΡΡΠΈΡΠ΅ ΡΡΡ ΡΡΠ΅ΠΉΠΊΡ, Π½Π°ΠΆΠ°Π² ΠΊΠ½ΠΎΠΏΠΊΡ Π²ΠΎΡΠΏΡΠΎΠΈΠ·Π²Π΅Π΄Π΅Π½ΠΈΡ. ΠΡΠΎΠΈΠ·ΠΎΡΠ»Π° Π½Π΅ΠΈΠ·Π²Π΅ΡΡΠ½Π°Ρ ΠΎΡΠΈΠ±ΠΊΠ°.")
|
299 |
-
|
300 |
-
if os.path.exists(SEGMENTS_DIRNAME) or os.path.exists(INFERENCE_OUTPUT_DIRNAME):
|
301 |
-
print(f"ΠΠ±Π½Π°ΡΡΠΆΠ΅Π½Ρ ΠΏΡΠ΅Π΄ΡΠ΄ΡΡΠΈΠ΅ ΠΏΠ°ΠΏΠΊΠΈ {SEGMENTS_DIRNAME} ΠΈ {INFERENCE_OUTPUT_DIRNAME}.")
|
302 |
-
cleanup_dirs()
|
303 |
-
|
304 |
-
# SLICE AUDIO
|
305 |
-
slice_audio(file_path)
|
306 |
-
|
307 |
-
# PERFORM INFERENCE
|
308 |
-
os.makedirs("inference_output", exist_ok=True)
|
309 |
-
run_inference(speaker, f0_method, transpose, noise_scale, cluster_ratio, is_pitch_prediction_enabled)
|
310 |
-
|
311 |
-
cleaned_speaker_name = speaker['name'].replace(" ", "_")
|
312 |
-
final_filename = f"{Path(file_path).stem}_{cleaned_speaker_name}_output{Path(file_path).suffix}"
|
313 |
-
self.final_filename = final_filename
|
314 |
-
|
315 |
-
# CONCATENATE FILES IN INFERENCE OUTPUT DIR
|
316 |
-
concatenate_segments(final_filename)
|
317 |
-
|
318 |
-
# MOVE FINAL CONCATENATED FILE TO TOP-LEVEL IN CURRENT DIR
|
319 |
-
shutil.move(Path(INFERENCE_OUTPUT_DIRNAME, final_filename), Path(final_filename))
|
320 |
-
|
321 |
-
# CLEAN UP
|
322 |
-
cleanup_dirs()
|
323 |
-
|
324 |
-
ts1 = time.time()
|
325 |
-
print(f"Total Time Elapsed: {ts1 - ts0} seconds")
|
326 |
-
print(f"\nΠΠΎΡΠΎΠ²ΠΎ! ΠΠΎΠΆΠ΅ΡΠ΅ ΡΠΊΠ°ΡΠ°ΡΡ Π²ΡΡ
ΠΎΠ΄Π½ΠΎΠΉ ΡΠ°ΠΉΠ» ΡΠ΅ΡΠ΅Π· ΠΏΡΠΎΠ²ΠΎΠ΄Π½ΠΈΠΊ ΠΊΠ°ΠΊ '{final_filename}' ΠΈΠ»ΠΈ ΡΠ΅ΡΠ΅Π· Π°ΡΠ΄ΠΈΠΎ-ΠΏΠ»Π΅Π΅Ρ Π½ΠΈΠΆΠ΅.")
|
327 |
-
|
328 |
-
audio = Audio(final_filename, autoplay=False)
|
329 |
-
display(audio)
|
330 |
-
self.is_inferencing = False
|
331 |
-
self.update_file_list_dropdown()
|
332 |
-
|
333 |
-
|
334 |
-
gui = InferenceGui()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
__init__.py β so_vits_svc_fork/__init__.py
RENAMED
File without changes
|
__main__.py β so_vits_svc_fork/__main__.py
RENAMED
File without changes
|
{cluster β so_vits_svc_fork/cluster}/__init__.py
RENAMED
File without changes
|
{cluster β so_vits_svc_fork/cluster}/train_cluster.py
RENAMED
File without changes
|
dataset.py β so_vits_svc_fork/dataset.py
RENAMED
File without changes
|
default_gui_presets.json β so_vits_svc_fork/default_gui_presets.json
RENAMED
File without changes
|
f0.py β so_vits_svc_fork/f0.py
RENAMED
File without changes
|
gui.py β so_vits_svc_fork/gui.py
RENAMED
File without changes
|
hparams.py β so_vits_svc_fork/hparams.py
RENAMED
File without changes
|
{inference β so_vits_svc_fork/inference}/__init__.py
RENAMED
File without changes
|
{inference β so_vits_svc_fork/inference}/core.py
RENAMED
File without changes
|
{inference β so_vits_svc_fork/inference}/main.py
RENAMED
File without changes
|
logger.py β so_vits_svc_fork/logger.py
RENAMED
File without changes
|
{modules β so_vits_svc_fork/modules}/__init__.py
RENAMED
File without changes
|
{modules β so_vits_svc_fork/modules}/attentions.py
RENAMED
File without changes
|
{modules β so_vits_svc_fork/modules}/commons.py
RENAMED
File without changes
|
{modules β so_vits_svc_fork/modules}/decoders/__init__.py
RENAMED
File without changes
|
{modules β so_vits_svc_fork/modules}/decoders/f0.py
RENAMED
File without changes
|
{modules β so_vits_svc_fork/modules}/decoders/hifigan/__init__.py
RENAMED
File without changes
|
{modules β so_vits_svc_fork/modules}/decoders/hifigan/_models.py
RENAMED
File without changes
|
{modules β so_vits_svc_fork/modules}/decoders/hifigan/_utils.py
RENAMED
File without changes
|
{modules β so_vits_svc_fork/modules}/decoders/mb_istft/__init__.py
RENAMED
File without changes
|
{modules β so_vits_svc_fork/modules}/decoders/mb_istft/_generators.py
RENAMED
File without changes
|
{modules β so_vits_svc_fork/modules}/decoders/mb_istft/_loss.py
RENAMED
File without changes
|
{modules β so_vits_svc_fork/modules}/decoders/mb_istft/_pqmf.py
RENAMED
File without changes
|
{modules β so_vits_svc_fork/modules}/decoders/mb_istft/_stft.py
RENAMED
File without changes
|
{modules β so_vits_svc_fork/modules}/decoders/mb_istft/_stft_loss.py
RENAMED
File without changes
|
{modules β so_vits_svc_fork/modules}/descriminators.py
RENAMED
File without changes
|
{modules β so_vits_svc_fork/modules}/encoders.py
RENAMED
File without changes
|
{modules β so_vits_svc_fork/modules}/flows.py
RENAMED
File without changes
|
{modules β so_vits_svc_fork/modules}/losses.py
RENAMED
File without changes
|
{modules β so_vits_svc_fork/modules}/mel_processing.py
RENAMED
File without changes
|
{modules β so_vits_svc_fork/modules}/modules.py
RENAMED
File without changes
|
{modules β so_vits_svc_fork/modules}/synthesizers.py
RENAMED
File without changes
|
{preprocessing β so_vits_svc_fork/preprocessing}/__init__.py
RENAMED
File without changes
|
{preprocessing β so_vits_svc_fork/preprocessing}/config_templates/quickvc.json
RENAMED
File without changes
|
{preprocessing β so_vits_svc_fork/preprocessing}/config_templates/so-vits-svc-4.0v1-legacy.json
RENAMED
File without changes
|
{preprocessing β so_vits_svc_fork/preprocessing}/config_templates/so-vits-svc-4.0v1.json
RENAMED
File without changes
|
{preprocessing β so_vits_svc_fork/preprocessing}/preprocess_classify.py
RENAMED
File without changes
|
{preprocessing β so_vits_svc_fork/preprocessing}/preprocess_flist_config.py
RENAMED
File without changes
|
{preprocessing β so_vits_svc_fork/preprocessing}/preprocess_hubert_f0.py
RENAMED
File without changes
|
{preprocessing β so_vits_svc_fork/preprocessing}/preprocess_resample.py
RENAMED
File without changes
|
{preprocessing β so_vits_svc_fork/preprocessing}/preprocess_speaker_diarization.py
RENAMED
File without changes
|
{preprocessing β so_vits_svc_fork/preprocessing}/preprocess_split.py
RENAMED
File without changes
|
{preprocessing β so_vits_svc_fork/preprocessing}/preprocess_utils.py
RENAMED
File without changes
|
py.typed β so_vits_svc_fork/py.typed
RENAMED
File without changes
|
train.py β so_vits_svc_fork/train.py
RENAMED
File without changes
|
utils.py β so_vits_svc_fork/utils.py
RENAMED
File without changes
|