Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSGF tag specification not supported #13

Closed
gitfoxi opened this issue Mar 21, 2015 · 14 comments
Closed

JSGF tag specification not supported #13

gitfoxi opened this issue Mar 21, 2015 · 14 comments
Milestone

Comments

@gitfoxi
Copy link

gitfoxi commented Mar 21, 2015

You're supposed to be able to do things like this:

<greeting>= (howdy | good morning) {hi};

So if i say, "howdy | good morning", it should return the text "hi". This does not appear to work.

@mbait mbait closed this as completed Mar 21, 2015
@nshmyrev nshmyrev reopened this Mar 21, 2015
@nshmyrev
Copy link
Contributor

I think we can implement it one day, but it's low priority for sure

@nshmyrev nshmyrev added this to the future milestone Mar 21, 2015
@miguelmota
Copy link

Can we expect tag support in the near future?

@nshmyrev
Copy link
Contributor

No

@dguy321
Copy link

dguy321 commented Dec 6, 2015

Is this feature available in sphinx4? Or not in any sphinx version?
It's a very powerful feature that allows creation of language agnostic speech enabled apps without needing backend nlu. Or simplifies any needed backend nlu.

@nshmyrev
Copy link
Contributor

nshmyrev commented Dec 6, 2015

We are not going to support this, we probably will even drop grammars support altogether in favor of natural language. Grammars are very complex to develop properly, it is much better to develop example-based language model than grammar.

To analyze speech recognition results you can use regular expressions, they provide equivalent of tags.

@nshmyrev nshmyrev closed this as completed Dec 6, 2015
@candrews
Copy link

candrews commented Dec 9, 2015

@nshmyrev - Could you please reconsider? JSGF support is pretty easy to add, and makes processing a whole lot easier!

http://jvoicexml.sourceforge.net/ includes a JSGF parser and it's under a compatible license, so the code can be incorporated directly into Sphinx. I copied this parser and integrated with Sphinx in my own project - please take a look and consider adding this to Sphinx itself?

https://github.com/candrews/commander/blob/master/plugins/sphinx4/src/main/java/com/integralblue/commander/plugins/sphinx4/RuleParse.java is a simple support class
https://github.com/candrews/commander/blob/master/plugins/sphinx4/src/main/java/com/integralblue/commander/plugins/sphinx4/RuleParser.java is primarily from jvoicexml, modified to reuse Sphinx instead of reimplementing everything
To use these classes:

// jsgfGrammar is a edu.cmu.sphinx.jsgf.JSGFGrammar instance that can be be retrieved using the existing Sphinx APIs
// text is a java.lang.String of the text you want to match against the grammar
RuleParse ruleParse = RuleParser.parse(text, jsgfGrammar, null);
// if ruleParse is null, then the text didn't match the grammar
// if ruleParse is not null, then you can get the name of the matched rule using ruleParse.getRuleReference().getRuleName() or the tags using ruleParse.getTags()

So really, all Sphinx needs to to add 2 classes.

@nshmyrev
Copy link
Contributor

nshmyrev commented Dec 9, 2015

Named regular expressions is a universal solution which does not depend on search module, you can use it with grammar or with language models.

string = "test 123"

regex = "(?<login>\\w+) (?<id>\\d+)"

matcher.group("login"); // test
matcher.group("id"); // 123

See for more details

https://blogs.oracle.com/xuemingshen/entry/named_capturing_group_in_jdk7

@nshmyrev
Copy link
Contributor

nshmyrev commented Dec 9, 2015

In case you need something more complex consider:

https://github.com/wit-ai/duckling

@candrews
Copy link

candrews commented Dec 9, 2015

Except with regular expressions, you have to define a grammar (so Sphinx knows what to expect) totally separately from the parser (which you're saying to do using regular expressions). That repetition is a major problem - why force all users of Sphinx to have to express their grammar in 2 different languages?

@nshmyrev
Copy link
Contributor

nshmyrev commented Dec 9, 2015

Right, and this is a reason we do not consider grammars as a future of voice interfaces. Writing a good grammar is hard and requires too many experiments. Users never follow the grammar precisely, they can repeat words, they can stop in the middle, they can say something arbitrary. And complex grammars do not increase the accuracy, users just do not follow them.

I wrote few posts on that before:

http://cmusphinx.sourceforge.net/2014/05/openears-introduces-easy-grammars-for-pocketsphinx/

Also there is a nice discussion here:

https://www.linkedin.com/groups/78206/78206-6025612581136326658

With the link to

http://videsign.wikispaces.com/How+to+Pick+Synonyms

Parsing user intent is also not a trivial thing, but I consider it has to be solved in separate module.

If you design voice user interface today, consider using language models instead of grammars.

@Kaljurand
Copy link

@candrews In my experiments with voice command applications, I found that it's better to use a richer formalism than JSGF+tags, namely Grammatical Framework (GF). GF allows you to write a single grammar that converts from natural language to some application format. Part of this grammar can be automatically converted to JSGF to constrain the recognizer. Maybe this could be a solution for you as well. See more at http://kaljurand.github.io/Grammars/

@nshmyrev
Copy link
Contributor

GS is great. Another thing to link is https://github.com/plison/opendial, which makes sense in case you look for dialog framework.

@nshmyrev
Copy link
Contributor

Interesting thing that microsoft also went away from grammars. Now they use constrains.

@Vishnu-Chittan
Copy link

which one is the best method either .lm or jsgf grammar for accurate speech recognition

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

8 participants