Encounter issue when read audio
Closed this issue · 2 comments
When I run the DTW.py,it warn that ValueError: not enough values to unpack (expected 3, got 2).
" File "D:/pycharm/python_sound_open-master/chapter10_语音识别/DTW/DTW.py", line 204, in
data, fs = soundBase('p1/{}.wav'.format(i)).audioread()"
So I check the file path and it is right.Is the parameter missing, or some other problem?
There will be several reason for this.
Firstly, please open soundBase.py and modify the function audioread
to :
def audioread(self, return_nbits=False, formater='sample'):
fs, data, bits = wavfile.read(self.path)
if formater == 'sample':
data = data / (2 ** (bits - 1))
if return_nbits:
return data, fs, bits
else:
return data, fs
Then, you will note that there are three parameter as the returns of wavfile.read(self.path)
. But if you open the read
function in wavfile.py, there is only two parameter as return. Please modify the return fs, data
as return fs, data, bit_depth
in read
function of wavfile.py
.
bit_depth
means the bits of data. We used in somewhere in this project, but it is not used in this chapter.
Thank you for your reply, I have solved the problem and thank you again.