Java 接收JSGF语法规则名称
我创造了一个语法Java 接收JSGF语法规则名称,java,sphinx4,Java,Sphinx4,我创造了一个语法 #JSGF V1.0; /** * JSGF Grammar */ grammar grammar; public <number> = ( zero | one | two | three | four | five | six | seven | nine | ten | eleven | twelve | thirteen | fourteen | fifteen | sixteen | seventeen |
#JSGF V1.0;
/**
* JSGF Grammar
*/
grammar grammar;
public <number> = ( zero | one | two | three | four | five | six | seven | nine | ten
| eleven | twelve | thirteen | fourteen | fifteen | sixteen | seventeen | eighteen | nineteen | twenty
| thirty | forty | fifty | sixty | seventy | eighty | ninety |
hundred | thousand | million | billion)+;
public <operation> = <number>{1} (plus | minus | multiply | division){1} <number>{1};
public <greet> = ( hello | hey | hi )* world;
public <sport> = (football | tennis);
public <program> = (notepad | calculator);
public <run> = (run | open | start) <program>;
有没有办法获得公认的语法规则名称?
这是没有办法的。如果要执行语义分析,只需使用正则表达式解析语音识别器输出。另见
没有办法做到这一点。如果要执行语义分析,只需使用正则表达式解析语音识别器输出。另见
Configuration configuration = new Configuration();
//SetVoice
textToSpeech.setVoice("cmu-bdl-hsmm");
// Load model from the jar
configuration.setAcousticModelPath("resource:/edu/cmu/sphinx/models/en-us/en-us");
configuration.setDictionaryPath("resource:/edu/cmu/sphinx/models/en-us/cmudict-en-us.dict");
configuration.setGrammarPath("resource:/grammars");
configuration.setGrammarName("grammar");
configuration.setUseGrammar(true);
try {
recognizer = new LiveSpeechRecognizer(configuration);
} catch (IOException ex) {
logger.log(Level.SEVERE, null, ex);
}
// Start recognition process pruning previously cached data.
recognizer.startRecognition(true);
SpeechResult speechResult = recognizer.getResult();
if (speechResult != null) {
result = speechResult.getHypothesis();
System.out.println("You said: [" + result + "]\n");