@@ -126,7 +126,7 @@ def vc_single(
126
126
f0_file ,
127
127
f0_method ,
128
128
file_index ,
129
- file_big_npy ,
129
+ # file_big_npy,
130
130
index_rate ,
131
131
): # spk_item, input_audio0, vc_transform0,f0_file,f0method0
132
132
global tgt_sr , net_g , vc , hubert_model
@@ -147,9 +147,9 @@ def vc_single(
147
147
.strip (" " )
148
148
.replace ("trained" , "added" )
149
149
) # 防止小白写错,自动帮他替换掉
150
- file_big_npy = (
151
- file_big_npy .strip (" " ).strip ('"' ).strip ("\n " ).strip ('"' ).strip (" " )
152
- )
150
+ # file_big_npy = (
151
+ # file_big_npy.strip(" ").strip('"').strip("\n").strip('"').strip(" ")
152
+ # )
153
153
audio_opt = vc .pipeline (
154
154
hubert_model ,
155
155
net_g ,
@@ -159,7 +159,7 @@ def vc_single(
159
159
f0_up_key ,
160
160
f0_method ,
161
161
file_index ,
162
- file_big_npy ,
162
+ # file_big_npy,
163
163
index_rate ,
164
164
if_f0 ,
165
165
f0_file = f0_file ,
@@ -182,7 +182,7 @@ def vc_multi(
182
182
f0_up_key ,
183
183
f0_method ,
184
184
file_index ,
185
- file_big_npy ,
185
+ # file_big_npy,
186
186
index_rate ,
187
187
):
188
188
try :
@@ -200,6 +200,14 @@ def vc_multi(
200
200
traceback .print_exc ()
201
201
paths = [path .name for path in paths ]
202
202
infos = []
203
+ file_index = (
204
+ file_index .strip (" " )
205
+ .strip ('"' )
206
+ .strip ("\n " )
207
+ .strip ('"' )
208
+ .strip (" " )
209
+ .replace ("trained" , "added" )
210
+ ) # 防止小白写错,自动帮他替换掉
203
211
for path in paths :
204
212
info , opt = vc_single (
205
213
sid ,
@@ -208,7 +216,7 @@ def vc_multi(
208
216
None ,
209
217
f0_method ,
210
218
file_index ,
211
- file_big_npy ,
219
+ # file_big_npy,
212
220
index_rate ,
213
221
)
214
222
if info == "Success" :
@@ -629,29 +637,29 @@ def train_index(exp_dir1):
629
637
phone = np .load ("%s/%s" % (feature_dir , name ))
630
638
npys .append (phone )
631
639
big_npy = np .concatenate (npys , 0 )
632
- np .save ("%s/total_fea.npy" % exp_dir , big_npy )
633
- n_ivf = big_npy .shape [0 ] // 39
634
- infos = []
635
- infos .append ("%s,%s" % (big_npy .shape , n_ivf ))
640
+ # np.save("%s/total_fea.npy" % exp_dir, big_npy)
641
+ # n_ivf = big_npy.shape[0] // 39
642
+ n_ivf = min (int (16 * np .sqrt (big_npy .shape [0 ])),big_npy .shape [0 ]// 39 )
643
+ infos = []
644
+ infos .append ("%s,%s" % (big_npy .shape ,n_ivf ))
636
645
yield "\n " .join (infos )
637
- index = faiss .index_factory (256 , "IVF%s,Flat" % n_ivf )
646
+ index = faiss .index_factory (256 , "IVF%s,Flat" % n_ivf )
647
+ # index = faiss.index_factory(256, "IVF%s,PQ128x4fs,RFlat"%n_ivf)
638
648
infos .append ("training" )
639
649
yield "\n " .join (infos )
640
650
index_ivf = faiss .extract_index_ivf (index ) #
641
- index_ivf .nprobe = int (np .power (n_ivf , 0.3 ))
651
+ # index_ivf.nprobe = int(np.power(n_ivf,0.3))
652
+ index_ivf .nprobe = 1
642
653
index .train (big_npy )
643
- faiss .write_index (
644
- index ,
645
- "%s/trained_IVF%s_Flat_nprobe_%s.index" % (exp_dir , n_ivf , index_ivf .nprobe ),
646
- )
654
+ faiss .write_index (index , '%s/trained_IVF%s_Flat_nprobe_%s.index' % (exp_dir ,n_ivf ,index_ivf .nprobe ))
655
+ # faiss.write_index(index, '%s/trained_IVF%s_Flat_FastScan.index'%(exp_dir,n_ivf))
647
656
infos .append ("adding" )
648
657
yield "\n " .join (infos )
649
658
index .add (big_npy )
650
- faiss .write_index (
651
- index ,
652
- "%s/added_IVF%s_Flat_nprobe_%s.index" % (exp_dir , n_ivf , index_ivf .nprobe ),
653
- )
654
- infos .append ("成功构建索引, added_IVF%s_Flat_nprobe_%s.index" % (n_ivf , index_ivf .nprobe ))
659
+ faiss .write_index (index , '%s/added_IVF%s_Flat_nprobe_%s.index' % (exp_dir ,n_ivf ,index_ivf .nprobe ))
660
+ infos .append ("成功构建索引,added_IVF%s_Flat_nprobe_%s.index" % (n_ivf ,index_ivf .nprobe ))
661
+ # faiss.write_index(index, '%s/added_IVF%s_Flat_FastScan.index'%(exp_dir,n_ivf))
662
+ # infos.append("成功构建索引,added_IVF%s_Flat_FastScan.index"%(n_ivf))
655
663
yield "\n " .join (infos )
656
664
657
665
@@ -842,13 +850,15 @@ def get_info_str(strr):
842
850
phone = np .load ("%s/%s" % (feature_dir , name ))
843
851
npys .append (phone )
844
852
big_npy = np .concatenate (npys , 0 )
845
- np .save ("%s/total_fea.npy" % exp_dir , big_npy )
846
- n_ivf = big_npy .shape [0 ] // 39
853
+ # np.save("%s/total_fea.npy" % exp_dir, big_npy)
854
+ # n_ivf = big_npy.shape[0] // 39
855
+ n_ivf = min (int (16 * np .sqrt (big_npy .shape [0 ])),big_npy .shape [0 ]// 39 )
847
856
yield get_info_str ("%s,%s" % (big_npy .shape , n_ivf ))
848
857
index = faiss .index_factory (256 , "IVF%s,Flat" % n_ivf )
849
858
yield get_info_str ("training index" )
850
859
index_ivf = faiss .extract_index_ivf (index ) #
851
- index_ivf .nprobe = int (np .power (n_ivf , 0.3 ))
860
+ # index_ivf.nprobe = int(np.power(n_ivf,0.3))
861
+ index_ivf .nprobe = 1
852
862
index .train (big_npy )
853
863
faiss .write_index (
854
864
index ,
@@ -1022,16 +1032,16 @@ def export_onnx(ModelPath, ExportedPath, MoeVS=True):
1022
1032
value = "E:\\ codes\\ py39\\ vits_vc_gpu_train\\ logs\\ mi-test-1key\\ added_IVF677_Flat_nprobe_7.index" ,
1023
1033
interactive = True ,
1024
1034
)
1025
- file_big_npy1 = gr .Textbox (
1026
- label = i18n ("特征文件路径" ),
1027
- value = "E:\\ codes\py39\\ vits_vc_gpu_train\\ logs\\ mi-test-1key\\ total_fea.npy" ,
1028
- interactive = True ,
1029
- )
1035
+ # file_big_npy1 = gr.Textbox(
1036
+ # label=i18n("特征文件路径"),
1037
+ # value="E:\\codes\py39\\vits_vc_gpu_train\\logs\\mi-test-1key\\total_fea.npy",
1038
+ # interactive=True,
1039
+ # )
1030
1040
index_rate1 = gr .Slider (
1031
1041
minimum = 0 ,
1032
1042
maximum = 1 ,
1033
1043
label = "检索特征占比" ,
1034
- value = 0.6 ,
1044
+ value = 0.65 ,
1035
1045
interactive = True ,
1036
1046
)
1037
1047
f0_file = gr .File (label = i18n ("F0曲线文件, 可选, 一行一个音高, 代替默认F0及升降调" ))
@@ -1048,7 +1058,7 @@ def export_onnx(ModelPath, ExportedPath, MoeVS=True):
1048
1058
f0_file ,
1049
1059
f0method0 ,
1050
1060
file_index1 ,
1051
- file_big_npy1 ,
1061
+ # file_big_npy1,
1052
1062
index_rate1 ,
1053
1063
],
1054
1064
[vc_output1 , vc_output2 ],
@@ -1075,11 +1085,11 @@ def export_onnx(ModelPath, ExportedPath, MoeVS=True):
1075
1085
value = "E:\\ codes\\ py39\\ vits_vc_gpu_train\\ logs\\ mi-test-1key\\ added_IVF677_Flat_nprobe_7.index" ,
1076
1086
interactive = True ,
1077
1087
)
1078
- file_big_npy2 = gr .Textbox (
1079
- label = i18n ("特征文件路径" ),
1080
- value = "E:\\ codes\\ py39\\ vits_vc_gpu_train\\ logs\\ mi-test-1key\\ total_fea.npy" ,
1081
- interactive = True ,
1082
- )
1088
+ # file_big_npy2 = gr.Textbox(
1089
+ # label=i18n("特征文件路径"),
1090
+ # value="E:\\codes\\py39\\vits_vc_gpu_train\\logs\\mi-test-1key\\total_fea.npy",
1091
+ # interactive=True,
1092
+ # )
1083
1093
index_rate2 = gr .Slider (
1084
1094
minimum = 0 ,
1085
1095
maximum = 1 ,
@@ -1107,7 +1117,7 @@ def export_onnx(ModelPath, ExportedPath, MoeVS=True):
1107
1117
vc_transform1 ,
1108
1118
f0method1 ,
1109
1119
file_index2 ,
1110
- file_big_npy2 ,
1120
+ # file_big_npy2,
1111
1121
index_rate2 ,
1112
1122
],
1113
1123
[vc_output3 ],
0 commit comments