RockmanYang commited on
Commit
5263115
·
1 Parent(s): e7532d6

Update inference.py

Browse files
Files changed (1) hide show
  1. inference.py +13 -7
inference.py CHANGED
@@ -11,7 +11,8 @@ from lib import dataset
11
  from lib import nets
12
  from lib import spec_utils
13
  from lib import utils
14
-
 
15
 
16
  class Separator(object):
17
 
@@ -162,12 +163,17 @@ def main():
162
  wave = spec_utils.spectrogram_to_wave(y_spec, hop_length=args.hop_length)
163
  print('done')
164
  # sf.write('{}{}_Instruments.wav'.format(output_dir, basename), wave.T, sr)
165
- sf.write('{}Instruments.wav'.format(output_dir), wave.T, sr)
166
-
167
- print('inverse stft of vocals...', end=' ')
168
- wave = spec_utils.spectrogram_to_wave(v_spec, hop_length=args.hop_length)
169
- print('done')
170
- sf.write('{}{}_Vocals.wav'.format(output_dir, basename), wave.T, sr)
 
 
 
 
 
171
 
172
  if args.output_image:
173
  image = spec_utils.spectrogram_to_image(y_spec)
 
11
  from lib import nets
12
  from lib import spec_utils
13
  from lib import utils
14
+ import io
15
+ from pydub import AudioSegment
16
 
17
  class Separator(object):
18
 
 
163
  wave = spec_utils.spectrogram_to_wave(y_spec, hop_length=args.hop_length)
164
  print('done')
165
  # sf.write('{}{}_Instruments.wav'.format(output_dir, basename), wave.T, sr)
166
+ #sf.write('{}Instruments.wav'.format(output_dir), wave.T, sr)
167
+ wav_io = io.BytesIO()
168
+ sf.write(wav_io, wave.T, sr,format='WAV')
169
+ wav_io.seek(0)
170
+ song=AudioSegment.from_wav(wav_io)
171
+ song.export('{}Instruments.ogg'.format(output_dir),format='ogg')
172
+
173
+ #print('inverse stft of vocals...', end=' ')
174
+ #wave = spec_utils.spectrogram_to_wave(v_spec, hop_length=args.hop_length)
175
+ #print('done')
176
+ #sf.write('{}{}_Vocals.wav'.format(output_dir, basename), wave.T, sr)
177
 
178
  if args.output_image:
179
  image = spec_utils.spectrogram_to_image(y_spec)