title: How to improve cmuSphinx's accuracy?
body: <p>I want to use pocketShpinx to do some speech-to-text word. I have install sphinxbase and pocketSphinx. And download the acoustic model/langauge model/dictionary. Then I test the <a href="http://cmusphinx.sourceforge.net/wiki/tutorialpocketsphinx" rel="nofollow">example code</a> just like follows:</p>
  
  <pre><code>#include &lt;pocketsphinx/pocketsphinx.h&gt;
  #include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include "debug.h"
  
  int main(int argc, char *argv[])
  {
    ps_decoder_t  *ps;
    cmd_ln_t      *config;
    FILE *fh;
    int rv;
    char const *hyp, *uttid;
    int32 score;
  
    config = cmd_ln_init(NULL, ps_args(), TRUE,
                         "-hmm", "/home/madper/speech/hub4opensrc.cd_continuous_8gau",
                         "-lm",  "/home/madper/speech/language_model.arpaformat.DMP",
                         "-dict", "/home/madper/speech/cmudict/cmudict/sphinxdict/cmudict_SPHINX_40",
                         NULL);
    if (config == NULL)
      {
        DBG (("cmd_ln_init() failed.\n"));
        exit(1);
      }
    if ((ps = ps_init (config)) == NULL) /* init decoder */
      {
        DBG (("ps_init() failed.\n"));
        exit(1 );
      }
    if ((fh = fopen("test.raw", "rb")) == NULL) /* open raw file */
      {
        DBG (("fopen() failed.\n"));
        exit (1);
      }
    if ((rv = ps_decode_raw (ps, fh, "test", -1)) &lt; 0 )
      {
        DBG (("ps_decode_raw() error!\n"));
        exit (1);
      }
    if ((hyp = ps_get_hyp(ps, &amp;score, &amp;uttid)) == NULL)
      {
        DBG (("ps_get_hyp() failed!\n"));
        exit (1);
      }
    printf ("Recognized: %s\n", hyp); /* this is what you say */
  
    fclose(fh);
    ps_free(ps);
    return 0;
  }
  </code></pre>
  
  <p><code>DBG</code> is just a macro to print error message if defined DEBUG. </p>
  
  <hr>
  
  <p>Then I write some code to record from mic use alsa. Like follows:</p>
  
  <pre><code>#define ALSA_PCM_NEW_HW_PARAMS_API
  
  #include &lt;alsa/asoundlib.h&gt;
  
  int main() {
    long loops;
    int rc;
    int size;
    snd_pcm_t *handle;
    snd_pcm_hw_params_t *params;
    unsigned int val;
    int dir;
    snd_pcm_uframes_t frames;
    char *buffer;
  
    /* Open PCM device for recording (capture). */
    rc = snd_pcm_open(&amp;handle, "default",
                      SND_PCM_STREAM_CAPTURE, 0);
    if (rc &lt; 0) {
      fprintf(stderr,
              "unable to open pcm device: %s\n",
              snd_strerror(rc));
      exit(1);
    }
  
    /* Allocate a hardware parameters object. */
    snd_pcm_hw_params_alloca(&amp;params);
  
    /* Fill it in with default values. */
    snd_pcm_hw_params_any(handle, params);
  
    /* Set the desired hardware parameters. */
  
    /* Interleaved mode */
    snd_pcm_hw_params_set_access(handle, params,
                        SND_PCM_ACCESS_RW_INTERLEAVED);
  
    /* Signed 16-bit little-endian format */
    snd_pcm_hw_params_set_format(handle, params,
                                SND_PCM_FORMAT_S16_LE);
  
    /* Two channels (stereo) */
    snd_pcm_hw_params_set_channels(handle, params, 1);
  
    /* 44100 bits/second sampling rate (CD quality) */
    val = 16000;
    snd_pcm_hw_params_set_rate_near(handle, params,
                                    &amp;val, &amp;dir);
  
    /* Set period size to 32 frames. */
    frames = 16;
    snd_pcm_hw_params_set_period_size_near(handle,
                                params, &amp;frames, &amp;dir);
  
    /* Write the parameters to the driver */
    rc = snd_pcm_hw_params(handle, params);
    if (rc &lt; 0) {
      fprintf(stderr,
              "unable to set hw parameters: %s\n",
              snd_strerror(rc));
      exit(1);
    }
  
    /* Use a buffer large enough to hold one period */
    snd_pcm_hw_params_get_period_size(params,
                                        &amp;frames, &amp;dir);
    size = frames * 2; /* 2 bytes/sample, 2 channels */
    buffer = (char *) malloc(size);
  
    /* We want to loop for 5 seconds */
    snd_pcm_hw_params_get_period_time(params,
                                           &amp;val, &amp;dir);
    loops = 2000000 / val;
  
    while (loops &gt; 0) {
      loops--;
      rc = snd_pcm_readi(handle, buffer, frames);
      if (rc == -EPIPE) {
        /* EPIPE means overrun */
        fprintf(stderr, "overrun occurred\n");
        snd_pcm_prepare(handle);
      } else if (rc &lt; 0) {
        fprintf(stderr,
                "error from read: %s\n",
                snd_strerror(rc));
      } else if (rc != (int)frames) {
        fprintf(stderr, "short read, read %d frames\n", rc);
      }
      rc = write(1, buffer, size);
      if (rc != size)
        fprintf(stderr,
                "short write: wrote %d bytes\n", rc);
    }
  
    snd_pcm_drain(handle);
    snd_pcm_close(handle);
    free(buffer);
  
    return 0;
  }
  </code></pre>
  
  <p>So, I record a <a href="http://en.wikipedia.org/wiki/Raw_audio_format" rel="nofollow">raw</a> file. Then do speech-to-test on that file. But the accuracy is very vert poor. Just like <code>hello</code> or <code>go home</code> will give me <code>hotel</code> or <code>MHM MHM</code> and so on. So what's wrong with these code?
  I have read the <a href="http://cmusphinx.sourceforge.net/wiki/faq" rel="nofollow">faqs</a>, should I use acoustic model adaptation to improve accuracy?</p>
  
  <p>PS. I change stereo to mono. And the sound is strange. I can't understand what I said. So, what's wrong with it? This is that raw file <a href="http://www.madper.com/test.raw" rel="nofollow">test.raw</a></p>