如何从speechsynthesizer对象释放RAM

如何从speechsynthesizer对象释放RAM

本文介绍了如何从speechsynthesizer对象释放RAM?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个程序:



[]





当快速按两次Ctrl + C时,程序会命令Windows在剪贴板中说出文字。



简单的源代码在我的Google网站上。



每次它说一个新句子,它为程序增加了大约3 MB的RAM,这一次达到521 MB ,我如何释放资源(处理它们)并忘记每一个口语句子,在说出或在中间停止后不再需要口语句子。



这就像它记住一些东西并在每次说句子时将它添加到RAM中并且不应该是这种情况,在过去使用SPVoice时,我认为这没有发生。



我尝试了什么:



I have this program:

Text To Speech For Windows[^]


The program orders Windows to speak text in clipboard when Ctrl+C is pressed twice fast.

The simple source code is in my Google site.

Every time it speaks a new sentence it adds around 3 MB of RAM for the program, reaching 521 MB this once, how can I release the resources (dispose them) and forget every spoken sentence, the spoken sentence is no longer needed after speaking it or stopping it in the middle.

It's like it's remembering something and adding it to RAM every time a sentence is spoken and that shouldn't be the case, in the past when using SPVoice, I think this didn't happen.

What I have tried:

public void speak1Text(string s)
        {

            s = prepareTextForSpeech(s);

            SS.SpeakAsyncCancelAll();
            SS = new SpeechSynthesizer();
            SS.SetOutputToDefaultAudioDevice();
            SS.SelectVoice(SS.GetInstalledVoices()[comboBoxVoice.SelectedIndex].VoiceInfo.Name);
            SS.Rate = trackBarRate.Value;
            SS.Volume = trackBarVolume.Value;

            SS.SpeakAsyncCancelAll();
            SS.SpeakAsync(s);
        }

推荐答案


这篇关于如何从speechsynthesizer对象释放RAM?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 19:53