I'm trying to use PocketSphinx for keyword spotting inside a Java application. I've used swig to successfully build the JNI library and have a simple program that links to the libraries and will do regular speech recognition. I'm now trying to switch it to keyword mode and I'm getting the following error:
Exception in thread "main" java.lang.RuntimeException: Decoder_setSearch returned -1
at edu.cmu.pocketsphinx.PocketSphinxJNI.Decoder_setSearch(Native Method)
at edu.cmu.pocketsphinx.Decoder.setSearch(Decoder.java:181)
at pocket.DecoderTest.main(DecoderTest.java:111)
Here is my Java code that leads up to that error:
Config c = Decoder.defaultConfig();
// Setup the dictionary
c.setString("-hmm", "/home/smm/hcs/orc.trunk2/nb/Speech/resources/model/en-us");
c.setString("-lm", "/home/smm/hcs/orc.trunk2/nb/Speech/resources/model/en-us.lm.bin");
c.setString("-dict", "/home/smm/hcs/orc.trunk2/nb/Speech/resources/model/orcontrol.dict");
// Set it up to detect the key phrase
c.setString("-keyphrase", "or(3) control");
c.setFloat("-kws_threshold", 1e-1);
// Build the decoder
Decoder d = new Decoder(c);
d.setSearch("KEYPHRASE");
The error is on "d.setSearch("KEYPHRASE"). I've tried a variety of values there ("keyword", etc.), but haven't had any luck and can't find any documentation or where it is used in the code to know what values are legitimate.
What is the correct way to switch the decoder to keyword mode?
Thanks in advance.
--Stephen
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The only log I've seen is what is dumped to stderr (below). Maybe I'm missing another error message? I tried using d.setSearch("or control") and d.setSearch("or(3) control"), which match in my dictionary, but that didn't seem to make any difference.
If you want to switch between searches, you need to add them with names with decoder.setLm(..) and decoder.setKeyphrase(..), not configure through configuration.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello All,
I'm trying to use PocketSphinx for keyword spotting inside a Java application. I've used swig to successfully build the JNI library and have a simple program that links to the libraries and will do regular speech recognition. I'm now trying to switch it to keyword mode and I'm getting the following error:
Here is my Java code that leads up to that error:
The error is on "d.setSearch("KEYPHRASE"). I've tried a variety of values there ("keyword", etc.), but haven't had any luck and can't find any documentation or where it is used in the code to know what values are legitimate.
What is the correct way to switch the decoder to keyword mode?
Thanks in advance.
--Stephen
I'm still not sure I understand.
The only log I've seen is what is dumped to stderr (below). Maybe I'm missing another error message? I tried using d.setSearch("or control") and d.setSearch("or(3) control"), which match in my dictionary, but that didn't seem to make any difference.
Stderr:
Sorry, I was not reading your post in details
If you want to switch between searches, you need to add them with names with decoder.setLm(..) and decoder.setKeyphrase(..), not configure through configuration.
Thanks Nickolay for your help. I was able to get it working and detecting the key word pretty well.
For other readers, here is the solution I ended up with:
First attempt got 5 of the 6 files correct! With some further work, I think this could be good.
LM search should have different name if you want to use it. In your case keyword search replaces lm search since you give it the same name.
Also you should not configure -lm in configuration.