how does the structure of an external vxml grammar looks like?
at the moment i have following inline grammar:
<grammar root="main" version="1.0" xml:lang="de-DE">
<rule id="main" scope="public">
<one-of>
<item> 1 </item>
<item> 2 </item>
<item>3 </item>
<item> 4</item>
</one-of>
</rule>
</grammar>
instead of this inline grammar i want to write
<grammar src = "mygrammar.grxml" type="application/srgs+xml" />
and refer to the external grammar.
can I just copy the inline grammar and put it in mygrammer.grxml?
or do I need somemore lines of code?
thanks in advance
----EDIT----
now where earlier my inline grammar was, i have
<grammar src = "grammar_produkte.grxml" type="application/srgs+xml" />
and my external grammar looks like this (like you said):
<?xml version="1.0" ?>
<grammar root="main" version="1.0" xml:lang="de-DE">
<rule id="main" scope="public">
<one-of>
<item> 1 </item>
<item> 2 </item>
<item> 3 </item>
<item> 4 </item>
</one-of>
</rule>
</grammar>
but it doesn't work. It says, that an error occurred and that the application stops. Did i do something wrong? The file is in the same directory like the .vxml.
I Use MS Speech Server 2007
----------------Edit-------
Hello,
I'm referencing to the grammar file with:
<grammar src = "grammar_produkte2.grxml" type="application/srgs+xml" />
In addition to the grammar i used before, now I use this example (from the website):
<?xml version="1.开发者_运维知识库0"?>
<grammar xml:lang="de-DE"
tag-format="semantics-ms/1.0" version="1.0"
root="Root" mode="voice"
xmlns="http://www.w3.org/2001/06/grammar"
xmlns:sapi=
"http://schemas.microsoft.com/
Speech/2002/06/SRGSExtensions">
<rule id="produkte" scope="public">
<one-of>
<item>
<item>ham</item>
<tag>$._value = "ham"</tag>
</item>
<item>
<item>roast beef</item>
<tag>$._value = "roast beef"</tag>
</item>
<item>
<item>italian</item>
<tag>$._value = "italian"</tag>
</item>
</one-of>
</rule>
</grammar>
I tried it with mode=voice and dtmf.
Do I need anything else expect the speech server? The Files are in the same folder.
At a minimum you'll need the XML declaration ( entry). Doctypes are usually optional (and for some parsers, you're better off avoiding). Most of the other attributes, for most grammars, can also be avoided.
The following is from an example in the SRGS (grammar) specification:
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE grammar PUBLIC "-//W3C//DTD GRAMMAR 1.0//EN"
"http://www.w3.org/TR/speech-grammar/grammar.dtd">
<!-- the default grammar language is US English -->
<grammar xmlns="http://www.w3.org/2001/06/grammar"
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"
xml:lang="en-US" version="1.0">
...
</grammar>
In your specific example, and for most platforms, the following should be sufficient:
<?xml version="1.0" ?>
<grammar root="main" version="1.0" xml:lang="de-DE">
<rule id="main" scope="public">
<one-of>
<item> 1 </item>
<item> 2 </item>
<item>3 </item>
<item> 4</item>
</one-of>
</rule>
</grammar>
Above, I mentioned doctype being a problem in some cases. I've found some systems that continuously fetch DTDs if listed. This is bad form, but not always noticed. If the Internet link goes down, the system doesn't respond correctly. And, if you have enough volume, you may be identified as a DOS attack and get blocked for a period of time.
精彩评论