segan_pytorch
segan_pytorch copied to clipboard
ValueError: cannot reshape array of size 2 into shape (1,)
I was trying to train this model but an error occurred. Is there any way to resolved it?
Thanks for your time!
Same issue with me. Trying to clean a .wav file, only about 30 seconds in length. Anyone?
Cleaning 1 wavs
clean.py:62: WavFileWarning: Chunk (non-data) not understood, skipping it.
rate, wav = wavfile.read(twav)
Traceback (most recent call last):
File "clean.py", line 110, in
Figured it out for me. It was due to my .wav file having extra metadata added to it when I exported it from Audacity. I had to clear this metadata by just selecting "Clear" when I go to export my edited .wav file. Audacity likes to add some tag to the file which scipy can't parse when you run this clean.py file. I found the answer on this page:
https://stackoverflow.com/questions/14321627/scipy-io-wavfile-gives-wavfilewarning-chunk-not-understood-error
Face the same issue. I solve it to modify by:
def pre_emphasize(x, coef=0.95):
if coef <= 0:
return x
if len(x.shape)>1:
x = x[:, 0]
x0 = np.reshape(x[0], (1,))
diff = x[1:] - coef * x[:-1]
concat = np.concatenate((x0, diff), axis=0)
return concat
Use the codes above to replace: https://github.com/santi-pdp/segan_pytorch/blob/master/segan/datasets/se_dataset.py#L111-L117
============================================
However, it is a issue caused by scipy
and your audio file's format
do:
print(wav.shape)
at here: https://github.com/santi-pdp/segan_pytorch/blob/master/clean.py#L68 you can got (N, ) if the codes doesn't go wrong, and may got (N, 2) if the codes goes wrong with "wrong" audio file.