2017-05-23 104 views
1

我創建了一個伽馬接收JSGF文法規則名稱

#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>; 

我使用它簡單Sphinx4語音識別,我要爲程序創建的答案基本邏輯。

這就是程序如何識別字(代碼片段):

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"); 

有沒有辦法獲得認可的語法規則的名字嗎? Regards

回答

相關問題