Menu

Cross-compile a C file using pocketsphinx

Help
Tayeb
2019-05-08
2019-05-08
  • Tayeb

    Tayeb - 2019-05-08

    Hello
    i want to cross-compile my C file but i have a problem with model dir , i used an example from the tuto in the web site of sphinx :

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

    int
    main(int argc, char argv[])
    {
    ps_decoder_t
    ps; // the decoder ( engine )
    cmd_ln_t config; // configuration object
    FILE
    fh;
    char const hyp, uttid; // l'hypothese de mot et ID de stream de parole %
    int16 buf[512]; //la parole est parser dans des buf de 512
    int rv; // id de la parti
    int32 score;

    config = cmd_ln_init(NULL, ps_args(), TRUE,
                 "-hmm", "/usr/local/share/pocketsphinx/model/en-us/cmudict-en-us.dict",
                 "-lm", "/usr/local/share/pocketsphinx/model/en-us/8888.lm.bin",          // les dict / lm / hmm ---> model dir = dossier cdu modelle
                 "-dict",  "/usr/local/share/pocketsphinx/model/en-us/8888.dict",
                 NULL);
    if (config == NULL) {
    fprintf(stderr, "Failed to create config object, see log for details\n");
    return -1;
    }
    
    ps = ps_init(config);                               // ajouter le model au decodeur 
    if (ps == NULL) {
    fprintf(stderr, "Failed to create recognizer, see log for details\n");
    return -1;
    }
    
    // fichier a parser , le input file 
    fh = fopen("light.raw", "rb");          
    if (fh == NULL) {
    fprintf(stderr, "Unable to open input file goforward.raw\n");
    return -1;
    }
    
    rv = ps_start_utt(ps);                              //read audio data from a source and feed it to the decoder
    
    while (!feof(fh)) {
    size_t nsamp;
    nsamp = fread(buf, 2, 512, fh);
    rv = ps_process_raw(ps, buf, nsamp, FALSE, FALSE);  // //read 512 samples at a time from the file, and feed them to the decoder
    }
    
    rv = ps_end_utt(ps);                                // fin de stream parole : mark the end of the utterence = paroles
    hyp = ps_get_hyp(ps, &score);                       // on donne l'hypothese de la mot identifier 
    printf("Recognized: %s\n", hyp);
    // ou bien send it to the server json RPC 
    //-------------> donc hyp est une chaine de caractere constante qui contient la commande , return , mettre dans un fichier or what ever 
    fclose(fh);
    ps_free(ps);
    cmd_ln_free_r(config);
    
    return 0;
    

    }
    and for the make file is in attachement

     
    • Nickolay V. Shmyrev

      What is the problem exactly? You are not quite clear.

       

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.