Menu

Shinx 4 Helloworld runtime errors

Help
Josh
2008-02-22
2012-09-22
  • Josh

    Josh - 2008-02-22

    Hey all. I'm trying to compile hello world and run it from a different directory so that I can start building my application. I'm having trouble getting it to work though. I copied HellWorld.java to myProject/java/source and I copied hello.gram and helloworld.config.xml to myProject/java/classes/demo/sphinx/helloworld. I have not yet edited HelloWorld.java at all. I can't seem to figure out what the problem is and I would greatly appreciate some help (I'm sure it's something stupid).

    My ant build file is copied at the end of this post. I'm not using an IDE (just jedit), and when compiling and running the original demo from the install directory it works fine. When I run ant it compiles and jar's everything just fine. I checked the project.jar archive with 7zip and it says it appears to have everything it needs. Nevertheless when I run the program (using java -mx200m -jar bin/project.jar) I get a bunch of errors. I've included below 1)the file tree, 2) the ant build file, 3) the output of the "ant" command, and 4)the output of running the executable.

    I would greatly appreciate some help in diagnosing the problem so that I can get to work on my project. I'm excited that an open source speech recognizer exists though I'm a little confused by how to use it. It seems simple enough but...

    1) file tree

    ..\java

    │ build.xml

    ├───bin
    │ sui.jar

    ├───classes
    │ └───demo
    │ └───sphinx
    │ └───helloworld
    │ hello.gram
    │ HelloWorld.class
    │ helloworld.config.xml

    └───source
    hello.gram
    helloworld.config.xml
    HelloWorld.java
    helloworld.Manifest

    2) Ant build.xml

    <?xml version="1.0" encoding="UTF-8"?>

    <project basedir="." default="CreateExecutableJar" name="SUI">
    <property name="src_dir" value="./source"/>
    <property name="class_dir" value="./classes"/>
    <property name="bin_dir" value="./bin"/>
    <property name="sphinx_dir" value="C:/sphinx/lib"/>

    &lt;target name=&quot;CreateExecutableJar&quot; depends=&quot;CompileClasses&quot; &gt;
        &lt;jar destfile=&quot;${bin_dir}/Sui.jar&quot;&gt;
            &lt;zipfileset dir=&quot;${class_dir}&quot; prefix=&quot;&quot; /&gt;
            &lt;zipfileset src=&quot;${sphinx_dir}/jsapi.jar&quot; /&gt;
            &lt;zipfileset src=&quot;${sphinx_dir}/sphinx4.jar&quot; /&gt;
            &lt;zipfileset src=&quot;${sphinx_dir}/tags.jar&quot; /&gt;
            &lt;zipfileset src=&quot;${sphinx_dir}/js.jar&quot; /&gt;
            &lt;manifest&gt;
                &lt;attribute name=&quot;Main-Class&quot; value=&quot;demo.sphinx.helloworld.HelloWorld&quot; /&gt;
            &lt;/manifest&gt;
        &lt;/jar&gt;
        &lt;echo&gt;Jar created&lt;/echo&gt;
    &lt;/target&gt;
    
    &lt;target name=&quot;CompileClasses&quot;&gt;
        &lt;javac debug=&quot;true&quot;
               source=&quot;1.4&quot;
               listfiles=&quot;true&quot;
               deprecation=&quot;true&quot;
               srcdir=&quot;${src_dir}&quot;
               destdir=&quot;${class_dir}&quot;
               classpath=&quot;  ${sphinx_dir}/jsapi.jar; 
                            ${sphinx_dir}/sphinx4.jar; 
                            ${sphinx_dir}/tags.jar; 
                            ${sphinx_dir}/js.jar&quot;&gt;
        &lt;/javac&gt;
        &lt;echo&gt;Classes Compiled&lt;/echo&gt;
    &lt;/target&gt;
    

    </project>

    3) Output of ant

    C:...\java>ant
    Buildfile: build.xml

    CompileClasses:
    [javac] Compiling 1 source file to C:...\java\classes
    [javac] C:...\java\source\HelloWorld.java
    [echo] Classes Compiled

    CreateExecutableJar:
    [jar] Building jar: C:...\java\bin\Sui.jar
    [echo] Jar created

    BUILD SUCCESSFUL
    Total time: 2 seconds

    4) output of program (errors)

    C:...\java>java -mx200m -jar bin/Sui.jar
    Loading...
    Exception in thread "main" java.lang.NullPointerException
    at edu.cmu.sphinx.model.acoustic.WSJ_8gau_13dCep_16k_40mel_130Hz_6800Hz.ModelLoader.loadProp
    erties(ModelLoader.java:372)
    at edu.cmu.sphinx.model.acoustic.WSJ_8gau_13dCep_16k_40mel_130Hz_6800Hz.ModelLoader.getIsBin
    aryDefault(ModelLoader.java:386)
    at edu.cmu.sphinx.model.acoustic.WSJ_8gau_13dCep_16k_40mel_130Hz_6800Hz.ModelLoader.newPrope
    rties(ModelLoader.java:346)
    at edu.cmu.sphinx.util.props.ConfigurationManager.lookup(ConfigurationManager.java:214)
    at edu.cmu.sphinx.util.props.ValidatingPropertySheet.getComponent(ValidatingPropertySheet.ja
    va:403)
    at edu.cmu.sphinx.model.acoustic.WSJ_8gau_13dCep_16k_40mel_130Hz_6800Hz.Model.newProperties(
    Model.java:159)
    at edu.cmu.sphinx.util.props.ConfigurationManager.lookup(ConfigurationManager.java:214)
    at edu.cmu.sphinx.util.props.ValidatingPropertySheet.getComponent(ValidatingPropertySheet.ja
    va:403)
    at edu.cmu.sphinx.linguist.flat.FlatLinguist.setupAcousticModel(FlatLinguist.java:299)
    at edu.cmu.sphinx.linguist.flat.FlatLinguist.newProperties(FlatLinguist.java:246)
    at edu.cmu.sphinx.util.props.ConfigurationManager.lookup(ConfigurationManager.java:214)
    at edu.cmu.sphinx.util.props.ValidatingPropertySheet.getComponent(ValidatingPropertySheet.ja
    va:403)
    at edu.cmu.sphinx.decoder.search.SimpleBreadthFirstSearchManager.newProperties(SimpleBreadth
    FirstSearchManager.java:180)
    at edu.cmu.sphinx.util.props.ConfigurationManager.lookup(ConfigurationManager.java:214)
    at edu.cmu.sphinx.util.props.ValidatingPropertySheet.getComponent(ValidatingPropertySheet.ja
    va:403)
    at edu.cmu.sphinx.decoder.Decoder.newProperties(Decoder.java:71)
    at edu.cmu.sphinx.util.props.ConfigurationManager.lookup(ConfigurationManager.java:214)
    at edu.cmu.sphinx.util.props.ValidatingPropertySheet.getComponent(ValidatingPropertySheet.ja
    va:403)
    at edu.cmu.sphinx.recognizer.Recognizer.newProperties(Recognizer.java:93)
    at edu.cmu.sphinx.util.props.ConfigurationManager.lookup(ConfigurationManager.java:214)
    at demo.sphinx.helloworld.HelloWorld.main(HelloWorld.java:49)

    C:...\java>

     
    • Josh

      Josh - 2008-02-22

      P.S. Sorry for the poor formatting. For some reason I figured the forum would preserve spaces. I can post files if it is necessary.

       
    • Nickolay V. Shmyrev

      I don't see you add the model jar WSJ_8gau_13dCep_8kHz_31mel_200Hz_3500Hz.jar into classpath nor it's packed into jar. Where is it?

       
      • Josh

        Josh - 2008-02-22

        And.... There it is. Thanks so much Nickolay. WSJ_8gau_13dCep_16k_40mel_130Hz_6800Hz.jar was actually the one I needed. It was in the library path along with the other .jar's. I only added the jar's I noticed in the original demos.xml ant build file. I must have missed that one or else it's requirement is hidden in the configuration file. I'm still not 100% on how the configuration manager works or why it is necessary (but I trust those CMU guys know what they're doing). Once I added the line <zipfileset src="${sphinx_dir}/WSJ_8gau_13dCep_16k_40mel_130Hz_6800Hz.jar" /> the program runs correctly.

        Thanks again.

         

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.