Skip to content

Commit 7fc22a0

Browse files
authored
Merge pull request #1227 from IAHispano/fixes
Fixes
2 parents c15aa4e + bdc00e0 commit 7fc22a0

8 files changed

Lines changed: 112 additions & 94 deletions

File tree

core.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,9 @@ def run_tts_script(
356356
],
357357
),
358358
]
359-
subprocess.run(command_tts, check=True)
359+
result = subprocess.run(command_tts, capture_output=True, text=True)
360+
if result.returncode != 0:
361+
raise RuntimeError(result.stderr.strip())
360362
infer_pipeline = import_voice_converter()
361363
infer_pipeline.convert_audio(
362364
pitch=pitch,
@@ -539,7 +541,11 @@ def run_train_script(
539541
],
540542
),
541543
]
542-
subprocess.run(command)
544+
result = subprocess.run(command)
545+
if result.returncode != 0:
546+
raise RuntimeError(
547+
f"Training failed for model {model_name}. Please check the console logs for more details."
548+
)
543549
run_index_script(model_name, index_algorithm)
544550
return f"Model {model_name} trained successfully."
545551

requirements.txt

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,25 @@ setuptools==81.0.0
33
pip>=23.3; sys_platform == 'darwin'
44
wheel; sys_platform == 'darwin'
55
PyYAML; sys_platform == 'darwin'
6-
numpy==2.3.5
7-
requests>=2.31.0,<2.32.0
6+
numpy==2.4.4
7+
requests
88
tqdm
99
wget
1010

1111
# Audio processing
1212
ffmpeg-python>=0.2.0
1313
faiss-cpu==1.13.2
1414
librosa==0.11.0
15-
scipy==1.16.3
16-
soundfile==0.12.1
15+
scipy==1.17.1
16+
soundfile==0.13.1
1717
noisereduce
1818
pedalboard
1919
stftpitchshift
2020
soxr
2121

2222
# Machine learning and deep learning
2323
omegaconf>=2.0.6; sys_platform == 'darwin'
24-
numba==0.63.1
24+
numba==0.65.0
2525
torch==2.7.1; sys_platform == 'darwin'
2626
torch==2.7.1+cu128; sys_platform == 'linux' or sys_platform == 'win32'
2727
torchaudio==2.7.1; sys_platform == 'darwin'
@@ -31,19 +31,20 @@ torchvision==0.22.1+cu128; sys_platform == 'linux' or sys_platform == 'win32'
3131
torchcrepe
3232
torchfcpe
3333
einops
34-
transformers==4.44.2
34+
transformers==5.4.0
3535

3636
# Visualization and UI
3737
matplotlib==3.10.8
3838
tensorboard
39-
gradio==6.5.1
39+
gradio==6.10.0
4040

4141
# Miscellaneous utilities
42-
certifi>=2023.07.22; sys_platform == 'darwin'
43-
antlr4-python3-runtime==4.8; sys_platform == 'darwin'
42+
certifi>=2026.2.25; sys_platform == 'darwin'
43+
antlr4-python3-runtime==4.13.2; sys_platform == 'darwin'
4444
tensorboardX
45-
edge-tts==7.2.7
45+
edge-tts==7.2.8
4646
pypresence
4747
beautifulsoup4
4848
sounddevice
4949
webrtcvad-wheels
50+
psutil

rvc/lib/tools/tts.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import asyncio
22
import os
33
import sys
4+
45
import edge_tts
56

67

@@ -21,10 +22,7 @@ async def main():
2122
with open(tts_file, "r") as file:
2223
text = file.read()
2324

24-
try:
25-
await edge_tts.Communicate(text, voice, rate=rates).save(output_file)
26-
except Exception:
27-
sys.exit(1)
25+
await edge_tts.Communicate(text, voice, rate=rates).save(output_file)
2826

2927

3028
if __name__ == "__main__":

tabs/inference/inference.py

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,6 @@ def get_files(type="model"):
123123

124124

125125
default_weight = next(iter(get_files("model")), None)
126-
index_files = sorted(get_files("index"))
127126

128127
audio_paths = [
129128
os.path.join(root, name)
@@ -232,8 +231,6 @@ def change_choices(model):
232231

233232
models_list = sorted(get_files("model"))
234233
indexes_list = sorted(get_files("index"))
235-
if indexes_list:
236-
indexes_list = [("No Index", "")] + [(x, x) for x in indexes_list]
237234

238235
audio_paths = [
239236
os.path.join(root, name)
@@ -487,8 +484,6 @@ def filter_dropdowns(filter_text):
487484
all_indexes = sorted(get_files("index"))
488485
filtered_models = [m for m in all_models if ft in m.lower()]
489486
filtered_indexes = [i for i in all_indexes if ft in i.lower()]
490-
if filtered_indexes:
491-
filtered_indexes = [("No Index", "")] + [(x, x) for x in filtered_indexes]
492487
return (gr.update(choices=filtered_models), gr.update(choices=filtered_indexes))
493488

494489

@@ -525,11 +520,7 @@ def inference_tab():
525520
index_file = gr.Dropdown(
526521
label=i18n("Index File"),
527522
info=i18n("Select the index file to use for the conversion."),
528-
choices=(
529-
[("No Index", "")] + [(x, x) for x in index_files]
530-
if index_files
531-
else []
532-
),
523+
choices=sorted(get_files("index")),
533524
value=match_index(default_weight),
534525
interactive=True,
535526
allow_custom_value=True,

tabs/realtime/realtime.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1181,11 +1181,7 @@ def realtime_tab():
11811181
index_choices = sorted(get_files("index"))
11821182
index_file = gr.Dropdown(
11831183
label=i18n("Index File"),
1184-
choices=(
1185-
[("No Index", "")] + [(x, x) for x in index_choices]
1186-
if index_choices
1187-
else []
1188-
),
1184+
choices=index_choices,
11891185
value=get_safe_index_value(
11901186
saved_settings["index_file"],
11911187
index_choices,
@@ -2205,8 +2201,6 @@ def delay_visible(checkbox):
22052201
def refresh_all():
22062202
new_names = get_files("model")
22072203
new_indexes = sorted(get_files("index"))
2208-
if new_indexes:
2209-
new_indexes = [("No Index", "")] + [(x, x) for x in new_indexes]
22102204
return (
22112205
gr.update(choices=sorted(new_names, key=extract_model_and_epoch)),
22122206
gr.update(choices=new_indexes),
@@ -2224,8 +2218,6 @@ def refresh_all():
22242218
def refresh_all():
22252219
new_names = get_files("model")
22262220
new_indexes = sorted(get_files("index"))
2227-
if new_indexes:
2228-
new_indexes = [("No Index", "")] + [(x, x) for x in new_indexes]
22292221
input_choices, output_choices = get_audio_devices_formatted()
22302222
input_choices, output_choices = list(input_choices.keys()), list(
22312223
output_choices.keys()

tabs/settings/sections/restart.py

Lines changed: 47 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,50 @@
1-
import gradio as gr
1+
import json
22
import os
33
import sys
4-
import json
4+
5+
import gradio as gr
6+
import psutil
57

68
now_dir = os.getcwd()
79

810

911
def stop_train(model_name: str):
12+
if not model_name or model_name == "":
13+
return
14+
1015
pid_file_path = os.path.join(now_dir, "logs", model_name, "config.json")
16+
killed = 0
17+
1118
try:
1219
with open(pid_file_path, "r", encoding="utf-8") as pid_file:
1320
pid_data = json.load(pid_file)
1421
pids = pid_data.get("process_pids", [])
15-
with open(pid_file_path, "w") as pid_file:
22+
23+
with open(pid_file_path, "w", encoding="utf-8") as pid_file:
1624
pid_data.pop("process_pids", None)
1725
json.dump(pid_data, pid_file, indent=4)
26+
1827
for pid in pids:
19-
os.kill(pid, 9)
28+
try:
29+
parent = psutil.Process(pid)
30+
for child in parent.children(recursive=True):
31+
child.kill()
32+
parent.kill()
33+
killed += 1
34+
except psutil.NoSuchProcess:
35+
pass
36+
except Exception:
37+
try:
38+
os.kill(pid, 9)
39+
killed += 1
40+
except:
41+
pass
42+
43+
# if killed > 0:
44+
# gr.Info(f"Training stopped successfully ({killed} process(es) terminated)")
45+
# else:
46+
# gr.Info("No active training processes found")
47+
2048
except:
2149
pass
2250

@@ -25,9 +53,22 @@ def stop_infer():
2553
pid_file_path = os.path.join(now_dir, "assets", "infer_pid.txt")
2654
try:
2755
with open(pid_file_path, "r") as pid_file:
28-
pids = [int(pid) for pid in pid_file.readlines()]
56+
pids = [int(pid) for pid in pid_file.readlines() if pid.strip()]
57+
2958
for pid in pids:
30-
os.kill(pid, 9)
59+
try:
60+
parent = psutil.Process(pid)
61+
for child in parent.children(recursive=True):
62+
child.kill()
63+
parent.kill()
64+
except psutil.NoSuchProcess:
65+
pass
66+
except Exception:
67+
try:
68+
os.kill(pid, 9)
69+
except:
70+
pass
71+
3172
os.remove(pid_file_path)
3273
except:
3374
pass

tabs/train/train.py

Lines changed: 41 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -768,7 +768,10 @@ def enforce_terms(terms_accepted, *args):
768768
message = "You must agree to the Terms of Use to proceed."
769769
gr.Info(message)
770770
return message
771-
return run_train_script(*args)
771+
try:
772+
return run_train_script(*args)
773+
except Exception as e:
774+
return e
772775

773776
terms_checkbox = gr.Checkbox(
774777
label=i18n("I agree to the terms of use"),
@@ -788,32 +791,6 @@ def enforce_terms(terms_accepted, *args):
788791

789792
with gr.Row():
790793
train_button = gr.Button(i18n("Start Training"))
791-
train_button.click(
792-
fn=enforce_terms,
793-
inputs=[
794-
terms_checkbox,
795-
model_name,
796-
save_every_epoch,
797-
save_only_latest,
798-
save_every_weights,
799-
total_epoch,
800-
sampling_rate,
801-
batch_size,
802-
gpu,
803-
overtraining_detector,
804-
overtraining_threshold,
805-
pretrained,
806-
cleanup,
807-
index_algorithm,
808-
cache_dataset_in_gpu,
809-
custom_pretrained,
810-
g_pretrained_path,
811-
d_pretrained_path,
812-
vocoder,
813-
checkpointing,
814-
],
815-
outputs=[train_output_info],
816-
)
817794

818795
stop_train_button = gr.Button(i18n("Stop Training"), visible=False)
819796
stop_train_button.click(
@@ -880,31 +857,21 @@ def enforce_terms(terms_accepted, *args):
880857
)
881858

882859
def toggle_visible(checkbox):
883-
return {"visible": checkbox, "__type__": "update"}
860+
return gr.update(visible=checkbox)
884861

885862
def toggle_pretrained(pretrained, custom_pretrained):
886-
if custom_pretrained == False:
887-
return {"visible": pretrained, "__type__": "update"}, {
888-
"visible": False,
889-
"__type__": "update",
890-
}
863+
if not custom_pretrained:
864+
return gr.update(visible=pretrained), gr.update(visible=False)
891865
else:
892-
return {"visible": pretrained, "__type__": "update"}, {
893-
"visible": pretrained,
894-
"__type__": "update",
895-
}
866+
return gr.update(visible=pretrained), gr.update(visible=pretrained)
896867

897-
def enable_stop_train_button():
898-
return {"visible": False, "__type__": "update"}, {
899-
"visible": True,
900-
"__type__": "update",
901-
}
868+
def enable_stop_train_button(terms_accepted):
869+
if not terms_accepted:
870+
return gr.update(visible=True), gr.update(visible=False)
871+
return gr.update(visible=False), gr.update(visible=True)
902872

903873
def disable_stop_train_button():
904-
return {"visible": True, "__type__": "update"}, {
905-
"visible": False,
906-
"__type__": "update",
907-
}
874+
return gr.update(visible=True), gr.update(visible=False)
908875

909876
def download_prerequisites():
910877
gr.Info(
@@ -1030,11 +997,38 @@ def update_slider_visibility(noise_reduction):
1030997
inputs=[overtraining_detector],
1031998
outputs=[overtraining_settings],
1032999
)
1000+
10331001
train_button.click(
10341002
fn=enable_stop_train_button,
1035-
inputs=[],
1003+
inputs=[terms_checkbox],
10361004
outputs=[train_button, stop_train_button],
1005+
).then(
1006+
fn=enforce_terms,
1007+
inputs=[
1008+
terms_checkbox,
1009+
model_name,
1010+
save_every_epoch,
1011+
save_only_latest,
1012+
save_every_weights,
1013+
total_epoch,
1014+
sampling_rate,
1015+
batch_size,
1016+
gpu,
1017+
overtraining_detector,
1018+
overtraining_threshold,
1019+
pretrained,
1020+
cleanup,
1021+
index_algorithm,
1022+
cache_dataset_in_gpu,
1023+
custom_pretrained,
1024+
g_pretrained_path,
1025+
d_pretrained_path,
1026+
vocoder,
1027+
checkpointing,
1028+
],
1029+
outputs=[train_output_info],
10371030
)
1031+
10381032
train_output_info.change(
10391033
fn=disable_stop_train_button,
10401034
inputs=[],

tabs/tts/tts.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
filter_dropdowns,
2020
get_files,
2121
get_speakers_id,
22-
index_files,
2322
match_index,
2423
refresh_embedders_folders,
2524
update_filter_visibility,
@@ -73,11 +72,7 @@ def tts_tab():
7372
index_file = gr.Dropdown(
7473
label=i18n("Index File"),
7574
info=i18n("Select the index file to use for the conversion."),
76-
choices=(
77-
[("No Index", "")] + [(x, x) for x in index_files]
78-
if index_files
79-
else []
80-
),
75+
choices=sorted(get_files("index")),
8176
value=match_index(default_weight),
8277
interactive=True,
8378
allow_custom_value=True,

0 commit comments

Comments
 (0)