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

标签 .net grammar speech-recognition context-free-grammar sapi

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

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

Speech recognition (SR) has two modes of operation:

  • Dictation mode — an unconstrained, free-form speech interpretation mode that uses a built-in grammar provided by the recognizer 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 a specific set of words, and the combination of these words that can be used. In basic terms, a CFG defines the sentences that are valid for SR. Grammars must be supplied by the application in the form of precompiled grammar files or supplied at runtime in the form of W3C Speech Recognition Grammar Specification (SRGS) markup or the older CFG 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/

相关文章:

android - 使用音频文件进行语音识别?

.net - .NET 调试期间是否可以控制程序流程?

python - 希腊语上下文无关语法

parsing - 字符串常量导致 xtext 中出现意外的类型冲突

ANTLR4:词法分析器规则:任何字符串,只要它不包含这两个并排的字符?

audio - 为什么 librosa 中的情节不同?

.net - 从 C++ DLL 使用 VB.NET 类库的最佳方式?

c# - 从 .NET 调用基于 AXIS 的 Web 服务时,永远不会填充嵌套的复杂类型元素

c# - 查找 Dns.GetHostEntry 返回的正确 IP 地址

web-services - 语音识别(网络)服务?