I'm training a Python audio source separation model package called DeWave (https://github.com/chaodengusc/DeWave). It's trained on single-channel .wav files. After training the model, I did inference on a .wav sample (to separate the two speaker sources in the single-channel audio test file). This works fine, except if I cut the .wav file, in which case I get an error from librosa stating that the audio buffer is not finite everywhere.
I've tried to do inference on different audio files, and the error only occurs if I use an external software to cut the .wav file (I've tried cutting with sox and Zamzar). The audio files I've done inference on successfully have all different lengths and are not multiples of a given length, so I don't believe it's a length issue. I'm wondering if the file cutting erases a buffer, but I'm not familiar with buffers in general, so any insight would be appreciated on how to remedy this.
The main code that writes with librosa are these lines from https://github.com/chaodengusc/DeWave/blob/master/DeWave/infer.py
## restore the original audio
len1 = len(out_audio1) // 3
len2 = len(out_audio2) // 3
source1 = out_audio1[len1:2*len1]
source2 = out_audio2[len2:2*len2]
librosa.output.write_wav(input_file[0:-4]+"_source1.wav", source1, SAMPLING_RATE)
librosa.output.write_wav(input_file[0:-4]+"_source2.wav", source2, SAMPLING_RATE)
return [(source1, SAMPLING_RATE), (source2, SAMPLING_RATE)]
The expected output would be two separate .wav files of the same length with one speaker in each file, and silence where the other speaker is speaking. However, I get this error:
Traceback (most recent call last):
File "/home/<me>/anaconda3/bin/dewave-infer", line 11, in <module>
sys.exit(infer())
File "/home/<me>/anaconda3/lib/python3.6/site-packages/DeWave/cmdinfer.py", line 12, in infer
blind_source_separation(args.input_file, args.model_dir)
File "/home/<me>/anaconda3/lib/python3.6/site-packages/DeWave/infer.py", line 207, in blind_source_separation
librosa.output.write_wav(input_file[0:-4]+"_source1.wav", source1, SAMPLING_RATE)
File "<decorator-gen-6>", line 2, in write_wav
File "/home/<me>/anaconda3/lib/python3.6/site-packages/librosa/util/decorators.py", line 58, in __wrapper
return func(*args, **kwargs)
File "/home/<me>/anaconda3/lib/python3.6/site-packages/librosa/output.py", line 239, in write_wav
util.valid_audio(y, mono=False)
File "/home/<me>/anaconda3/lib/python3.6/site-packages/librosa/util/utils.py", line 171, in valid_audio
raise ParameterError('Audio buffer is not finite everywhere')
librosa.util.exceptions.ParameterError: Audio buffer is not finite everywhere