wav2vec icon indicating copy to clipboard operation
wav2vec copied to clipboard

TypeError: "NoneType" object is not subscriptable when converting some wav file

Open AaronZhangAus opened this issue 10 months ago • 4 comments

Hi, wav2vec team.

I received "TypeError: "NoneType" object is not subscriptable" as in the screenshot attached when I converted some wav files while others seem to be OK.

Can you pls give some ideas what caused it?

Thank you.

AaronZhangAus avatar Apr 18 '24 06:04 AaronZhangAus

Hi,

Is it possible for you to share one of the wav files that produces the error?

cristoper avatar Apr 18 '24 15:04 cristoper

thanks for getting back to me Chris. I used this public dataset: https://github.com/irfankamboh/DeepShip/tree/main

I can't upload wav file here as it only accepts images. if you run wav2vec on a wav file e.g in PassengerShip or other ships folders, you will replicate the issue.

Areas I have looked into but no findings are:

  • codec of the wav file
  • file access on Linux, normal as other wav files
  • sample rate of the wav file

thanks for looking into this. Look forward to hear back from you.

AaronZhangAus avatar Apr 19 '24 12:04 AaronZhangAus

Hi Aaron,

It looks like .wav files in that directory use floating point data samples, but unfortunately Python's wave module only supports reading integer data. There is an open Python bug report and PR, but it is not yet merged: https://github.com/python/cpython/issues/60729

I think the only workaround would be to first convert the .wav files to a non-floating point format. One way to do that is to open the files in Audacity and then export them as signed 32 bit PCM WAV files. You can probably automate the conversion with the ffmpeg command line tool (this works for me: ffmpeg -i ~/Downloads/1.wav 1_converted.wav which produces a 16 bit WAV file that wav2vec can read).

cristoper avatar Apr 19 '24 16:04 cristoper

thanks Cristoper for the prompt response. I will give it a try and keep you posted.

AaronZhangAus avatar Apr 22 '24 01:04 AaronZhangAus