Search code examples
javaccmusphinxsphinx4pocketsphinx

Failed to load en-us-semi model in sphinx4


I've recently been tasked with rewriting a C server in Java, which has meant migrating its speech recognition capabilities from the Pocketsphinx C api over to the Sphinx4 Java API, using the same dictionary and language model files as those that were working with Pocketsphinx plus the default en-us-semi acoustic model provided by CMU Sphinx on their site. One note: no acoustic model was required for using Pocketsphinx, so I chose the en-us-semi model thinking that it would be satisfactory for my needs. In doing so, I'm getting an error while initializing a StreamSpeechRecognizer as a Spring bean with this code:

@Bean
@Autowired
public StreamSpeechRecognizer streamSpeechRecognizer(SphinxProperties sphinxProperties) throws
                                                                                      IOException {
edu.cmu.sphinx.api.Configuration sphinxConfiguration = new edu.cmu.sphinx.api.Configuration();
sphinxConfiguration.setAcousticModelPath("resource:/" + sphinxProperties.getAcousticModelPath());
sphinxConfiguration.setDictionaryPath("resource:/" +  sphinxProperties.getDictionaryPath());
sphinxConfiguration.setLanguageModelPath("resource:/" + sphinxProperties.getLanguageModelPath());

return new StreamSpeechRecognizer(sphinxConfiguration);

}

The error I am getting follows:

Caused by: java.lang.AssertionError
at edu.cmu.sphinx.linguist.acoustic.tiedstate.Sphinx3Loader.createSenonePool(Sphinx3Loader.java:484)
at edu.cmu.sphinx.linguist.acoustic.tiedstate.Sphinx3Loader.loadModelFiles(Sphinx3Loader.java:386)
at edu.cmu.sphinx.linguist.acoustic.tiedstate.Sphinx3Loader.load(Sphinx3Loader.java:315)
at edu.cmu.sphinx.frontend.AutoCepstrum.newProperties(AutoCepstrum.java:118)
at edu.cmu.sphinx.util.props.PropertySheet.getOwner(PropertySheet.java:508)

It is thrown by the StreamSpeechRecongizer's constructor.

The assertion failing is assert numVariances == numSenones * numGaussiansPerSenone;

Also, it may be useful for you to know that the dictionary file I am using contains ordinary English words like potato alongside Internet service names, like Hotmail, Facebook, Twitter, and so on.

Any help would be hugely appreciated from you all. Thank you very much.


Solution

  • You need to use latest version of sphinx4-5prealpha as described in http://cmusphinx.sourceforge.net/wiki/tutorialsphinx4

    It goes with default en-us generic ptm 5.2 model, the most accurate model available. You need to use that default sphinx4 model, not en-us semi. Latest pocketsphinx works with the same model.

    en-us-semi is not supported by sphinx4