Tag: speechsynthesizer

ASP.NET MVC中的超快文本到语音(WAV – > MP3)

这个问题主要是关于Microsoft的Speech API(SAPI)对服务器工作负载的适用性,以及它是否可以在w3wp中可靠地用于语音合成。 我们有一个异步控制器使用.NET 4中的本机System.Speech程序集(不是作为Microsoft Speech Platform – Runtime Version 11的一部分提供的Microsoft.Speech)和lame.exe来生成mp3,如下所示: [CacheFilter] public void ListenAsync(string url) { string fileName = string.Format(@”C:\test\{0}.wav”, Guid.NewGuid()); try { var t = new System.Threading.Thread(() => { using (SpeechSynthesizer ss = new SpeechSynthesizer()) { ss.SetOutputToWaveFile(fileName, new SpeechAudioFormatInfo(22050, AudioBitsPerSample.Eight, AudioChannel.Mono)); ss.Speak(“Here is a test sentence…”); ss.SetOutputToNull(); ss.Dispose(); } var process = new Process() […]

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和语言包的版本是否匹配。 此代码适用于我已安装的默认语音。 […]

C#SpeechSynthesizer使服务无响应

我有以下代码 [WebMethod] public byte[] stringToWav(string text) { SpeechSynthesizer ss = new SpeechSynthesizer(); MemoryStream ms = new MemoryStream(); ss.SetOutputToWaveStream(ms); ss.Speak(text); return ms.ToArray(); } 并且该服务什么都不返回。 知道为什么会这样吗?