1

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.

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

The program:

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

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

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

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

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' Speech Recognition works though, if that has any help.)

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.

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? :(

EDIT:

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.

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

bloodleh
  • 493
  • 8
  • 28
  • I unfortunately don't have an answer for you, but thank you for attempting to solve the problem multiple times yourself before finally posting a question. It is rare these days that people try to help themselves before giving up. – Luke Joshua Park Nov 14 '15 at 02:51
  • 2
    I don't understand those people as you usually find an answer from suggested topics after writing the title for your post. In my opinion asking a new question on SO should be treated as the final and very last option as most problems have been solved years ago. – bloodleh Nov 14 '15 at 03:45

2 Answers2

1

Finally got it solved.

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

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

bloodleh
  • 493
  • 8
  • 28
0

Not sure if this will help you, but I ran into a similar situation this morning. Turned out that in my ClickOnce application I had to add the following to my app.manifest file:

<requestedExecutionLevel level="asInvoker" uiAccess="false" />

This should go in the assembly/security/requestedPrivileges node.

MagicMau
  • 305
  • 3
  • 10
  • I created the manifest-file, but apparently the default level for requestedExecutionLevel is "asInvoker". So no luck with this one. Thanks anyway for suggesting something new! – bloodleh Nov 15 '15 at 16:50
  • what happens if you ask for a higher execution level, such as `highestAvailable`? – MagicMau Nov 16 '15 at 12:30
  • Visual Studio asks to be ran as administrator but the problem still persists. – bloodleh Nov 17 '15 at 15:52