gpt4 book ai didi

java - 接收 JSGF Gramma 规则名称

转载 作者:太空宇宙 更新时间:2023-11-04 11:28:00 25 4
gpt4 key购买 nike

我创建了一个语法

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

有没有办法获取可识别的语法规则名称?问候

最佳答案

没有办法做到这一点。如果您想执行语义分析,您可以简单地使用正则表达式解析语音识别器的输出。另请参阅

How do you retrieve tags from JSGF grammars using sphinx?

Why tags are not supported in pocketsphinx?

关于java - 接收 JSGF Gramma 规则名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44136918/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com