nttcslab-sp / kaldiio

A pure python module for reading and writing kaldi ark files
Other
248 stars 35 forks source link

New version cannot work with multichannel .wav files #30

Closed Jzmo closed 5 years ago

Jzmo commented 5 years ago

Hi,

I'm using kaldiio to process multichannel wav files in espnet, and noticed that in matio.py

mat = _load_mat(arkfd, offset, slices, endian=endian,
                                        as_bytes=as_bytes,
                                        use_scipy_wav=False)

can not successfully read the header but the older version (use_scipy_wav=offset is None) can.

I think it is because when processing multichannel files, it firstly call wavio.read_wav() which modified 'fd' but failed(don't know why), then call wavio.read_wav_scipy() with this 'fd' and fail to reach the header.

If my understanding is wrong please let me know, thanks.

nttcslab-sp-admin commented 5 years ago

Thank you. It was fixed at v2.13.7

The wave which is output from sox has wrong header in some situation. Typically, they comes from the stream output and kaldi's wav.scp includes such usage in many recipes. Because the information of wave has redundant information, many audio library can read such wav file with ignoring the header, e.g. sndfile and sox can read them without any problem, but scipy and python-builtin-wave can't do. I copied and modified python-builtin-wave to ignore the incorrect information in this case - the data format in the wave header is wrong only with multi channel case. I don't know why .

Jzmo commented 5 years ago

Thanks for your reply, it now work well.