首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Sphinx 4-控制台

Sphinx 4-控制台
EN

Stack Overflow用户
提问于 2013-02-14 02:36:14
回答 1查看 418关注 0票数 0

我对java中的Sphinx 4有一点问题。我实现了下面的代码:

代码语言:javascript
复制
package test.ionut;

import edu.cmu.sphinx.frontend.util.Microphone;
import edu.cmu.sphinx.recognizer.Recognizer;
import edu.cmu.sphinx.result.Result;
import edu.cmu.sphinx.util.props.ConfigurationManager;


public class Test {

    /**
     * @param args
     */
    public static void main(String[] args) {
        ConfigurationManager manager;

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

            manager=new ConfigurationManager(Test.class.getResource("test.config.xml"));

        }

        Recognizer recognizer=(Recognizer)manager.lookup("recognizer");
        recognizer.allocate();
        Microphone mic=(Microphone)manager.lookup("microphone");
        if(!mic.startRecording()){

            System.out.println("Mic not identified.");
            recognizer.deallocate();
            System.out.println(1);

            System.out.println("Say: (Good morning | Hello | Hi | Welcome) (Dipayan | Paul | Philip | Rita | Will )");

            while(true){
                System.out.println("Start speaking. Press Ctrl-C to quit.\n");
                Result result = recognizer.recognize();
                if(result != null) {
                String resultText = result.getBestFinalResultNoFiller();
            //  System.out.println((new StringBuilder()).append("You said: ").append(resultText).append('\n').toString());
                System.out.println("You said: "+resultText+"...");
                } else {
                System.out.println("I can't hear what you said.\n");
                }
                }

        }


    }

}

this is the grammar file:

***#JSGF V1.0;***

***grammar hello;***

***public <greet>= (Good morning | Hello | Hi | Welcome) ( Paul | Philip | Rita | Will );***

and in the xml file i have modified so that the program knows what to do with the gram file.



Bellow is the part of the code where i modified the xml:

    <!-- ******************************************************** -->
    <!-- The Grammar  configuration                               -->
    <!-- ******************************************************** -->

    <component name="jsgfGrammar" type="edu.cmu.sphinx.jsgf.JSGFGrammar">
        <property name="dictionary" value="dictionary"/>
        <property name="grammarLocation"
             value="resource:/test/ionut/"/>
        <property name="grammarName" value="mydict"/>
    <property name="logMath" value="logMath"/>
    </component>


Any help is appreciated.

问题是,当我编译代码时,我没有得到任何错误,但是控制台没有显示任何东西,甚至第一次打印也没有。如果我通过添加字典中没有的单词来修改gram文件,然后单击run,控制台会显示一个错误,表明该单词是字典中的已知单词。删除该单词后,单击run,然后再次单击:控制台没有显示任何内容。此外,我还使用-mx256m参数添加了额外的堆内存。

我已经尝试了一整天,因为我想用sphinx 4实现我自己语言中的单词,但现在我只是在做一些测试,开始使用它。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-02-14 02:46:13

你是通过麦克风说话的吗,你放在语法文件里的那些单词?或者只是随便说几句话。系统只能识别语法文件和词典中的那些单词。请记住,.gram文件是。DIC文件。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/14860579

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档