pythonnumpyaudiopyaudioanalysis

pyAudioAnalysis Library error: cannot reshape array of size 4400 into shape (220,10)


I'm trying to extract some features of a wav file, I have this:

https://s3-us-west-2.amazonaws.com/music-emotions/ambient/13+Clock+in+the+Morning+-+Waiters+the++Free+Music+Archive+(No+Copyright+Music).wav

I'm using the feature extraction tools of the pyAudioAnalysis library:

https://github.com/tyiannak/pyAudioAnalysis/wiki/3.-Feature-Extraction

The problem is that I'm getting an error of the reshape() function of numpy. I'm following the guidelines of how to use the feature extractor as in the wiki like this:

[Fs, x] = audioBasicIO.readAudioFile('13 Clock in the Morning - Waiters the  Free Music Archive (No Copyright Music).wav')
F = audioFeatureExtraction.stFeatureExtraction(x, Fs, 0.050 * Fs, 0.025 * Fs)

And this is the error I get:

      1 [Fs, x] = audioBasicIO.readAudioFile("song-wavs/"+song.name)
----> 2 F = audioFeatureExtraction.stFeatureExtraction(x, Fs, 0.050 * Fs, 0.025 * Fs)

pyAudioAnalysis/audioFeatureExtraction.pyc in stFeatureExtraction(signal, Fs, Win, Step)
    575         curFV[0] = stZCR(x)                              # zero crossing rate
    576         curFV[1] = stEnergy(x)                           # short-term energy
--> 577         curFV[2] = stEnergyEntropy(x)                    # short-term entropy of energy
    578         [curFV[3], curFV[4]] = stSpectralCentroidAndSpread(X, Fs)    # spectral centroid and spread
    579         curFV[5] = stSpectralEntropy(X)                  # spectral entropy

pyAudioAnalysis/audioFeatureExtraction.pyc in stEnergyEntropy(frame, numOfShortBlocks)
     49             frame = frame[0:subWinLength * numOfShortBlocks]
     50     # subWindows is of size [numOfShortBlocks x L]
---> 51     subWindows = frame.reshape(subWinLength, numOfShortBlocks, order='F').copy()
     52 
     53     # Compute normalized sub-frame energies:

ValueError: cannot reshape array of size 4400 into shape (220,10)

Can anyone tell me how can I fix the problem of the reshape and what is it that I'm doing wrong?


Solution

  • I had the same error, but according to https://github.com/tyiannak/pyAudioAnalysis/issues/72, I converted my stereo music to mono and it solved the problem for me.