如何查看词在Pocketsphinx字典中是否存在? [英] How to see if word exists in Pocketsphinx dictionary?
问题描述
我只想看看字典文件中是否存在字符串。 (问题底部的字典文件)
我想检查语音识别器是否能识别字词。例如,识别器将不能识别 ahdfojakdlfafiop
的字符串,因为这在字典中没有定义。 我可以检查pocktsphinx字典中的字词吗?
I want to check if the voice recognizer can recognize a word or not. For example, the recognizer will not be able to recognize a string of ahdfojakdlfafiop
, because that is not defined in the dictionary. So, can I check if a word is in the dictionary of pocktsphinx?
像:
if(myString.existsInDictionary){
startListeningBecauseExists();
}else(
//Doesn't exist in dictionary!!!
}
b $ b
我只想要一种能够识别识别器能否听我想听的内容的方法。
I just want a way to be able to tell if the recognizer can listen for what I want it to listen to.
这里是字典文件:
感谢,
Ruchir
推荐答案
在C中有 ps_lookup_word 函数,它允许您查找字词:
In C there is ps_lookup_word function which allows you to lookup for the word:
if (ps_lookup_word(ps, "abc") == NULL) {
// do something
}
在Java封装中,它是一个方法 Decoder.lookupWord
:
In Java wrapper it's a method Decoder.lookupWord
:
if(decoder.lookupWord("abc") == null) {
// do something
}
b $ b
在Android中,您可以从识别器
访问解码器:
if(recognizer.getDecoder().lookupWord("abc") == null) {
// do something
}
这篇关于如何查看词在Pocketsphinx字典中是否存在?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!