voicexml 中外部语法的结构

发布于 2024-10-10 16:37:09 字数 2342 浏览 6 评论 0原文

外部 vxml 语法的结构是什么样的?

目前我有以下内联语法:

<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>

我想编写

<grammar src = "mygrammar.grxml" type="application/srgs+xml" />

并引用外部语法,而不是这个内联语法。

我可以复制内联语法并将其放入 mygrammer.grxml 中吗?

或者我需要更多的代码行吗?

提前致谢

----编辑----

现在我的内联语法早些时候在哪里,我有

<grammar src = "grammar_produkte.grxml" type="application/srgs+xml" />

,我的外部语法看起来像这样(就像你说的):

<?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>

但它不起作用。它表示发生错误并且应用程序停止。 我做错了什么吗? 该文件与 .vxml 位于同一目录中。

我使用 MS Speech Server 2007

----------------编辑-----

你好,

我引用的语法文件是:

<grammar src = "grammar_produkte2.grxml" type="application/srgs+xml"  />

除了我之前使用的语法之外,现在我使用这个示例(来自网站):

 <?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>

我尝试使用 mode=voice 和 dtmf。

除了语音服务器之外,我还需要什么吗? 文件位于同一文件夹中。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

谜兔 2024-10-17 16:37:09

您至少需要 XML 声明(条目)。文档类型通常是可选的(对于某些解析器,最好避免)。对于大多数语法来说,大多数其他属性也可以避免。

以下内容来自 SRGS(语法)规范 中的示例:

  <?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>

在您的具体示例中,对于大多数平台,以下内容应该足够了:

<?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>

上面,我提到 doctype 在某些情况下是一个问题。我发现一些系统可以连续获取 DTD(如果列出)。这是不好的形式,但并不总是被注意到。如果互联网链接出现故障,系统将无法正确响应。而且,如果您的流量足够大,您可能会被识别为 DOS 攻击并被封锁一段时间。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文