【问题标题】:How to access Speech Recognition via Win32 API?如何通过 Win32 API 访问语音识别?
【发布时间】:2022-01-11 02:19:57
【问题描述】:

我正在尝试更新一个非常旧的 VB6 程序以提供语音识别。 我认为最好的方法是访问 Win32 API for Speech Recognition。

在 MS 文档中查找此内容。看起来以前这将通过 SAPI 5.3 per this question 已被弃用并被 MS Agent 取代,而 MS Agent 本身已被弃用。

【问题讨论】:

  • 对于 VB6,您几乎肯定想找到一些 ActiveX 控件。并且仅仅因为某些东西被标记为已弃用,请记住 MS 不太可能真正删除它。 VB6 本身必须被视为已弃用,如果现在可以使用它,我不会担心未来的官方支持。
  • VB6 运行时根本没有被弃用,它在 Windows 中完全受支持:docs.microsoft.com/en-us/previous-versions/visualstudio/… ... 上面写着“Visual Basic 团队致力于为 Visual Basic 6.0 应用程序提供“它只是工作”的兼容性在以下受支持的 Windows 操作系统上:Windows 11 Windows 10"。虽然不再支持 VB6 开发工具。
  • 这个问题看起来好像有一些链接,但没有。您可以编辑和添加它们吗?

标签: winapi vb6 speech-recognition


【解决方案1】:

http://msdn.microsoft.com/en-us/library/ms720589(VS.85).aspx

上面的链接是旧的(因为我在 10 年前使用它),但有效。您基本上创建了适当的对象,可能以它们的格式创建语法,然后在RC 对象上创建事件,如下所示:

以下方法“有效”,但效果不是很好。此外,这导致我们不得不创建自己的 MsgBox 函数,因为我们需要自动化一切...而且,因为您不能只告诉 Windows “单击”一个标准的消息框(除非您想处理更多的 API),您必须控制软件的更多方面。

它确实有效,但我不确定是否有人使用过它。

Public WithEvents RC As SpSharedRecoContext
Public myGrammar, b As ISpeechRecoGrammar

Private Sub Form_Load()
    On Error GoTo EH

    Set RC = New SpSharedRecoContext

    Set myGrammar = RC.CreateGrammar
    myGrammar.CmdLoadFromFile "sol.xml", SLODynamic
    myGrammar.CmdSetRuleIdState 0, SGDSActive

EH:
    If Err.Number Then ShowErrMsg
End Sub

Private Sub RC_FalseRecognition(ByVal StreamNumber As Long, ByVal StreamPosition As Variant, ByVal Result As SpeechLib.ISpeechRecoResult)
    'Label1.Caption = "(no recognition)"
End Sub

Private Sub RC_Recognition(ByVal StreamNumber As Long, ByVal StreamPosition As Variant, ByVal RecognitionType As SpeechLib.SpeechRecognitionType, ByVal Result As SpeechLib.ISpeechRecoResult)
    'Label1.Caption = Result.PhraseInfo.GetText
End Sub

Private Sub RC_StartStream(ByVal StreamNumber As Long, ByVal StreamPosition As Variant)
    'Label2.Caption = Val(StreamNumber)
End Sub

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2023-04-08
    • 1970-01-01
    • 1970-01-01
    • 2013-07-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多