SpeechSynthesizer Exception - Please Help
- by Chris
Hi.
I have the following code:
private List<VoiceInfo> GetInstalledVoices(SpeechSynthesizer synthesizer)
{
CultureInfo currentCulture = CultureInfo.CurrentCulture;
var listOfVoiceInfo = from voice
in synthesizer.GetInstalledVoices(currentCulture)
select voice.VoiceInfo;
return listOfVoiceInfo.ToList<VoiceInfo>();
}
I then call the code from the following code snippet:
var synthesizer = new SpeechSynthesizer();
var installedVoices = GetInstalledVoices(synthesizer);
VoiceInfo voice = null;
if (installedVoices != null && installedVoices.Count > 0)
{
voice = installedVoices.FirstOrDefault();
}
if (voice != null)
{
synthesizer.SelectVoice(voice.Name);
}
The line of code that selects the voice throws the following exception:
"Cannot set voice. No matching voice is installed or the voice was disabled."
This is being done from within an ASP.NET web application - running on Windows Server 2003 R2. When I run this from within Visual Studio 2008 - everything works fine. I created a simple Console app to perform the same action - then ran it from the Windows Server 2003 machine - and it worked fine. I even modified the code in the Console app to loop through each of the installed voices and select the voice. No problems. However, when doing the same from within the web application, I get the same error.
I am beating my head against a wall on this one. ANY help on this would be greatly appreciated.
Thanks.
Chris