raspberry-pi2 - 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.
解决方案
在 C 中,字符串与 进行比较strcmp
,而不是与=
,=
您只需分配指针,甚至不比较它们。
它应该是
if (strcmp(hyp, "OPEN") == 0) {
....
}
推荐阅读
- python - Keras 自定义损失函数导致 TypeError
- flutter - Accessing OS-Level APIs with Flutter
- c - 我无法在 C 中执行某些输入
- python - 为什么 pygame 不显示我的图像或棋盘?
- reactjs - 为什么 getDerivedStateFromProps 每次调用两次
- c++ - std::vector::reserve 允许在 push_back 之前进行随机访问
- c - 卸载功能的另一个问题,节点设置为 null 正在以某种方式重新填充
- ffmpeg - 使用ffmpeg将vobsubs刻录到MP4时设置半透明框
- python - 奇怪的填充层输出
- php - Laravel,数据更新错误。没有错误提示,但是数据没有插入数据库