如何使用sphinx从JSGF语法中检索标签? [英] How do you retrieve tags from JSGF grammars using sphinx?

查看:274
本文介绍了如何使用sphinx从JSGF语法中检索标签?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用Java编写了一个应用程序,它使用CloudGarden API来解析JSAPI语法,从语法规则中返回标记,然后相应地处理这些标记。 CloudGarden API的问题在于它依赖于Windows。我需要一个可以执行相同任务的跨平台库。我不需要语音合成,也不需要语音识别。本质上,一个字符串被传递给包含一些转录语音的程序。我需要根据我的语法文件解析这个字符串,以检索动作标记(JSGF语法规则中{}之间的文本)。然后我的程序使用检索到的动作标签来执行其他功能。

I have written an application in Java that utlizes the CloudGarden API to parse JSAPI grammars, return tags from the grammar rules and then process these tags accordingly. The issue with the CloudGarden API is its dependency on Windows. I need a cross-platform library that can perform the same task. I do not need speech synthesis nor do I need speech recognition. Essentially a string is passed to the program containing some transcribed speech. I need to parse this string against my grammar files to retrieve the action tags (the text between { } in a JSGF grammar rule). My program then uses the retrieved action tags to perform other functions.

我一直在寻找一个可以解析符合JSAPI的JSGF语法文件的免费库。我找到的唯一现实选择是语音识别引擎Sphinx / CMUSphinx。我一直在研究Sphinx,它在我们的文档中将我带到了ActionTagsParser类。我无法弄清楚如何解析语法并检索标签。任何人都可以指出我正确的方向或向我解释吗?

I have been looking for a free library that can parse JSGF grammar files that conform to JSAPI. The only realistic alternative I found was the speech recognition engine, Sphinx/CMUSphinx. I have been looking into Sphinx which brought me to the ActionTagsParser class in their documentation. I cannot figure out how to parse a grammar and retrieve the tags. Can anyone point me in the right direction or explain it to me?

谢谢你,
诺亚

Thank you, Noah

编辑:

是否需要配置Sphinx才能解析语法?在以下代码中,RuleParse始终求值为NULL。 RuleGrammar和文本有效。

Does Sphinx need to be configured for the grammars to be parsed? In the following code, RuleParse always evaluates to NULL. The RuleGrammar and text are valid.

    try {
        if(recognizer == null){
            recognizer = new BaseRecognizer();
            recognizer.allocate();
        }

        rg.setEnabled(true);
        recognizer.commitChanges();

        RuleParse p = rg.parse(text, null);
        if (p == null) {
            return null;
        }

        return p.getTags();
    } catch (Exception ex) {
        ex.printStackTrace();
        return null;
    }


推荐答案

我们删除了标签,请参阅Travis回答如下。

We removed tags, see Travis answer below.

这篇关于如何使用sphinx从JSGF语法中检索标签?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆