#145 WAV 2 uLAW conversion fails occassionally

closed-works-for-me
nobody
None
5
2013-08-14
2009-09-22
OnTheEdge
No

We create WAV files from a TTS engine (NeoSpeech) on a Windows 2k3 server and execute Sox 14.3 (and 12.17.x) to convert them to headless-uLAW files. 99% of the time the conversion works just fine and an 8-bit 8KHz PCM wav file is converted to an 8-bit 8KHz mono headerless uLAW file.

However once in a while the SoX generates a 16-bit 48KHz PCM file despite the command-line param that explicitly expects the output in uLAW.

If the initial errant 8-bit 8kHz PCM is converted, using SoX, to 16kHz and then converted back to a uLAW the resultant file is perfectly formed.
A careful review of the fields in the PCM data struct, and the WaveFormatEx header, of the errant WAV file, is identical to any other PCM file (except the 4-byte size field) that is sent to SoX as input and generates the well-formed output uLAW file.

If anyone can explain why this happens we would be really grateful.
Regards,
Edge.

Discussion

  • robs

    robs - 2009-09-27

    Please can you clarify: you mention examining the header of the errant file, but prior to that you say that the target of the conversion is header-less.
    TIA.

     
  • OnTheEdge

    OnTheEdge - 2009-09-28

    Sorry for the confusion, and thank you for taking an interest in my post.
    I compared the PCM headers of both source PCM 8-bit 8kHz files. They both generate headerl-less uLAW files. However most of the time I can drag the output file (uLAW) into Goldwave and it asks about the format (which is fine) and plays the file as an audio stream.
    However occassionally the output file will have no obvious header information ("RIFF' for example) but when dragged into Goldwave it is recognized as a PCM 16-bit 48kHz format and just plays a squeaky sound.

    Once a source file is identified as generating squeaky output I can continually execute SoX using the cmd-line params shown here to reproduce the problem:

    > SoX -t wav SourceFile.WAV -t ul -r 8000 OutputFile.WAV.WAV

    Converting the 8kHz source file to a 16kHz PCM file and then converting it to a uLAW file will work just fine.

    If there's a way to upload 4 files (2 source files, and 2 output files one of which is squeaky) I will be delighted to do so.
    Regards,
    Edge.

     
  • Doug Cook

    Doug Cook - 2009-10-02

    My guess is that this isn't a bug at all. Goldwave tried to guess what the file format was. With no header, and with all of the data in the file pure audio, almost any combination of data is possible. Every once in a while, the audio data looks like a header that Goldwave recognizes. It then tries to treat the audio data like a header.

    You can't rely on any program to accurately guess the file type if it doesn't have an accurate file extension or a recognizable header. Perhaps try naming the files ".raw" instead of ".wav" so that Goldwave doesn't try to treat them like WAV files, or use -t WAV to create a WAV file so that the file always has an accurate header.

     
  • Doug Cook

    Doug Cook - 2009-12-24
    • status: open --> closed-works-for-me
     
  • Doug Cook

    Doug Cook - 2009-12-24

    Without additional information, it seems that SoX is doing the right thing here, and that the problem is with telling SoX to treat raw files as wav files.

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks