Unexpected end of file wavfile.read python

半世苍凉 提交于 2019-12-23 13:05:25

问题


I am trying to read .wav audio file by following code

from scipy.io import wavfile
file = 'PC1_20090513_050000_0010.wav'
rate, audio = wavfile.read(file)

but it is showing following error :

raise ValueError("Unexpected end of file.")
ValueError: Unexpected end of file.

Any idea ??


回答1:


It seems that you got incorrect data in the head of wav file (http://soundfile.sapp.org/doc/WaveFormat/). VLC sometimes can handle that. Try to resave this file with any soft. For example use sox (http://sox.sourceforge.net/) and resample to the same frequency that were (like this: sox.exe wav_file -r frequency out_wav_file)



来源:https://stackoverflow.com/questions/47419836/unexpected-end-of-file-wavfile-read-python

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!