Как исправить задержку в приложении синтеза речи?
Я написал приложение на Visual Basic 2017, которое должно было помочь мне понять синтез речи. Приложение работает нормально, за исключением одной вещи, есть 1-2 - секундная задержка в разговорной части во время первой итерации, но не в последующих итерациях. Мы ничего не слышим, пока заявление не будет сделано наполовину. Что я упускаю?
Код включен здесь:
Imports System.Speech.Synthesis Public Class Form1 Dim synth As New SpeechSynthesizer() Dim prompt1 As String = "" Dim prompt2 As String = "" Dim user As String = "Darby" Dim currentTime As Date = TimeOfDay Dim Sayit1 As String = "" Dim Sayit2 As String = "" Dim greeting1 As String = "" Dim greeting2 As String = "" Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click greeting1 = "Hi " & user & ", " If currentTime >= #12:00:00 AM# And currentTime < #12:00:00 PM# Then greeting2 = " How is your Morning going?" ElseIf currentTime >= #12:00:00 PM# And currentTime < #6:00:00 PM# Then greeting2 = " How is your Afternoon going? " ElseIf currentTime >= #6:00:00 PM# Then greeting2 = " How is your Evening going? " End If TalkToMe(greeting1, greeting2) End Sub Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click greeting1 = "Goodbye " & user & ", " If currentTime >= #12:00:00 AM# And currentTime < #12:00:00 PM# Then greeting2 = " you Have a Good Morning " ElseIf currentTime >= #12:00:00 PM# And currentTime < #6:00:00 PM# Then greeting2 = " you Have a Blessed Afternoon " ElseIf currentTime >= #6:00:00 PM# Then greeting2 = " you Have a Good Evening " End If TalkToMe(greeting1, greeting2) End Sub Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click Sayit1 = TextBox1.Text TalkToMe(Sayit1, "") End Sub Private Sub TalkToMe(prompt1, prompt2) synth.SelectVoice("Microsoft David Desktop") synth.Volume = 40 synth.Rate = -1 synth.Speak(prompt1 + prompt2) prompt1 = "" prompt2 = "" End Sub Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click End End Sub End Class
Что я уже пробовал:
Я переместил последовательность инициализации в разные позиции, но задержка одна и та же. (т:
synth.SelectVoice("Microsoft David Desktop") synth.Volume = 40 synth.Rate = -1