0

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??

Community
  • 1
  • 1
syam houng
  • 307
  • 4
  • 14

1 Answers1

0

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/

Nikolay Shmyrev
  • 24,897
  • 5
  • 43
  • 87
  • thank you @barryhunter i have change resource to com/mycompany/spechrecognizer/garmmar, but i am still getting another error : – syam houng Oct 08 '15 at 04:48
  • here is my error @Nikolay Exception in thread "main" java.lang.IllegalStateException: javax.sound.sampled.LineUnavailableException: line with format PCM_SIGNED 16000.0 Hz, 16 bit, mono, 2 bytes/frame, little-endian not supported. at edu.cmu.sphinx.api.Microphone.(Microphone.java:38) at edu.cmu.sphinx.api.SpeechSourceProvider.getMicrophone(SpeechSourceProvider.java:18) at edu.cmu.sphinx.api.LiveSpeechRecognizer.(LiveSpeechRecognizer.java:35) at com.mycompany.spechrecognizer.DialogDemo.main(DialogDemo.java:142) – syam houng Oct 08 '15 at 05:01
  • `Caused by: javax.sound.sampled.LineUnavailableException: line with format PCM_SIGNED 16000.0 Hz, 16 bit, mono, 2 bytes/frame, little-endian not supported. at com.sun.media.sound.DirectAudioDevice$DirectDL.implOpen(DirectAudioDevice.java:513) at com.sun.media.sound.AbstractDataLine.open(AbstractDataLine.java:124) at com.sun.media.sound.AbstractDataLine.open(AbstractDataLine.java:416)` – syam houng Oct 08 '15 at 05:13