Ingerid
Ingerid

Reputation: 151

Sox file format fail

I have tried to convert pcm files to wav, but keep getting a FAIL format error, no matter how many (or few) options I try. I am wondering what I need to do to get the file handler for pcm files. Installing sox again and updating the terminal did nothing. I know this question has been here before, and here, but sadly, nobody gave an answer that solved the problem.

Here's the command I tried:

sox -t raw -r 44000 --bits 16 −e signed-integer -c 2 -B \
    infile.pcm /wav/outfile.wav channels 1

and this is the error it throws:

sox FAIL formats: no handler for file extension `pcm'

The pcm-files have the following properties:

I need it to give me the speech only (so convert from stereo to mono, but only taking the information from the left channel) and in a wav file, so the program I'm using can deal with it.

Upvotes: 5

Views: 4601

Answers (1)

Ingerid
Ingerid

Reputation: 151

Found a solution! Basically, everyone else's suggestion to put -t raw right after the command was wrong, and order does indeed matter. Now, I don't know why the strictness of the option order is never specified in the documentation (and I think I read through all of it, although not in one sitting), but at least this is what worked for me to convert a headerless raw PCM file to wav:

sox -e signed-integer -b 16 -B -r 44100 -c 2 -t raw infile.pcm wav/outfile.wav remix 1

Order of options, files and effects:

  1. encoding
  2. sample size
  3. endianness
  4. sample rate
  5. channels
  6. file type
  7. infile
  8. outfile
  9. remix effect, converting from stereo to mono

The remix effect chooses which channel to use (in this case, 1 for left). My stereo infile consists of speech (left=1) and laryngograph recording (right=2), so I didn't want both together in the output.

Upvotes: 10

Related Questions