Menu

PocketSphinx for Absolute Beginners!

Help
2012-05-01
2012-09-22
  • Tracy Martinez

    Tracy Martinez - 2012-05-01

    Hello. I have downloaded and compiled PocketSphinx on my Windows7
    successfully. However, I am having trouble understanding where to go next. I
    have a C++ program that I want to be able to add voice control to. I tried
    adding in the code at the bottom of the tutorial page http://cmusphinx.source
    forge.net/wiki/tutorialpocketsphinx
    :

    include <pocketsphinx.h></pocketsphinx.h>

    int
    main(int argc, char argv)
    {
    ps_decoder_t
    ps;
    cmd_ln_t config;
    FILE
    fh;
    char const hyp, uttid;
    int16 buf;
    int rv;
    int32 score;

    config = cmd_ln_init(NULL, ps_args(), TRUE,
    "-hmm", MODELDIR "/hmm/en_US/hub4wsj_sc_8k",
    "-lm", MODELDIR "/lm/en/turtle.DMP",
    "-dict", MODELDIR "/lm/en/turtle.dic",
    NULL);
    if (config == NULL)
    return 1;
    ps = ps_init(config);
    if (ps == NULL)
    return 1;

    fh = fopen("goforward.raw", "rb");
    if (fh == NULL) {
    perror("Failed to open goforward.raw");
    return 1;
    }

    rv = ps_decode_raw(ps, fh, "goforward", -1);
    if (rv < 0)
    return 1;
    hyp = ps_get_hyp(ps, &score, &uttid);
    if (hyp == NULL)
    return 1;
    printf("Recognized: %s\n", hyp);

    fseek(fh, 0, SEEK_SET);
    rv = ps_start_utt(ps, "goforward");
    if (rv < 0)
    return 1;
    while (!feof(fh)) {
    size_t nsamp;
    nsamp = fread(buf, 2, 512, fh);
    rv = ps_process_raw(ps, buf, nsamp, FALSE, FALSE);
    }
    rv = ps_end_utt(ps);
    if (rv < 0)
    return 1;
    hyp = ps_get_hyp(ps, &score, &uttid);
    if (hyp == NULL)
    return 1;
    printf("Recognized: %s\n", hyp);

    fclose(fh);
    ps_free(ps);
    return 0;
    }

    One of my questions is, when I downloaded the binary version, there is no
    "pocketsphinx.h" file, but this code requires that header. So maybe this is
    not the right code I should be using. I just want to run the binary from my
    c++ program on Windows7. What am I doing wrong?

    Thanks,

    Tracy

     
  • Nickolay V. Shmyrev

    One of my questions is, when I downloaded the binary version, there is no
    "pocketsphinx.h" file, but this code requires that header.

    For development (to compile sample application) you need source distribution,
    not binary. Binary distribution is needed if you just want to run the
    application which requires pocketsphinx. However, it's a good idea to include
    pocketsphinx.h into the binary distribution too

    So maybe this is not the right code I should be using.

    Code is correct, you just need to configure the project settings to add a
    folder containing pocketsphinx.h as an additional include file search folder.
    It's done in project properties. Pocketsphinx.h is inside source code
    distribution.

     
  • Tracy Martinez

    Tracy Martinez - 2012-05-02

    I think I just want to run the binary. But I'm not sure. For my application, I
    want to have a speech recognizer, that spits out strings that I can parse into
    some logic functions to make certain actions happen. Also, I need to change
    the grammar model, just a bit. Can that be done with just the binary?

     
  • Nickolay V. Shmyrev

    Can that be done with just the binary?

    No

     
  • Tracy Martinez

    Tracy Martinez - 2012-05-04

    So let me start over. So I am starting a new program with just the "main.cpp"
    file above. So how do I add pocketsphinx to my program? Do I add the
    executables and library from the pocketsphinx that I compiled, or do I add the
    distribution code to my code and compile it together. Sorry for the questions.
    I've been working on other IDE's and languages for a while and I'm a little
    rusty with Microsoft Visual C++. Thanks.

     
  • Nickolay V. Shmyrev

    So how do I add pocketsphinx to my program? Do I add the executables and
    library from the pocketsphinx that I compiled, or do I add the distribution
    code to my code and compile it together.

    You can learn more about development in VS using external libraries from MSDN:

    http://msdn.microsoft.com/en-
    us/library/ms235636.aspx

     

Log in to post a comment.