本文整理汇总了Java中edu.cmu.sphinx.api.Configuration.setGrammarName方法的典型用法代码示例。如果您正苦于以下问题:Java Configuration.setGrammarName方法的具体用法?Java Configuration.setGrammarName怎么用?Java Configuration.setGrammarName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类edu.cmu.sphinx.api.Configuration
的用法示例。
在下文中一共展示了Configuration.setGrammarName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initVoice
import edu.cmu.sphinx.api.Configuration; //导入方法依赖的package包/类
public void initVoice(){
if (config == 0){
configuration = new Configuration();
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
.setLanguageModelPath("resource:/edu/cmu/sphinx/models/en-us/en-us.lm.bin");
//set the path to the file "octo.gram"
configuration.setGrammarPath("file:C:/Users/Marcus/Documents/mthubrepo/PenguinUML"); //Home PC
configuration.setGrammarName("hello");
configuration.setUseGrammar(true);
config = 1;
}
else {
System.out.println("Configuration already done");
}
if (mic == 0){
try{
voiceGrammar = new LiveSpeechRecognizer(configuration);
mic = 1;
}
catch (Exception e){
System.out.println(e);
}
}
else {
System.out.println("Microphone already started");
}
}
示例2: Hearing
import edu.cmu.sphinx.api.Configuration; //导入方法依赖的package包/类
public Hearing()
{
try
{
// ToDo: Too much chatter with logging enabled. Optionally allow it later.
Logger logger = LogManager.getLogManager().getLogger("");
Handler[] handlers = logger.getHandlers();
logger.setLevel(Level.OFF);
//ConfigurationManager cm = new ConfigurationManager(url);
Configuration config = new Configuration();
config.setAcousticModelPath("resource:/lang/en-us");
config.setDictionaryPath("resource:/lang/cmudict-en-us.dict");
config.setLanguageModelPath("resource:/lang/en-us.lm.bin");
// Comment the below two lines to enable free speech detection (warning: detection is rather poor)
// Also set setUseGrammar() to false to enable free speech.
config.setGrammarPath("resource:/lang");
config.setGrammarName("default");
config.setUseGrammar(true);
recognizer = new LiveSpeechRecognizer(config);
}
catch(Exception e)
{
System.out.println("Unable to provide speech recognition: " + e);
System.exit(1);
}
}