Quantcast
Channel: VBForums
Viewing all articles
Browse latest Browse all 42326

SpeechSynthesizer memory leak problem (System.Speech.Synthesis)

$
0
0
Hey Guys

I have notice that when I use the SpeechSynthesizer (System.Speech.Synthesis) to read the content of the clipboard the memory utilization (In the Task Manager) goes up and up without any resource release ... how can I deal with this issue?

Code:

Imports System.Speech.Synthesis

Public Class Form1

    Public Voice As New SpeechSynthesizer
    Public ClipboardText As String = ""

    Private Sub btnRead_MouseHover(sender As Object, e As System.EventArgs) Handles btnRead.MouseHover
        My.Computer.Keyboard.SendKeys("^c", True)
        TxtClipboard.Text = Clipboard.GetText
        ClipboardText = Clipboard.GetText

        Timer1.Start()
    End Sub

    Private Sub btnPause_MouseHover(sender As Object, e As System.EventArgs) Handles btnPause.MouseHover
        Voice.Pause()
    End Sub

    Private Sub btnStop_MouseHover(sender As Object, e As System.EventArgs) Handles btnStop.MouseHover
        Voice.SpeakAsyncCancelAll()
    End Sub

    Private Sub BackgroundWorker1_DoWork(sender As System.Object, e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork
        Timer1.Stop()
        My.Computer.Audio.PlaySystemSound(Media.SystemSounds.Asterisk)
        Voice.SpeakAsync(ClipboardText)
    End Sub

    Private Sub Timer1_Tick(sender As System.Object, e As System.EventArgs) Handles Timer1.Tick
        'Timer1.Interval="1000"
        BackgroundWorker1.RunWorkerAsync()
    End Sub

End Class


Viewing all articles
Browse latest Browse all 42326

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>