如何将参数传递给 BackGroundWorker

发布于 2024-10-16 10:18:19 字数 1154 浏览 8 评论 0原文

Imports SpeechLib

Public Class Form1
    Public vox = CreateObject("sapi.spvoice")

    Private Sub cmdSpeak_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdSpeak.Click
        Dim text2 As String = "Hello , This is a Text. Hello , This is a Text."
        BackgroundWorker1.RunWorkerAsync()
    End Sub

    Private Sub cmdPause_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdPause.Click
        vox.pause()
    End Sub

    Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Dim SVEPhoneme As Integer = 64
        vox.EventInterests = SVEPhoneme
        vox.AlertBoundary = SVEPhoneme
    End Sub

    Private Sub cmdResume_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdResume.Click
        vox.resume()
    End Sub

    Private Sub BackgroundWorker1_DoWork(ByVal sender As System.Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork
        vox.Speak(Text, SpeechVoiceSpeakFlags.SVSFlagsAsync)
    End Sub
End Class

如何将 text2 传递给 vox.speak?

Imports SpeechLib

Public Class Form1
    Public vox = CreateObject("sapi.spvoice")

    Private Sub cmdSpeak_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdSpeak.Click
        Dim text2 As String = "Hello , This is a Text. Hello , This is a Text."
        BackgroundWorker1.RunWorkerAsync()
    End Sub

    Private Sub cmdPause_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdPause.Click
        vox.pause()
    End Sub

    Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Dim SVEPhoneme As Integer = 64
        vox.EventInterests = SVEPhoneme
        vox.AlertBoundary = SVEPhoneme
    End Sub

    Private Sub cmdResume_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdResume.Click
        vox.resume()
    End Sub

    Private Sub BackgroundWorker1_DoWork(ByVal sender As System.Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork
        vox.Speak(Text, SpeechVoiceSpeakFlags.SVSFlagsAsync)
    End Sub
End Class

How can I pass text2 to vox.speak?

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

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

发布评论

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

评论(1

流殇 2024-10-23 10:18:19

cmdSpeak_Click 中,将 text2 作为参数传递给 RunWorkerAsync

BackgroundWorker1.RunWorkerAsync(text2)

BackgroundWorker1_DoWork 中,检索参数的值

vox.Speak(DirectCast(e.Argument, String), SpeechVoiceSpeakFlags.SVSFlagsAsync)

In cmdSpeak_Click, pass text2 as a parameter to RunWorkerAsync

BackgroundWorker1.RunWorkerAsync(text2)

In BackgroundWorker1_DoWork, retrieve the value of the parameter

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