Menu

48000 to 16000 (Sampling errors)

Help
2004-03-24
2012-09-22
  • James Trienfo

    James Trienfo - 2004-03-24

    Alright, when I try and run sphinx2-simple or sphinx2-continuous it bails with this error:

    Audio ioctl(SPEED): 48000, expected: 16000
    ad_open_sps failed

    Now, according to the FAQ, I have to change the code that sends the samples to take every third sample. Great, but how on earth do I do that? How do I make sphinx get along with 48KHz sampling? I've googled without much luck, and the FAQ had a two line explanation that left me just as confused.

     
    • Anonymous

      Anonymous - 2004-03-25

      First of all, see if you can find out how to induce your a/d to sample the input signal at 16000 samples/second rather than 48000.  There is no effective way to "make sphinx get along" with 48 kHz sampling.

      Failing that, the solution is to insert some code (in ad_read, for example) to downsample that 48 kHz signal to the 16 kHz rate that Sphinx can work with.

      As a DSP engineer, I must comment that the "take every third sample" approach mentioned in the FAQ is but a quick&dirty method, with the downside that any signal components in the 8-24 kHz part of the spectrum will be folded into the 0-8 kHz signal that results, thus adding some contamination of the signal.  The good news is that there isn't very much energy in that region, but the bad news is that there is some, especially in fricatives such as "s", "f", etc.  The kosher way is to low-pass-filter the original signal to suppress the 8-24 kHz components before doing the 3-to-1 downsampling.

      That said, the 3-to-1 downsampling is simple.  In ad_read, for example, you have a buffer 'buf' of 'length' int16 samples.  Make a new output buffer 'buf2' as:
          for (i = 0; i < length; i +=3]
              buf2[i/3] = buf[i];
      The caveat with the above is that 'length' won't generally be a multiple of 3, so you have to store any leftover buf[] samples between calls so that the strict  "take every 3rd sample" regime is maintained.

      cheers,
        jerry

       
      • Anonymous

        Anonymous - 2004-03-25

        Just noticed a bug in the code fragment in my earlier message.  In the specific case of ad_read(), 'length' is the number of bytes, so the number of samples must be (length/handle->bps).  But you get the idea: take 1, throw away 2, take 1, throw away 2, ...

         
    • James Trienfo

      James Trienfo - 2004-03-25

      Any thoughts on what files and utilities I might use to tweak my sound card down to that sampling rate? Any way to force it using aRTS?

       
      • Jia Pu

        Jia Pu - 2004-03-25

        The easiest way is not twisting sound card. Instead, twist your recorded audio.

        There are a couple of open source audio lib to do resampling. But I couldn't recall their names at this point.

        Try "SOX".

         

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.