python使用oct2py执行octave(matlab)文件报错:buffer is too small for requested array

在python中使用oct2py模块执行octave(matlab)文件时报错:

\bed\00f0204f_nohash_0.wav",1,1,1,1,1)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\xxxx\anaconda3\envs\tensorflow\lib\site-packages\oct2py\dynamic.py", line 96, in __call__
    return self._ref().feval(self.name, *inputs, **kwargs)
  File "C:\Users\xxxx\anaconda3\envs\tensorflow\lib\site-packages\oct2py\core.py", line 379, in feval
    store_as=store_as, plot_dir=plot_dir)
  File "C:\Users\xxxx\anaconda3\envs\tensorflow\lib\site-packages\oct2py\core.py", line 576, in _feval
    resp = read_file(in_file, self)
  File "C:\Users\xxxx\anaconda3\envs\tensorflow\lib\site-packages\oct2py\io.py", line 36, in read_file
    data = loadmat(path, struct_as_record=True)
  File "C:\Users\xxxx\anaconda3\envs\tensorflow\lib\site-packages\scipy\io\matlab\mio.py", line 218, in loadmat
    matfile_dict = MR.get_variables(variable_names)
  File "C:\Users\xxxx\anaconda3\envs\tensorflow\lib\site-packages\scipy\io\matlab\mio5.py", line 292, in get_variables
    res = self.read_var_array(hdr, process)
  File "C:\Users\xxxx\anaconda3\envs\tensorflow\lib\site-packages\scipy\io\matlab\mio5.py", line 252, in read_var_array
    return self._matrix_reader.array_from_header(header, process)
  File "mio5_utils.pyx", line 673, in scipy.io.matlab.mio5_utils.VarReader5.array_from_header
  File "mio5_utils.pyx", line 721, in scipy.io.matlab.mio5_utils.VarReader5.array_from_header
  File "mio5_utils.pyx", line 968, in scipy.io.matlab.mio5_utils.VarReader5.read_struct
  File "mio5_utils.pyx", line 671, in scipy.io.matlab.mio5_utils.VarReader5.read_mi_matrix
  File "mio5_utils.pyx", line 715, in scipy.io.matlab.mio5_utils.VarReader5.array_from_header
  File "mio5_utils.pyx", line 878, in scipy.io.matlab.mio5_utils.VarReader5.read_char
TypeError: buffer is too small for requested array

网上查找之后也没有发现原因,后来猜测是反斜号的问题,就将原来路径中的"\":

 octave.pre_process('C:\tmp\speech_dataset\bed\00f0204f_nohash_0.wav',16000,32,16,0.95,11)

替换为"\\":

octave.pre_process('C:\\tmp\\speech_dataset\\bed\\00f0204f_nohash_0.wav',16000,32,16,0.95,11)

之后即可
其实也可以使用下面这种表示方法:

octave.pre_process('/tmp/speech_dataset/bed/00f0204f_nohash_0.wav',16000,32,16,0.95,11)
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 5
    评论
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值