1
$\begingroup$

I have a dataset of audios(namely TIDIGITS, collected at Texas Instruments, Inc.) and they are in .wav format. However, when I try to read them from python, I get the following error:

Error: file does not start with RIFF id

Error is thrown from the following line:

import wave
...
f = wave.open(/path/to/audio/example.wav, "rb")

I searched on the Internet, and it looks like the problem is that "wave" library does not support NIST formats and the audio are in the NIST SPHERE format, according to the dabaset's website: https://catalog.ldc.upenn.edu/ldc93s10

So I transformed them into .wav using "sox" program:

find . -name '*.wav' | xargs -I@ bash -c "sox @ @"

The command reads though all of my ".wav" files and then applies

sox name.wav name.wav

to transform them to RIFF format.

However, now when I play the files in my media player, I get no sound. The waveform of the audio becomes as follows:

enter image description here

Where it should be something like this:

enter image description here

I think the problem lies at the sox command.

Can anyone help me to convert all of my data to a RIFF format, so that I could read them from the "wave" library?

EDIT: Also, now I noticed, that when I apply the sox command to only one file, the file is converted to "RIFF" format and the waveform is similar to the second image, however when I apply them to all of them with the above described command, the audios loose their sound.

Thank you in advance!

$\endgroup$
  • 1
    $\begingroup$ Ask TI which format the files are in: .wav is just a file name extension, and that says exactly nothing about the file format. $\endgroup$ – Marcus Müller Apr 30 '18 at 9:26
  • $\begingroup$ Hello @MarcusMüller! As I mentioned, on the TI website, there is written that "The waveform files are in the NIST SPHERE format." $\endgroup$ – UrmLmn Apr 30 '18 at 9:30
  • $\begingroup$ You didn't say that, you said you inferred from something you read "on the internet", so I needed you to confirm that we're not only guessing it's that format, but have certainty. Can you still link to where you read that, please? Might help a lot! Where did you read that Sox can read SPHERE files? $\endgroup$ – Marcus Müller Apr 30 '18 at 9:32
  • $\begingroup$ Also, now I noticed, that when I apply the sox command to only one file, the file is converted to "RIFF" format and the waveform is similar to the second image, however when I apply them to all of them with the above described command, the audios loose their sound. The page of the dataset is here: catalog.ldc.upenn.edu/ldc93s10 $\endgroup$ – UrmLmn Apr 30 '18 at 9:36
  • $\begingroup$ Please edit your question to include that link! The chances that you get an answer when people don't have to read all the comments to get all the details are way higher :) $\endgroup$ – Marcus Müller Apr 30 '18 at 9:38
2
$\begingroup$

OK, I solve the problem. The problem was that I was overriding the files when I used the "sox" command, as I want them to convert into RIFF format. However, "sox" didn't convert them correctly when using the same file name, i.e. when overriding the files. When I changed the file name of the overridden files, it converted them into RIFF format.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.