【发布时间】:2014-06-06 14:31:30
【问题描述】:
我在使用 pocketsphinx c 程序代码收集四位数字(个人 ID)的组合时遇到问题。我的所有其他命令都被检测到并正确运行。但我不知道如何创建一个条件语句,当检测到一串可能的四位数字组合时将选择该条件语句。 请建议我该怎么做!
printf("Processing...\n");
fflush(stdout);
/* Finish decoding, obtain and print result */
ps_end_utt(ps);
hyp = ps_get_hyp(ps, NULL, &uttid);
//printf("%s: %s\n", uttid, hyp);
fflush(stdout);
if (hyp) {
sscanf(hyp, "%s", word);
if (strcmp(hyp, "LASCHE FAHRPLAN") == 0) {
counter_correct = counter_correct + 1;
printf("LASCHE FAHRPLAN is confirmed\n");
printf("The correct number of utterances calculated %d, Total number of utterances calculated %s \n",counter_correct,uttid);
}
else if (strcmp(hyp, "LASCHE VORSCHAU") == 0) {
counter_correct = counter_correct + 1;
printf("LASCHE VORSCHAU is confirmed \n");
printf("The correct number of utterances calculated %d, Total number of utterances calculated %s \n",counter_correct,uttid);
}
同样,我想检测像 '1 2 3 4' 、 '3 7 8 9' 这样的字符串(所有可能的四位数组合) 它们也在变量 hyp [ printf("%s: %s\n", uttid, hyp); ] 我应该如何为这种情况制作条件循环。
感谢您的帮助。
【问题讨论】:
-
您的代码很难理解,请尝试澄清它。你说的数字不见了?
-
不确定你在问什么,但也许正则表达式可以做到这一点?
-
当我使用 cmu sphinx - pocketsphinx 的工具箱时,我已经针对 30 个命令集和可能的数字组合训练了我的声学模型。因此,当我在麦克风中说出这些命令时,它会输出 printf("%s: %s\n", uttid, hyp);
标签: c if-statement speech-recognition conditional-statements cmusphinx