System.Speech 抛出“系统上没有安装语音或当前安全设置没有语音可用"Windows 服务中的异常 [英] System.Speech throws "No voice installed on the system or none available with the current security setting" exception in Windows Service

查看:165
本文介绍了System.Speech 抛出“系统上没有安装语音或当前安全设置没有语音可用"Windows 服务中的异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

长期读者,第一次发帖.

Long time reader, first time poster.

我正在 C# .Net 3.5 中开发一个 Windows 服务来执行文本到语音操作.

I'm developing a Windows Service in C# .Net 3.5 to perform Text to Speech operations.

我正在使用 System.Speech(Microsoft Speech API 3.x).

I'm using System.Speech (Microsoft Speech API 3.x).

我将该服务部署到 Win2008 x64 服务器,现在它抛出以下异常:

I deployed the service to a Win2008 x64 server and it's now throwing the following exception:

System.InvalidOperationException: No voice installed on the system or none available with the current security setting.
   at System.Speech.Internal.Synthesis.VoiceSynthesis.Speak(Prompt prompt)
   at System.Speech.Synthesis.SpeechSynthesizer.Speak(Prompt prompt)
   at System.Speech.Synthesis.SpeechSynthesizer.Speak(String textToSpeak)

该服务正在域帐户下运行.如果我将服务更改为在我自己的个人域帐户(具有相当高的权限)下运行,则一切正常(因此肯定安装了语音 [Anna]).所以我很确定这是一个安全问题.

The service is running under a domain account. If I change the service to run under my own personal domain account (which has pretty high privileges), everything works perfectly (so a voice [Anna] is definitely installed). So I'm quite certain it's a security issue.

我需要对另一个域帐户进行哪些权限/修改才能使其正常工作?

What permissions/modifications do I need to make to the other domain account to make this work?

它必须是这个特定用户,因为它用于 MSSQL 数据库的 Windows 身份验证.

And it needs to be this specific user because it's used for Windows auth for a MSSQL database.

提前致谢.

推荐答案

简单修复:授予对 C:\windows\system32\config\systemprofile\appdata\roaming 的读/写访问权限运行服务的用户.

Simple fix: Grant read/write access to C:\windows\system32\config\systemprofile\appdata\roaming for the same user that the service is running under.

更多信息:在 Windows 10 Framework 4.6.2 上测试:Microsoft Speech 需要对roaming"文件夹的文件读/写访问权限,以便创建 ...\roaming\Microsoft\Speech 文件夹以在那里存储文件.

More Info: Tested on Windows 10 Framework 4.6.2: Microsoft Speech needs file read/write access to the "roaming" folder in order to create the ...\roaming\Microsoft\Speech folder to store files there.

如果您的服务用户不是对以下注册表项具有读/写访问权限的组的成员,您可能还需要添加这些权限:

If your service user is not a member of a group that has read/write access to the following registry keys, you may need to add these rights as well:

对于以下内容,包括适用于 32 位应用程序的 WOW6432Node,适用于 64 位应用程序

For the following, include WOW6432Node for 32 bit apps, leave it out for 64 bit apps

HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\SPEECH\Voices\Tokens(VOICE NAME)

HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\SPEECH\Voices\Tokens(VOICE NAME)

示例:HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\SPEECH\Voices\Tokens\TTS_MS_EN-US_DAVID_11.0

Example: HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\SPEECH\Voices\Tokens\TTS_MS_EN-US_DAVID_11.0

和:

HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\SPEECH\Voices\Tokens(VOICE NAME)\Attributes

HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\SPEECH\Voices\Tokens(VOICE NAME)\Attributes

示例:HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\SPEECH\Voices\Tokens\TTS_MS_EN-US_DAVID_11.0\Attributes

Example: HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\SPEECH\Voices\Tokens\TTS_MS_EN-US_DAVID_11.0\Attributes

您可能需要将这些注册表项的所有者从 TrustedInstaller 切换到您的用户或管理员组,以进行这些更改

You may need to switch the owner of these registry keys away from TrustedInstaller to your user, or the administrators group , to make these changes

如果您的应用程序在 IIS 下运行,请为应用程序池用户添加上述权限.

If your application runs under IIS, add the above rights for the application pool user.

这篇关于System.Speech 抛出“系统上没有安装语音或当前安全设置没有语音可用"Windows 服务中的异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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