ValueError:字符串大小必须是元素大小的倍数

时间:2017-05-01 20:00:33

标签: python scipy classification wav mfcc

我正在对两类音频样本(.wav文件)进行分类。 以下是出现错误的示例代码,

> for curr_class in classes:
>     dirname = os.path.join(data_dir_train, curr_class)
>     for fname in os.listdir(dirname):
>         with open(os.path.join(dirname, fname), 'r') as f:
>             rate,sig = scipy.io.wavfile.read(f)
              mfcc_feat = mfcc(sig, rate)
              train_data.append(mfcc_feat[1:9, :])

运行代码时遇到以下错误:

C:\Python27\lib\site-packages\scipy\io\wavfile.py:267: WavFileWarning: Chunk (non-data) not understood, skipping it.
  WavFileWarning)
Traceback (most recent call last):
  File "C:/Users/NIKHIL/PycharmProjects/major1/try1.py", line 44, in <module>
    rate,sig = scipy.io.wavfile.read(f)
  File "C:\Python27\lib\site-packages\scipy\io\wavfile.py", line 258, in read
    is_big_endian, mmap)
  File "C:\Python27\lib\site-packages\scipy\io\wavfile.py", line 129, in _read_data_chunk
    data = numpy.fromstring(fid.read(size), dtype=dtype)
ValueError: string size must be a multiple of element size

提前致谢

0 个答案:

没有答案