SRGS XML 语法中的语义解释
我有以下 XML 语法来检测 1000 或 2200 等数字。
<rule id="rule1" scope="public">
<one-of>
<item>1</item>
<item>2</item>
<item>3</item>
</one-of>
<ruleref uri="#rule2"/>
</rule>
<rule id="rule2" scope="public">
<one-of>
<item>thousand<tag>out="000";</tag></item>
<item>thousand 100<tag>out=100;</tag></item>
<item>thousand 200<tag>out=200;</tag></item>
</one-of>
</rule>
但是,当用户说例如 2100 时,我得到“2 千 100”而不是 2100。看起来 out= 部分不起作用。我在网上看到了几个例子,不知道是否还需要添加其他内容才能完成这项工作。我正在使用 tag-format="semantics/1.0"
I have got the following XML grammar to detect a number like 1000 or 2200 etc.
<rule id="rule1" scope="public">
<one-of>
<item>1</item>
<item>2</item>
<item>3</item>
</one-of>
<ruleref uri="#rule2"/>
</rule>
<rule id="rule2" scope="public">
<one-of>
<item>thousand<tag>out="000";</tag></item>
<item>thousand 100<tag>out=100;</tag></item>
<item>thousand 200<tag>out=200;</tag></item>
</one-of>
</rule>
However when the user says for example 2100, I get "2 thousand 100" instead of 2100. It seems like the out= part is not working. I have seen several examples online and don't know if there is something else I need to add to make this work. I am using tag-format="semantics/1.0"
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我解决这个问题的方法是仅使用一个规则并使用 out.start、out.end 等属性,然后将它们连接起来。
要从 C# 检索语义值,您可以使用类似的方法
The way I solved this was to use just one rule and use properties like out.start, out.end and then concatenate them.
To retrieve the semantic value from C# you can use something like
Microsoft Speech SDK 附带一个示例SRGS 可以很好地处理数字。例如,“基数”规则可以处理最多 1,000,000 个数字。它在示例目录中提供了多种语言版本(例如 C:\Program Files\Microsoft SDKs\Speech\v11.0\Samples\Sample Grammars\en-US.grxml)。
The Microsoft Speech SDK comes with a sample SRGS that can handle numbers quite well. For instance the "Cardinal" rule can handle numbers up to 1,000,000. It's available in a variety of languages in the Samples directory (e.g. C:\Program Files\Microsoft SDKs\Speech\v11.0\Samples\Sample Grammars\en-US.grxml).