如何修改 pocketsphinx continuous.c
how to modify pocketsphinx continuous.c
我试图让检测到的单词执行 file.py。
这是我尝试在 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);
}
程序仍然检测到这个词,但它仍然没有执行我想要的程序。
这是我使用的命令
pocketsphinx_continuous -lm /home/pi/project/3379.lm -dict /home/pi/project/3379.dic -samprate 16000/8000/48000 -inmic yes -adcdev plughw:1,0
这里真的需要帮助。先谢谢了。
在 C 中,字符串与 strcmp
进行比较,而不是与 =
进行比较,而与 =
相比,您只是分配指针,甚至不比较它们。
应该是
if (strcmp(hyp, "OPEN") == 0) {
....
}
我试图让检测到的单词执行 file.py。 这是我尝试在 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);
}
程序仍然检测到这个词,但它仍然没有执行我想要的程序。 这是我使用的命令
pocketsphinx_continuous -lm /home/pi/project/3379.lm -dict /home/pi/project/3379.dic -samprate 16000/8000/48000 -inmic yes -adcdev plughw:1,0
这里真的需要帮助。先谢谢了。
在 C 中,字符串与 strcmp
进行比较,而不是与 =
进行比较,而与 =
相比,您只是分配指针,甚至不比较它们。
应该是
if (strcmp(hyp, "OPEN") == 0) {
....
}