11
11
from uvr5_pack .lib_v5 import spec_utils
12
12
from uvr5_pack .utils import _get_name_params , inference
13
13
from uvr5_pack .lib_v5 .model_param_init import ModelParameters
14
- from scipy . io import wavfile
14
+ import soundfile as sf
15
15
from uvr5_pack .lib_v5 .nets_new import CascadedNet
16
16
from uvr5_pack .lib_v5 import nets_61968KB as nets
17
17
@@ -41,7 +41,7 @@ def __init__(self, agg, model_path, device, is_half):
41
41
self .mp = mp
42
42
self .model = model
43
43
44
- def _path_audio_ (self , music_file , ins_root = None , vocal_root = None ):
44
+ def _path_audio_ (self , music_file , ins_root = None , vocal_root = None , format = "flac" ):
45
45
if ins_root is None and vocal_root is None :
46
46
return "No save root."
47
47
name = os .path .basename (music_file )
@@ -120,12 +120,11 @@ def _path_audio_(self, music_file, ins_root=None, vocal_root=None):
120
120
else :
121
121
wav_instrument = spec_utils .cmb_spectrogram_to_wave (y_spec_m , self .mp )
122
122
print ("%s instruments done" % name )
123
- wavfile .write (
123
+ sf .write (
124
124
os .path .join (
125
- ins_root , "instrument_{}_{}.wav " .format (name , self .data ["agg" ])
125
+ ins_root , "instrument_{}_{}.{} " .format (name , self .data ["agg" ], format )
126
126
),
127
- self .mp .param ["sr" ],
128
- (np .array (wav_instrument ) * 32768 ).astype ("int16" ),
127
+ (np .array (wav_instrument ) * 32768 ).astype ("int16" ), self .mp .param ["sr" ],
129
128
) #
130
129
if vocal_root is not None :
131
130
if self .data ["high_end_process" ].startswith ("mirroring" ):
@@ -138,12 +137,11 @@ def _path_audio_(self, music_file, ins_root=None, vocal_root=None):
138
137
else :
139
138
wav_vocals = spec_utils .cmb_spectrogram_to_wave (v_spec_m , self .mp )
140
139
print ("%s vocals done" % name )
141
- wavfile .write (
140
+ sf .write (
142
141
os .path .join (
143
- vocal_root , "vocal_{}_{}.wav " .format (name , self .data ["agg" ])
142
+ vocal_root , "vocal_{}_{}.{} " .format (name , self .data ["agg" ], format )
144
143
),
145
- self .mp .param ["sr" ],
146
- (np .array (wav_vocals ) * 32768 ).astype ("int16" ),
144
+ (np .array (wav_vocals ) * 32768 ).astype ("int16" ), self .mp .param ["sr" ],
147
145
)
148
146
149
147
class _audio_pre_new :
@@ -173,7 +171,7 @@ def __init__(self, agg, model_path, device, is_half):
173
171
self .mp = mp
174
172
self .model = model
175
173
176
- def _path_audio_ (self , music_file , vocal_root = None , ins_root = None ):#3个VR模型vocal和ins是反的
174
+ def _path_audio_ (self , music_file , vocal_root = None , ins_root = None , format = "flac" ):#3个VR模型vocal和ins是反的
177
175
if ins_root is None and vocal_root is None :
178
176
return "No save root."
179
177
name = os .path .basename (music_file )
@@ -252,12 +250,11 @@ def _path_audio_(self, music_file, vocal_root=None, ins_root=None):#3个VR模型
252
250
else :
253
251
wav_instrument = spec_utils .cmb_spectrogram_to_wave (y_spec_m , self .mp )
254
252
print ("%s instruments done" % name )
255
- wavfile .write (
253
+ sf .write (
256
254
os .path .join (
257
- ins_root , "main_vocal_{}_{}.wav " .format (name , self .data ["agg" ])
255
+ ins_root , "main_vocal_{}_{}.{} " .format (name , self .data ["agg" ], format )
258
256
),
259
- self .mp .param ["sr" ],
260
- (np .array (wav_instrument ) * 32768 ).astype ("int16" ),
257
+ (np .array (wav_instrument ) * 32768 ).astype ("int16" ),self .mp .param ["sr" ],
261
258
) #
262
259
if vocal_root is not None :
263
260
if self .data ["high_end_process" ].startswith ("mirroring" ):
@@ -270,12 +267,11 @@ def _path_audio_(self, music_file, vocal_root=None, ins_root=None):#3个VR模型
270
267
else :
271
268
wav_vocals = spec_utils .cmb_spectrogram_to_wave (v_spec_m , self .mp )
272
269
print ("%s vocals done" % name )
273
- wavfile .write (
270
+ sf .write (
274
271
os .path .join (
275
- vocal_root , "others_{}_{}.wav " .format (name , self .data ["agg" ])
272
+ vocal_root , "others_{}_{}.{} " .format (name , self .data ["agg" ], format )
276
273
),
277
- self .mp .param ["sr" ],
278
- (np .array (wav_vocals ) * 32768 ).astype ("int16" ),
274
+ (np .array (wav_vocals ) * 32768 ).astype ("int16" ),self .mp .param ["sr" ],
279
275
)
280
276
281
277
0 commit comments