No voice installed on the system or none available

2019-02-25 06:14发布

Exception on IIS Server When try to create .wav file on c# using SpeechSynthesizer.

3条回答
小情绪 Triste *
2楼-- · 2019-02-25 06:49

This error is caused when the application is unable to access a voice for the SpeechSynthesizer to use. The first possible cause is the lack of any installed voices on the system. Odds are this isn't the problem, but you should still double check by running something like the following bit of code:

SpeechSynthesizer ssTest = new SpeechSynthesizer();
System.Diagnostics.Debug.WriteLine(ssTest.GetInstalledVoices().Count);

Assuming the above returns a number higher than 0, the problem is likely a more complicated issue with your application's security settings.

Several methods in the SpeechSynthesizer class, including SetOutputToWaveFile, require the immediate caller to be fully trusted. This might not be a huge concern for a desktop application (which the SpeechSynthesizer class was likely designed for) but has more serious security repercussions in a web environment. Therefore, IIS's default settings only make applications partially trusted. There are a number of ways to change this, possibly the quickest and certainly the dirtiest way is switching the application pool's identity from the default to an account with administrator privileges like the LocalSystem account.

Once again, just for emphasis, this will seriously harm the security of your application and should be fully researched before implementing.

查看更多
叼着烟拽天下
3楼-- · 2019-02-25 06:53

Simply, run the app as "administrator". ;)

error run as administrator

查看更多
爷的心禁止访问
4楼-- · 2019-02-25 07:11

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

查看更多
登录 后发表回答