cmusphinx / sphinx4

Pure Java speech recognition library
cmusphinx.sourceforge.net
Other
1.41k stars 586 forks source link

NullPointerException crushes Sphinx on limited vocabulary #51

Closed agur closed 8 years ago

agur commented 8 years ago

edu.cmu.sphinx.frontend.feature.LiveCMN#sum was missing which resulted in NPEs in some cases.

Exception in thread "main" java.lang.NullPointerException
    at edu.cmu.sphinx.frontend.feature.LiveCMN.normalize(LiveCMN.java:203)
    at edu.cmu.sphinx.frontend.feature.LiveCMN.getData(LiveCMN.java:182)
    at edu.cmu.sphinx.frontend.feature.AbstractFeatureExtractor.getNextData(AbstractFeatureExtractor.java:125)
    at edu.cmu.sphinx.frontend.feature.AbstractFeatureExtractor.getData(AbstractFeatureExtractor.java:101)
    at edu.cmu.sphinx.frontend.feature.FeatureTransform.getData(FeatureTransform.java:85)
    at edu.cmu.sphinx.frontend.FrontEnd.getData(FrontEnd.java:222)
    at edu.cmu.sphinx.decoder.scorer.SimpleAcousticScorer.getNextData(SimpleAcousticScorer.java:146)
    at edu.cmu.sphinx.decoder.scorer.SimpleAcousticScorer.calculateScoresAndStoreData(SimpleAcousticScorer.java:104)
    at edu.cmu.sphinx.decoder.search.WordPruningBreadthFirstLookaheadSearchManager.scoreFastMatchTokens(WordPruningBreadthFirstLookaheadSearchManager.java:286)
    at edu.cmu.sphinx.decoder.search.WordPruningBreadthFirstLookaheadSearchManager.fastMatchRecognize(WordPruningBreadthFirstLookaheadSearchManager.java:206)
    at edu.cmu.sphinx.decoder.search.WordPruningBreadthFirstLookaheadSearchManager.localStart(WordPruningBreadthFirstLookaheadSearchManager.java:244)
    at edu.cmu.sphinx.decoder.search.WordPruningBreadthFirstSearchManager.startRecognition(WordPruningBreadthFirstSearchManager.java:274)
    at edu.cmu.sphinx.decoder.Decoder.decode(Decoder.java:62)
    at edu.cmu.sphinx.recognizer.Recognizer.recognize(Recognizer.java:106)
    at edu.cmu.sphinx.recognizer.Recognizer.recognize(Recognizer.java:122)
    at edu.cmu.sphinx.api.AbstractSpeechRecognizer.getResult(AbstractSpeechRecognizer.java:60)
    at edu.cmu.sphinx.demo.transcriber.TranscriberDemo.main(TranscriberDemo.java:78)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)
agur commented 8 years ago

Filed pull request #52 - please review.

Hey @nshmyrev - seems that it was introduced in b5e4ac7. Please see if the logic is appropriate. Only made the minimum to help it not to crash. And while the tests have all passed, didn't have enough time or deep knowledge of the library to validate.

Code around the fixed logic was not straight forward, if someone got the cycles we may want to revise.

mbait commented 8 years ago

Looks good for me, but I am leaving it for @nshmyrev to accept.