gpt4 book ai didi

.net - 具有基于自定义 SRGS 语法的自由格式文本

转载 作者:行者123 更新时间:2023-12-01 12:58:49 38 4
gpt4 key购买 nike

我正在尝试开发一个基于语音的应用程序,它将用户输入作为语音接受并根据输入执行一些操作。这是我第一次涉足这项技术,我一边学习一边开发它。

我正在使用 dotnet 4 附带的 Microsoft SAPI 来识别语音。至此,我了解了它支持的两种模式。

Speech recognition (SR) has two modes of operation:

  • Dictation mode — an unconstrained, free-form speechinterpretation mode that uses a built-in grammar provided by therecognizer for a specific language. This is the default recognizer.

  • Grammar mode — matches spoken words to one or more specific context-free grammars (CFGs). A CFG is a structure that defines aspecific set of words, and the combination of these words that can beused. In basic terms, a CFG defines the sentences that are valid forSR. Grammars must be supplied by the application in the form ofprecompiled grammar files or supplied at runtime in the form of W3CSpeech Recognition Grammar Specification (SRGS) markup or the olderCFG specification. The Windows SDK includes a grammar compiler:gc.exe.

所以基本上,无论我用语法指定什么词,引擎都只会识别那些词。但我还想包括一些自由格式的文本以及结构化语法。一个例子就是人名。如果我想从语音中捕获名字,我需要在语法中指定那个名字,但如果应用程序开放供任何人使用,那是不可能的。

有没有办法提取一些不属于语法的文本?

如何让系统识别诸如“我叫加里,今年 25 岁”之类的句子。名称绝对可以是任何名称,我如何在我的语法中定义它?

最佳答案

您可以将听写模式与语法模式混合使用,请参阅 MSDN 中的示例:

http://msdn.microsoft.com/en-us/library/ms723634(v=vs.85).aspx

<GRAMMAR>
<!-- command to handle first and last names with semantic properties -->
<!-- By using semantic properties, the application can ignore all of
the text returned, except for the text associated with the dictation
tags' semantic properties "PID_FirstName" and "PID_LastName" -->
<RULE ID="SubmitName" TOPLEVEL="ACTIVE">
<P>
my first name is
<!-- Note the implicit maximum is only one word -->
<DICTATION PROPID="PID_FirstName"/>
and my last name is
<!-- Note the implicit maximum is two words -->
<DICTATION PROPID="PID_LastName" MAX="2"/>
</P>
</RULE>
</GRAMMAR>

关于.net - 具有基于自定义 SRGS 语法的自由格式文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8006238/

38 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com