[asterisk-speech-rec]Troubles with grammars
Kyle Danielson
KyleDanielson at LumenVox.com
Thu Sep 7 09:31:39 MST 2006
Please post the grammar which is failing to load.
The lang directory of the LumenVox distribution contains our built in
grammars. These may be useful as a reference. I will post two full
examples below. One is ABNF SRGS and the second is the same grammar but
in GRXML SRGS.
ABNF:
#ABNF 1.0;
mode voice;
language en-US;
root $FullToppingGrammar ;
tag-format <lumenvox/1.0>;
$Filler = [and] ("I want"| "I'd like" | "Give me");
$Half = [([on] one | [and] [on] the other | and )] (half | side);
/*
* Using shortcut to assign a string to a rule
* $RULENAME = (some rule definition (may be partial) ):'This is a rule'
* is equal to
* $RULENAME = (rule definition (may be partial) ){$ = 'This is a rule'}
*/
$GreenPepper = ((green | bell) pepper) :'green pepper';
$GroundBeef = ([ground] beef):'ground beef';
$Pepperoni = (pepperoni):"pepperoni";
$Sausage = ([italian] sausage):"sausage";
$Cheese = cheese :"cheese";
$Bacon = bacon :'bacon';
$Ham = ham:"ham";
$Ingredients = ($GreenPepper | $Pepperoni | $GroundBeef | $Sausage |
$Cheese | $Bacon | $Ham){$ = $$};
/*
* Shortcut again.
* See, you can apply them to a part of rule definition.
*/
$Modifier = ((extra | double):"double"|no:"no"| light:'light');
$Topping = [$Modifier {$.modifier = $$}] $Ingredients {$.ingredient =
$$};
/*
* Here's fun part toppinglist is an array of topping.
* We initialize it at the beginning of $Toppings rule,
* then whenever we see a new $Topping, we push it into
* the array.
*/
$Toppings = {$.toppinglist = new Array} ($Topping
{$.toppinglist.push($$)} )<1-> [and $Topping{$.toppinglist.push($$)}];
$HalfTopping = ($Half $Toppings|$Toppings $Half) {$=$Toppings; $.half =
true};
/*
* Here we have an array of pizza,
* which is the whole order.
*/
$FullToppingGrammar = {$ = new Array} [$Filler] ($Toppings |
$HalfTopping){$.push($$)}[$Filler][$HalfTopping {$.push($$)}];
GRXML:
Its important that the file begins with the <? Characters otherwise it
will assume that the format is ABNF
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE grammar PUBLIC "-//W3C//DTD GRAMMAR 1.0//EN"
"http://www.w3.org/TR/speech-grammar/grammar.dtd">
<!--
This grammar is modified from a W3C Semantic Interpretation Draft
Committee example
reference document: http://www.w3.org/TR/semantic-interpretation/
copyright notice:
http://www.w3.org/Consortium/Legal/2002/copyright-documents-20021231
-->
<grammar xmlns="http://www.w3.org/2001/06/grammar" xml:lang="en"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.w3.org/2001/06/grammar
http://www.w3.org/TR/speech-grammar/grammar.xsd"
version="1.0" mode="voice" root="FullToppingGrammar"
tag-format="lumenvox/1.0" lang="en-US">
<rule id="Filler">
<item repeat="0-1"> and </item>
<one-of>
<item> I want </item>
<item> "I'd like" </item>
<item> Give me </item>
</one-of>
</rule>
<rule id="Half">
<item repeat="0-1">
<one-of>
<item>
<item repeat="0-1"> on </item>
one
</item>
<item>
<item repeat="0-1"> and </item>
<item repeat="0-1"> on </item>
the other
</item>
<item> and </item>
</one-of>
</item>
<one-of>
<item> half </item>
<item> side </item>
</one-of>
</rule>
<rule id="GreenPepper">
<item>
<one-of>
<item> green </item>
<item> bell </item>
</one-of>
<item> pepper </item>
</item>
<tag>
$="green pepper";
</tag>
</rule>
<rule id="GroundBeef">
<item>
<item repeat="0-1"> ground </item>
beef
</item>
<tag>
$="ground beef";
</tag>
</rule>
<rule id="Pepperoni">
pepperoni
<tag>
$="pepperoni";
</tag>
</rule>
<rule id="Sausage">
<item>
<item repeat="0-1"> italian </item>
<item> sausage </item>
</item>
<tag>
$="sausage";
</tag>
</rule>
<rule id="Cheese">
cheese
<tag>
$="cheese";
</tag>
</rule>
<rule id="Bacon">
bacon
<tag>
$="bacon";
</tag>
</rule>
<rule id="Ham">
ham
<tag>
$="ham";
</tag>
</rule>
<rule id="Ingredients">
<one-of>
<item><ruleref uri="#GreenPepper" /></item>
<item><ruleref uri="#Pepperoni" /></item>
<item><ruleref uri="#GroundBeef" /></item>
<item><ruleref uri="#Sausage" /></item>
<item><ruleref uri="#Cheese" /></item>
<item><ruleref uri="#Bacon" /></item>
<item><ruleref uri="#Ham" /></item>
</one-of>
<tag>
$=$$;
</tag>
</rule>
<rule id="Modifier">
<one-of>
<item>
<one-of>
<item> extra </item>
<item> double </item>
<tag>
$="double";
</tag>
</one-of>
</item>
<item>
no
<tag>
$="no";
</tag>
</item>
<item>
light
<tag>
$="light";
</tag>
</item>
</one-of>
</rule>
<rule id="Topping">
<item repeat="0-1">
<ruleref uri="#Modifier" />
<tag>
$.modifier = $$;
</tag>
</item>
<ruleref uri="#Ingredients" />
<tag>
$.ingredient = $$;
</tag>
</rule>
<rule id="Toppings">
<tag>
$.toppinglist = new Array;
</tag>
<item repeat="1-">
<ruleref uri="#Topping" />
<tag>
$.toppinglist.push($$);
</tag>
</item>
<item repeat="0-1">
and
<ruleref uri="#Topping" />
<tag>
$.toppinglist.push($$);
</tag>
</item>
</rule>
<rule id="HalfTopping">
<one-of>
<item>
<ruleref uri="#Half" />
<ruleref uri="#Toppings" />
</item>
<item>
<ruleref uri="#Toppings" />
<ruleref uri="#Half" />
</item>
</one-of>
<tag>
$=$Toppings;
$.half = true;
</tag>
</rule>
<rule id="FullToppingGrammar">
<tag>
$ = new Array;
</tag>
<item repeat="0-1">
<ruleref uri="#Filler" />
</item>
<one-of>
<item><ruleref uri="#Toppings" /></item>
<item><ruleref uri="#HalfTopping" /></item>
</one-of>
<tag>
$.push($$);
</tag>
<item repeat="0-1"><ruleref uri="#Filler" /></item>
<item repeat="0-1">
<ruleref uri="#HalfTopping" />
<tag>
$.push($$);
</tag>
</item>
<item repeat="0-1">
<ruleref uri="#HalfTopping" />
<tag>
$.push($$);
</tag>
</item>
</rule>
</grammar>
Kyle Danielson
Project Manager
P: 877-977-0707
F: 858-707-7072
Kyle at LumenVox.com
http://www.LumenVox.com
Tell us what is important to you! Take our product development survey:
http://www.LumenVox.com/survey/srDevelopment/index.asp
-----Original Message-----
From: asterisk-speech-rec-bounces at lists.digium.com
[mailto:asterisk-speech-rec-bounces at lists.digium.com] On Behalf Of Alan
Parker
Sent: Tuesday, September 05, 2006 2:13 PM
To: asterisk-speech-rec at lists.digium.com
Subject: Re: [asterisk-speech-rec] Lumenvox
I think the problem is elsewhere, as no matter which grammar is
installed in the directory (including the example grammars Lumnevox
provides), the same error message and failure occurs. Is it not possible
output in verbose mode, some indication of the cause of the error?
Perhaps the file/path/directory that it is trying to load?
Alan
-----Original Message-----
From: asterisk-speech-rec-bounces at lists.digium.com
[mailto:asterisk-speech-rec-bounces at lists.digium.com] On Behalf Of
Kenneth Shumard
Sent: 05 September 2006 16:46
To: Discussing of speech recognition in Asterisk
Subject: Re: [asterisk-speech-rec] Lumenvox
Some sort of validation is apparently done by the Lumenvox SRE before it
considers a grammar to be loaded. If lumenvox.conf properly points to a
grammar and it fails to load, that suggests that there is some problem
within the grammar itself. I'm not (yet!) an expert on the syntax of the
grammars, so I'm afraid I can't be of much help troubleshooting yours. I
believe the Lumenvox Tuner can load a grammar, so you might try that
utility to see if it helps.
~Kenny Shumard
Digium
----- Original Message -----
From: Kenneth Shumard <kenny at digium.com>
To: Discussing of speech recognition in Asterisk
<asterisk-speech-rec at lists.digium.com>
Sent: Saturday, September 2, 2006 9:06:09 PM GMT-0600
Subject: Re: [asterisk-speech-rec] Lumenvox
I will look through the available documentation to try to find out under
what conditions a grammar can fail to load. If the available docs don't
specify, I'll see if I can get that added in.
_______________________________________________
--Bandwidth and Colocation provided by Easynews.com --
asterisk-speech-rec mailing list
To UNSUBSCRIBE or update options visit:
http://lists.digium.com/mailman/listinfo/asterisk-speech-rec
_______________________________________________
--Bandwidth and Colocation provided by Easynews.com --
asterisk-speech-rec mailing list
To UNSUBSCRIBE or update options visit:
http://lists.digium.com/mailman/listinfo/asterisk-speech-rec
More information about the asterisk-speech-rec
mailing list