Search code examples
javacmusphinxsphinx4

Sphinx .InternalConfigurationException


Execuse me i need help how to use Sphinx4 API, i have create new maven project and i follow this link How to depend on this maven project to make pom.xml file here my pom.xml :

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.mycompany.app</groupId>
    <artifactId>my-app</artifactId>
    <packaging>jar</packaging>
    <version>1.0-SNAPSHOT</version>
    <name>my-app</name>
    <url>http://maven.apache.org</url>
    <repositories>
        <repository>
            <id>snapshots-repo</id>
            <url>https://oss.sonatype.org/content/repositories/snapshots</url>
            <releases>
                <enabled>false</enabled>
            </releases>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </repository>
    </repositories>
    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>3.8.1</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>edu.cmu.sphinx</groupId>
            <artifactId>sphinx4-core</artifactId>
            <version>1.0-SNAPSHOT</version>
        </dependency>
        <dependency>
            <groupId>edu.cmu.sphinx</groupId>
            <artifactId>sphinx4-data</artifactId>
            <version>1.0-SNAPSHOT</version>
        </dependency>
    </dependencies>
</project>

and then i am try the Sphinx DialogDemo in this Link https://github.com/cmusphinx/sphinx4/blob/master/sphinx4-samples/src/main/java/edu/cmu/sphinx/demo/dialog/DialogDemo.java but i am getting this error

------------------------------------------------------------------------
Building my-app 1.0-SNAPSHOT
------------------------------------------------------------------------

--- exec-maven-plugin:1.2.1:exec (default-cli) @ my-app ---
Exception in thread "main" Property exception component:'jsgfGrammar' property:'grammarLocation' - Can't locate resource:/edu/cmu/sphinx/demo/dialog/
edu.cmu.sphinx.util.props.InternalConfigurationException: Can't locate resource:/edu/cmu/sphinx/demo/dialog/
    at edu.cmu.sphinx.util.props.ConfigurationManagerUtils.getResource(ConfigurationManagerUtils.java:468)
    at edu.cmu.sphinx.jsgf.JSGFGrammar.newProperties(JSGFGrammar.java:228)
    at edu.cmu.sphinx.util.props.PropertySheet.getOwner(PropertySheet.java:518)
    at edu.cmu.sphinx.util.props.PropertySheet.getComponent(PropertySheet.java:296)
    at edu.cmu.sphinx.linguist.flat.FlatLinguist.newProperties(FlatLinguist.java:222)
    at edu.cmu.sphinx.util.props.PropertySheet.getOwner(PropertySheet.java:518)
    at edu.cmu.sphinx.util.props.PropertySheet.getComponent(PropertySheet.java:296)
    at edu.cmu.sphinx.decoder.search.SimpleBreadthFirstSearchManager.newProperties(SimpleBreadthFirstSearchManager.java:177)
    at edu.cmu.sphinx.util.props.PropertySheet.getOwner(PropertySheet.java:518)
    at edu.cmu.sphinx.util.props.PropertySheet.getComponent(PropertySheet.java:296)
    at edu.cmu.sphinx.decoder.AbstractDecoder.newProperties(AbstractDecoder.java:81)
    at edu.cmu.sphinx.decoder.Decoder.newProperties(Decoder.java:36)
    at edu.cmu.sphinx.util.props.PropertySheet.getOwner(PropertySheet.java:518)
    at edu.cmu.sphinx.util.props.PropertySheet.getComponent(PropertySheet.java:296)
    at edu.cmu.sphinx.recognizer.Recognizer.newProperties(Recognizer.java:86)
    at edu.cmu.sphinx.util.props.PropertySheet.getOwner(PropertySheet.java:518)
    at edu.cmu.sphinx.util.props.ConfigurationManager.lookup(ConfigurationManager.java:163)
    at edu.cmu.sphinx.api.Context.<init>(Context.java:73)
    at edu.cmu.sphinx.api.Context.<init>(Context.java:45)
    at edu.cmu.sphinx.api.AbstractSpeechRecognizer.<init>(AbstractSpeechRecognizer.java:44)
    at edu.cmu.sphinx.api.LiveSpeechRecognizer.<init>(LiveSpeechRecognizer.java:34)
    at com.mycompany.spechrecognizer.DialogDemo.main(DialogDemo.java:138)

what should i do??


Solution

  • Add required grammar resources to your project.

    Fix path to the resources in source code. If your class is com.mycompany.spechrecognizer, the resource URL is probably also resource:/com/mycompany/spechrecognizer/