Hello stackoverflow users,
Currently I am facing the following problem, I have a function to open a .wav file, it returns sample rate, length and samples. I have tried it will small files, it worked perfectly, now I am trying to load 1GB wav file and it returns me "MemoryError was unhandled by user code" window.
Here is my function:
def OpenWavFile(fileName):
waveFile = wave.open(fileName, 'r')
sampFreq = waveFile.getframerate()
length = waveFile.getnframes()
byteList = np.fromstring(waveFile.readframes(length), dtype = np.int16)
return sampFreq, length, byteList
I have tried it with breakpoints and I noticed that the value of length variable is 472289280, what fits in int
range. I have tried this function at this position dtype = np.int16
, with different types.
Is there a limitation of numpy? Or where is the problem?
RAM size is 8Gb on my laptop.