1

I'm trying to write an application that reads out text in multiple languages - I've got it to speak in English with some very simple code, but I now need to get the same application to speak in French. All I'm doing in code is starting with this

    SpeechSynthesizer speaker = new SpeechSynthesizer();

and then

    speaker.Speak("Hello world.");

which reads it out in English - I just need it to also do French

It's proving difficult to get example code for this - anyone have any leads?

I've also tried also downloading the Microsoft Speech Platform so I could get Excel or Word to do the same thing, but the platform doesn't install on my system (Office 2016, Windows 10), and googling it doesn't give me any answers

wns
  • 13
  • 4
  • To put this another way, how can I add installed voices in another language so that they show up in the GetInstalledVoices method of SpeechSynthesizer? – wns Nov 09 '15 at 04:18

1 Answers1

0

The default Speech Synth used by .Net just uses the [SAPI compliant] TTS engine that comes with Windows, so what voice languages you get will depend on which version of the OS is installed.

I haven't switched to Windows 10 yet, but back in the days of Windows 7, you got "Microsoft Sam" and maybe one other English voice by default.

You will need to find and install voices for other languages to read the text (most require a license) or use a different speech synthesis approach.

The L&H French voices are available for download here. I've not used the site before but VirusTotal says the french download is safe. No guarantees from me.

Once you have a voice installed, use speaker.SelectVoice() to select a voice by name (or better yet, speaker.SelectVoiceByHints() which will allow you to specify a desired culture).

To include the details mentioned in comments; An alternative is to use the Google Translate TTS Api as discussed in this answer. Sample Url: (Bonjour le Monde)

http://translate.google.com/translate_tts?tl=fr&q=Bonjour%20le%20monde

Community
  • 1
  • 1
Basic
  • 26,321
  • 24
  • 115
  • 201
  • HI, thanks for that - but it's not translation I need to do, but speaking in the different language: so in the example above, I want to add (e.g.) "Je me leve" instead of "Hello World", and have it pronounced in a French accent. If I got the existing synthesizer to say it, it would think the words were in English, and would pronounce it something like "Gee meee leeeve", which obviously isn't now it sounds in French! – wns Nov 09 '15 at 01:44
  • Yes... But you don't want it to say "Hello World", you want "Bonjour le Monde" or similar. Nothing is going to do that for you automatically. You need to work out what the words are in another language, then you need to find a voice that can read text in that language with appropriate accent/intonation. It's a multi-step problem – Basic Nov 09 '15 at 01:46
  • Hi Basic - just commented as you were typing. There is no translation required in my application - I will type "Hello World" and I want it to say it in English. I will also type "Bonjour le Monde" and I want it to say it pronounced in french – wns Nov 09 '15 at 01:48
  • Ah, beg pardon. That wasn't clear. You can ignore the translate steps then... You'll still need to install the international voices into Windows (they have to be SAPI compliant). Once you've done that, you can select the appropriate voice using the framework as you would any other. ViaVoice used to offer international voices for free but since they've become Nuance, I don't think they do any more – Basic Nov 09 '15 at 01:51
  • See if that helps at all? – Basic Nov 09 '15 at 02:18
  • Thanks Basic - made *some* progress - I found this link after your suggestion http://opendirective.net/blog/2014/02/free-international-sapi-voices-from-microsoft/ and I downloaded the French SAPI voice. In my application code, I looped through the SpeechSynthesizers GetInstalledVoices collection and it only showed two, both in English. I'm not sure how to get the SpeechSynthesizer to recognise that I have other installed voices.... – wns Nov 09 '15 at 02:59
  • Can you select those voices outside of .Net. As I said I'm on Win7, so I have a "Speech Recognition -> Text To Speech" control panel option. Not sure where that lives in Win10 but it allows me to test installed voices – Basic Nov 09 '15 at 09:04
  • Hi Basic - there is a Text to Speech in control panel in Windows 10 - it's only showing me the two voices that are installed though. I tried downloading MSSpeech_TTS_fr-FR_Hortense.msi, but the installation quits after a couple of seconds with no error message. Third party SAPI-5 speech engines also don't seem to show up. All I really need is something that can speak both French and English text - Excel and Word have the Speak function for instance - I just can't see anything in Office 2016 that explains how to get it to work with multiple languages – wns Nov 09 '15 at 12:13
  • Sorry for intermittent responses, busy day. In short, .Net will only use the voices you can see in the control panel. I have no idea why the voices you've installed don't show up there. It may be Win10 specific (I know a lot was redesigned for Cortana), but without a copy to hand, it's impossible to test. I might spin up a VM if I get time but can't guarantee anything. You could always give up on MS TTS and just use Google's api eg: [google...translate_tts?tl=fr&q=Bonjour%20le%20monde](http://translate.google.com/translate_tts?tl=fr&q=Bonjour%20le%20monde) which will serve the speech as an MP3 – Basic Nov 09 '15 at 19:12
  • More info on avoiding the CAPTCHA: http://stackoverflow.com/questions/9893175/google-text-to-speech-api/31791632#31791632 – Basic Nov 09 '15 at 19:18
  • Basic - you've convinced me! Within 10 mins I'd got Google API to do at least 80% of what I need. No idea why Microsoft make things so complicated. Thanks again for yourr help on this – wns Nov 09 '15 at 22:38
  • Glad you got there in the end, sorry it wasn't quite what you were looking for – Basic Nov 10 '15 at 01:23