在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)