我想在Sphinx4中使用我自己的gram文件或hello world demo更新的gram文件

时间:2015-11-18 17:35:15

标签: java cmusphinx sphinx4

实际上,hello world演示示例有几个单词,但我想在其中添加更多单词。它似乎可以采取两种方式。 1.更新hello.gram文件 2.创建我自己的gram文件。 但问题是我无法做到这两种方式。你能帮帮我吗?谢谢你的时间。抱歉英文不好。

这是我更新的hello.gram文件。我没有更新其他文件。请帮帮我这个。 hello.gram文件

import java.util.Scanner;

public class DivideByTwoLoop {
   public static void main (String [] args) {
      int userNum = 0;

      userNum = 20;

      while ( (userNum % 2) > 1){
         userNum = userNum / 2;
         System.out.println(userNum );
      }

      System.out.println("");

      return;
   }
}

我添加了'是''否'并且' Yummy'在我的.gram文件中。

hello.config.xml(此文件中的jsgf语法配置部分)

#JSGF V1.0;



/**
* JSGF Grammar for Hello World example
*/

grammar hello;

public <greet> = (Good morning | Hello | Yes | No | Yummy) ( Bhiksha | Evandro | Paul | Philip | Rita | Will );

1 个答案:

答案 0 :(得分:0)

您发布的文件不是有效的JSGF文件。这部分

&#13;
&#13;
<!-- ******************************************************** -->
<!-- The Grammar  configuration                               -->
<!-- ******************************************************** -->

<component name="jsgfGrammar" type="edu.cmu.sphinx.jsapi.JSGFGrammar">
    <property name="dictionary" value="dictionary"/>
    <property name="grammarLocation" 
         value="resource:/demo.sphinx.helloworld.elloWorld!/demo/sphinx/helloworld/"/>
    <property name="grammarName" value="hello"/>
<property name="logMath" value="logMath"/>
</component>
&#13;
&#13;
&#13;

来自配置文件。