Tag: text to speech

System.Speech.Synthesis在2012 R2上挂起了高CPU

我有一个asp.net MVC应用程序,它有一个控制器动作,它接受一个字符串作为输入,并发送一个合成语音的响应wav文件。 这是一个简化的例子: public async Task Speak(string text) { Task task = Task.Run(() => { using (var synth = new System.Speech.Synthesis.SpeechSynthesizer()) using (var stream = new MemoryStream()) { synth.SetOutputToWaveStream(stream); synth.Speak(text); var bytes = stream.GetBuffer(); return File(bytes, “audio/x-wav”); } }); return await task; } 应用程序(特别是此操作方法)在2008 R2服务器,2012(非R2)服务器和我的8.1 ​​dev PC上的服务器环境中运行良好。 它在标准的Azure 2012 R2虚拟机上运行良好。 但是,当我将其部署到三个2012 R2服务器(最终永久主页)时,操作方法永远不会产生HTTP响应 – IIS工作进程无限期地最大化其中一个CPU核心。 事件查看器中没有任何内容,在使用Procmon查看服务器时没有任何内容跳出来。 […]

为什么我的.NET应用程序中出现System.Security.Permissions.SecurityPermission错误?

我正在尝试使用C#在.NET 3.5中开发一个文本到语音编辑器。 我遇到了以下exception: System.Security.Permissions.SecurityPermission 。 怎么处理?

SAPI或(文本到语音)的同步问题… C#

我正在开发一个能说出浏览网页内容的项目。浏览器由我使用WebControl制作。 我正在使用SAPI语音引擎。 我想在通过SpVoice.speak阅读时突出显示网页中的行。 但问题是如果我以异步方式使用这种说话方法,那么只有网页的最后一行会突出显示,因为循环不会等待语音完成。 因此它发生得如此之快,以至于只有最后一行显示为高亮显示.Highlight方法使用引用Microsoft mshtml。 码: SpeechLib.SpVoice sound_object = new SpeechLib.SpVoice(); bool highlight(string senten) { if (senten != null) { IHTMLDocument2 doc = (IHTMLDocument2)GetCurrentBrowser().Document.DomDocument; IHTMLSelectionObject sel = (IHTMLSelectionObject)doc.selection; IHTMLTxtRange rng = (IHTMLTxtRange)sel.createRange(); rng.collapse(false); if (rng.findText(senten, 1000000, 0)) { rng.select(); return true; } else { return false; } } else { return false; } } […]

中文TTS失败,而英语作品

我刚安装了Microsoft语音SDK 11,并为英语和中文添加了2种不同的运行时语言。 英语似乎运行良好,虽然中国人抛出了这个错误 System.InvalidOperationException 附加信息 Speak error ‘80004005’ 为线 synth.Speak(s); 在以下代码中 using System; using Microsoft.Speech.Synthesis; namespace SampleSynthesis { class Program { static void Main(string[] args) { speakString(0, “Hello, I’m TTS.”); } static void speakString(int i, String s) { // Initialize a new instance of the SpeechSynthesizer. SpeechSynthesizer synth = new SpeechSynthesizer(); // Select a voice. […]

如何在SpeechSynthesizer中使用词典?

我正在执行一些文本到语音,我想在词典文件中指定一些特殊的发音。 我已经逐字地运行了MSDN的AddLexicon示例 ,并且它说出了句子,但它没有使用给定的词典,似乎有些东西被打破了。 这是提供的示例: using System; using Microsoft.Speech.Synthesis; namespace SampleSynthesis { class Program { static void Main(string[] args) { // Initialize a new instance of the SpeechSynthesizer. using (SpeechSynthesizer synth = new SpeechSynthesizer()) { // Configure the audio output. synth.SetOutputToDefaultAudioDevice(); PromptBuilder builder = new PromptBuilder(); builder.AppendText(“Gimme the whatchamacallit.”); // Append the lexicon file. synth.AddLexicon(new Uri(“c:\\test\\whatchamacallit.pls”), […]

如何使用Microsoft SAPI将文本到语音保存为wav?

我需要将文本转换为语音,然后将其保存为wav文件。

SpeechSynthesizer.SelectVoice()失败,“未安装匹配的语音或语音被禁用”

我正在修改Scott Hanselman的BabySmash代码以支持其他语言。 我按照这些步骤安装了语音平台和新语言。 该语言现在显示在注册表中: 现在可以通过Windows选择和播放该语言: System.Speech.Synthesis.SpeechSynthesizer.GetInstalledVoices()现在返回语音。 但是,下面的代码中的SelectVoice()会引发错误“System.ArgumentException:无法设置语音。未安装匹配的语音或语音被禁用”。 string phrase = null; SpeechSynthesizer speech = new SpeechSynthesizer(); CultureInfo keyboardCulture = System.Windows.Forms.InputLanguage.CurrentInputLanguage.Culture; InstalledVoice neededVoice = speech.GetInstalledVoices(keyboardCulture).FirstOrDefault(); if (neededVoice == null) { phrase = “Unsupported Language”; } else if (!neededVoice.Enabled) { phrase = “Voice Disabled”; } else { speech.SelectVoice(neededVoice.VoiceInfo.Name); } speech.Speak(phrase); 我已经尝试升级到C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\System.Speech.dll 。 我已经validation了Microsoft.Speech.dll和语言包的版本是否匹配。 此代码适用于我已安装的默认语音。 […]

在Windows Phone 8中取消语音合成

我在我的应用中添加了一个语音合成。 它有效,但问题是我无法取消语音…例如,当我导航到另一个页面时,语音继续…所以,我调用CancelAll()方法取消当前语音但发生exception而且我不知道为什么。 你知道这是什么问题吗? 例外 A first chance exception of type ‘System.Threading.Tasks.TaskCanceledException’ occurred in mscorlib.ni.dll An exception of type ‘System.Threading.Tasks.TaskCanceledException’ occurred in mscorlib.ni.dll and wasn’t handled before a managed/native boundary An exception of type ‘System.Threading.Tasks.TaskCanceledException’ occurred in mscorlib.ni.dll and wasn’t handled before a managed/native boundary The program ‘[2576] TaskHost.exe’ has exited with code -1 (0xffffffff). 我的代码: […]