C# SpeechSynthesizer - “系统上没有安装语音" [英] C# SpeechSynthesizer - "No voice installed on the system"

查看:182
本文介绍了C# SpeechSynthesizer - “系统上没有安装语音"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图制作一个简单的控制台程序,它使用 System.Speech.Synthesis 中的 SpeechSynthesizer 将文本转换为语音,但它不起作用.

I have tried to make a simple console program which uses SpeechSynthesizer from System.Speech.Synthesis to convert text to speech but it doesn't work.

我使用的是 64 位 Windows 7 和 Visual Studio 2010(我认为是 .NET Framework 4.0?)

I am using 64-bit Windows 7 and Visual Studio 2010 (with .NET Framework 4.0 I think?)

程序:

using System.Speech.Synthesis;
// *skip*
SpeechSynthesizer speech = new SpeechSynthesizer();
speech.SetOutputToDefaultAudioDevice();
speech.Speak("Hello world");

InvalidOperationException 发生在行 speech.Speak(...) 并带有消息 系统上没有安装语音或当前安全设置没有语音可用.

InvalidOperationException occurs at line speech.Speak(...) with message No voice installed on the system or none available with the current security setting.

speech.GetInstalledVoices() 显示安装了 Microsoft Anna 并且它的 Enabled 也设置为 true.

speech.GetInstalledVoices() shows that there is Microsoft Anna installed and the Enabled of it is also set to true.

我已尝试将 System.Speech.Synthesis 替换为 Microsoft.Speech.Synthesis(dll 位于 C:Program Files (x86)Microsoft Speech Platform SDKAssemblyMicrosoft.Speech.dll) 但同样的事情发生了.

I have tried replacing System.Speech.Synthesis with Microsoft.Speech.Synthesis (dll found at C:Program Files (x86)Microsoft Speech Platform SDKAssemblyMicrosoft.Speech.dll) but the same thing happens.

导航到控制面板 > 语音 > 文本到语音并单击预览语音"也失败并显示消息无法播放此语音.请尝试选择其他语音或选择其他音频输出设备. Microsoft Anna - 英语(美国)是唯一的选项.

Navigating to Control Panel > Speech > Text To Speech and clicking "Preview Voice" also fails with a message This voice cannot be played. Please try selecting another voice or selecting a different audio output device. Microsoft Anna - English (United States) is found there as the only option.

(不过,Windows 的语音识别可以工作,如果有帮助的话.)

(Windows' Speech Recognition works though, if that has any help.)

一些解决方案建议导航到注册表编辑器,HKEY_LOCAL_MACHINE > SOFTWARE > Microsoft > Speech > Voices > Tokens 并修复损坏的语言键.在令牌下是 MS-Anna-1033-20-DSK > Attributes 和 Language-key 应该是 409.

Some solution suggested navigation to Registry Editor, HKEY_LOCAL_MACHINE > SOFTWARE > Microsoft > Speech > Voices > Tokens and fixing a broken Language-key. Under token is MS-Anna-1033-20-DSK > Attributes and the Language-key is 409 as it should be.

另一个解决方案建议从 Visual Studio 的配置管理器更改 Active 解决方案平台,但我已经使用任何 CPU、x86 和 x64 测试了该程序,但没有任何效果.

Another solution suggested changing Active solution platform from Visual Studio's Configuration Manager but I have tested the program with Any CPU, x86 and x64 and none works.

我的文字转语音有什么问题?:(

What's wrong with my text to speech? :(

安装了 Visual Studio 2012 以防万一它是 .NET Framework 4.0 的问题,因为 VS2012 支持 4.5,但它也不起作用.

Installed Visual Studio 2012 just in case it was a problem with .NET Framework 4.0 as VS2012 supports 4.5, but it didn't work either.

我想问题出在我的 Windows 7 中,因为即使内置的文本到语音转换功能也不起作用.

I suppose the problem is within my Windows 7 as even the built in Text-to-Speech thing doesn't work.

推荐答案

终于解决了.

我的 SpeechEngine(或在 Windows 7 上的任何名称)显然已损坏,运行系统文件检查器 (SFC) 修复了它.

My SpeechEngine (or whatever the whole thing is called on Windows 7) was apparently corrupted and running System File Checker (SFC) fixed it.

要运行 SFC,请输入 cmd(必须以管理员身份运行)sfc/scannow

To run SFC, type into cmd (must be ran as administrator) sfc /scannow

这篇关于C# SpeechSynthesizer - “系统上没有安装语音"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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