如何从speechsynthesizer对象释放RAM? [英] How to release RAM from speechsynthesizer object?

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

问题描述

我有这个程序:



适用于Windows的文字转语音 [ ^ ]





当快速按两次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);
        }

推荐答案

我把它改成了SPvoice,它似乎现在运作良好,我会尝试一段时间,我读到微软已经意识到了这个问题,但是解决了更常见的问题...
I changed it to SPvoice and it seems to work well now, I will try it for some time, I read that Microsoft are aware of the problem but work on more common problems...


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

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆