1
私は、単純なSphinx4の音声認識でそれを使用していると私はプログラムの回答のための基本的なロジックを作成しようとしていgramma受信JSGF Grammaルール名
#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");
? よろしくお願いします。