Menu

NullPointer Exception (at AbstractScorer)

Help
2009-06-08
2012-09-22
  • Mauricio Olaya

    Mauricio Olaya - 2009-06-08

    I am having the same problem with the NullPointer Exception, exactly the same output posted in your comment, but the answer in there did not solve my problem. What I am trying to do is to transcribe from a Wav file. However I would like to use WSJ and not TIDIGITS as in WavFile.

    So what I have done is
    1) change the HelloWorld demo. by including AudioFiledatasource and a Wav file at root C:.
    2) Then I change the Frontend pipe line as Nickolay suggested (from the transcriber demo), basically I copy/paste from the Transcriber config to the HelloWorld config.

    3) the Wav file I am using is the 12345 from WavFile. that is, I copy it and paste it at C:. I changed its name. What I want to be sure is that I can read any file of my own... but using a different acoustic model (WSJ).

    Could you please tell me

    1) if using the HUB4 is required to obtain recognition results? I know that it is for testing and I am not interesting in doing so. still I would like to be sure that by omiting it I am not missing a fundamental step to obtain results. I ask this question because Kelly mentioned it when she posted her question.
    I however did not use any test, in particular I have not run the HUB4.

    2) are the changes I have made to the HelloWorld ok? I mean, I know I am importing more than what I need but apart from that do you think that the file is being read? and the necessary code is there to get timedresults?

    3) What do you think is the reason for the Exception in thread "main" java.lang.NullPointerException
    at edu.cmu.sphinx.decoder.scorer.AbstractScorer.startRecognition(AbstractScorer.java:116)
    at edu.cmu.sphinx.decoder.search.SimpleBreadthFirstSearchManager.startRe
    cognition(SimpleBreadthFirstSearchManager.java:158)
    at edu.cmu.sphinx.decoder.Decoder.decode(Decoder.java:44)
    at edu.cmu.sphinx.recognizer.Recognizer.recognize(Recognizer.java:98)
    at edu.cmu.sphinx.recognizer.Recognizer.recognize(Recognizer.java:114)
    at edu.cmu.sphinx.demo.helloworld.HelloWorld.main(HelloWorld.java:53)

    next i post the modified java file for my project (The only change to config was to bring the frontend from Transcriber):

    package edu.cmu.sphinx.demo.helloworld;

    import edu.cmu.sphinx.frontend.util.AudioFileDataSource;
    import edu.cmu.sphinx.recognizer.Recognizer;
    import edu.cmu.sphinx.result.Result;
    import edu.cmu.sphinx.util.props.ConfigurationManager;
    import edu.cmu.sphinx.frontend.util.StreamDataSource;
    import java.io.FileInputStream;
    import java.io.File;
    import java.io.*;
    import java.net.MalformedURLException;
    import java.net.URL;
    public class HelloWorld {
    public static void main(String[] args) throws FileNotFoundException {

    //URL audioFileURL;

    URL configURL;
    ConfigurationManager cm ;

    if (args.length > 0) {
    cm = new ConfigurationManager(args[0]);
    } else {

    cm = new ConfigurationManager(HelloWorld.class.getResource("helloworld.config.xml"));
    }

    String audioFile = "C:/test.wav"; // Put your file name here
    StreamDataSource source = (StreamDataSource) cm.lookup ("streamDataSource");
    source.setInputStream(new FileInputStream(audioFile), audioFile);
    // String audioFileURL = "C:/test.wav"; // Put your file name here
    Recognizer recognizer = (Recognizer) cm.lookup("recognizer");
    recognizer.allocate();

    AudioFileDataSource dataSource = (AudioFileDataSource) cm.lookup("audioFileDataSource");

    //dataSource.setAudioFile(audioFileURL, null);
    System.out.println("ejecutando mao");
    Result result = recognizer.recognize();
    System.out.println("Result: " + (result != null ? result.getBestFinalResultNoFiller() : null));

    System.out.println("Result: " + (result != null ? result.getTimedBestResult( false, true) : null));
    }
    }

    Mauricio Olaya

     
    • Nickolay V. Shmyrev

      > 1) if using the HUB4 is required to obtain recognition results?

      No, you can use any acoustic model

      > 2) are the changes I have made to the HelloWorld ok?

      No, since you can't run it

      > 3) What do you think is the reason for the Exception in thread "main"

      You commented out the line

      //dataSource.setAudioFile(audioFileURL, null);

      I'm don't understand why, you should setup the input component of pipeline to read the file to decode. I also suggest you to read carefully the programming manual to understand what you are doing:

      http://cmusphinx.sourceforge.net/sphinx4/doc/ProgrammersGuide.html

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.