首页 > 解决方案 > how to modify pocketsphinx continuous.c

问题描述

i was trying to make word that was detected to execute file.py. here the source code that i try to modify at continuous.c

if (!in_speech && utt_started) {
        /* speech -> silence transition, time to start new utterance  */
        ps_end_utt(ps);
        hyp = ps_get_hyp(ps, NULL );
    if (hyp = "OPEN"){
        fopen("/home/pi/project/open.py", "r");
    }
        if (hyp != NULL) {
            printf("%s\n", hyp);
            fflush(stdout);
        }

the program still detect the word but it still not execute the program that i want. and here is the command that i was using

 pocketsphinx_continuous -lm /home/pi/project/3379.lm -dict /home/pi/project/3379.dic -samprate 16000/8000/48000 -inmic yes -adcdev plughw:1,0

really need help here. thanks before.

标签: raspberry-pi2pocketsphinx

解决方案


在 C 中,字符串与 进行比较strcmp,而不是与==您只需分配指针,甚至不比较它们。

它应该是

if (strcmp(hyp, "OPEN") == 0) {
  ....
}

推荐阅读