@@ -119,8 +119,15 @@ def vc(
119
119
npy = feats [0 ].cpu ().numpy ()
120
120
if self .is_half :
121
121
npy = npy .astype ("float32" )
122
- _ , I = index .search (npy , 1 )
123
- npy = big_npy [I .squeeze ()]
122
+
123
+ # _, I = index.search(npy, 1)
124
+ # npy = big_npy[I.squeeze()]
125
+
126
+ score , ix = index .search (npy , k = 8 )
127
+ weight = np .square (1 / score )
128
+ weight /= weight .sum (axis = 1 , keepdims = True )
129
+ npy = np .sum (big_npy [ix ] * np .expand_dims (weight , axis = 2 ), axis = 1 )
130
+
124
131
if self .is_half :
125
132
npy = npy .astype ("float16" )
126
133
feats = (
@@ -172,21 +179,23 @@ def pipeline(
172
179
f0_up_key ,
173
180
f0_method ,
174
181
file_index ,
175
- file_big_npy ,
182
+ # file_big_npy,
176
183
index_rate ,
177
184
if_f0 ,
178
185
f0_file = None ,
179
186
):
187
+ print (file_index != "" ,os .path .exists (file_index ) == True ,index_rate != 0 )
180
188
if (
181
- file_big_npy != ""
182
- and file_index != ""
183
- and os .path .exists (file_big_npy ) == True
189
+ file_index != ""
190
+ # and file_big_npy != ""
191
+ # and os.path.exists(file_big_npy) == True
184
192
and os .path .exists (file_index ) == True
185
193
and index_rate != 0
186
194
):
187
195
try :
188
196
index = faiss .read_index (file_index )
189
- big_npy = np .load (file_big_npy )
197
+ # big_npy = np.load(file_big_npy)
198
+ big_npy = index .reconstruct_n (0 , index .ntotal )
190
199
except :
191
200
traceback .print_exc ()
192
201
index = big_npy = None
0 commit comments