I simply want to see if a string exists in a dictionary file. (Dictionary file at bottom of question)
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?
Something like:
if(myString.existsInDictionary){
startListeningBecauseExists();
}else(
//Doesn't exist in dictionary!!!
}
I just want a way to be able to tell if the recognizer can listen for what I want it to listen to.
here is the dictionary file:
Thanks,
Ruchir
In C there is ps_lookup_word function which allows you to lookup for the word:
In Java wrapper it's a method
Decoder.lookupWord
:In Android, you can access decoder from
Recognizer
:Read the file using
BufferedReader
and store all the words inArrayList
then check if word present in
dictionary
usingHope it'll help.
You could load the dictionary to a arraylist by reading it line by line and to get only the words do
arraylist.add(line.split("\\s+")[0]);
And then check if it exist by
if(arraylist.contains(word))