3

I am trying to create an app that speaks Greek. But since Microsoft does not support Greek as a spoken language and my question on guidelines on how to create my own lexicon (here) I am asking this:

How may I download an mp3 (or just the data doesn't matter) that includes the text that I sent to google translate on runtime and play it using C#?

Community
  • 1
  • 1
John Demetriou
  • 4,093
  • 6
  • 52
  • 88

2 Answers2

4

just use this link to download the MP3:

http://translate.google.com/translate_tts?tl=el&q=%22hello%22

Edit: Be aware Some Browsers like Firefox replaces the %22 with " and the link doesnt work so you need to copy it and cant click it!

How to Download Files: http://www.csharp-examples.net/download-files/

http://msdn.microsoft.com/en-us/library/ez801hhe.aspx

How to Play MP3: http://msdn.microsoft.com/en-us/library/4y171b18.aspx

using System.Media;

String strTextYouWantAsMp3 = "Hello";
WebClient webClient = new WebClient();
webClient.DownloadFile("http://translate.google.com/translate_tts?tl=el&q=%22" + strTextYouWantAsMp3 + "%22", @"c:\audio.mp3");

SoundPlayer simpleSound = new SoundPlayer(@"c:\audio.mp3");
simpleSound.Play();
Vloxxity
  • 980
  • 1
  • 9
  • 30
  • Firstly what is the difference between downloading files synchronously and asynchronously?? Second what does firefox have to do with everything? (maybe I understood your answer wrong Third I wish to send the text to google translate and get the tts all from my code and not just get a link from a browser. It will be done at runtime – John Demetriou Nov 16 '12 at 10:12
  • 1.if you download it synchronously you cant do anythin other than downloading (your UI will freeze) 2.doesnt matter because i used a codebox for the link so u cant click it. 3.yeah u need to download the file given from the link with webClient.DownloadFile(Link) – Vloxxity Nov 16 '12 at 10:19
  • This example does not work. `SoundPlayer` does not play MP3s. It says so specifically in the [MSDN reference](https://msdn.microsoft.com/en-us/library/system.media.soundplayer(v=vs.110).aspx). The only thing I've found is to use the WMPLib COM control to be able to play MP3s. – qJake Apr 03 '15 at 23:17
  • Google has blocked this behavior effective November 2015. – KatDevsGames Dec 31 '15 at 02:26
3

This link is now broken, you can refer to Chris Cirefice answer here: Google Text-To-Speech API

As suggested you will need to make a get request against the following URL http://translate.google.com/translate_tts?tl=en&q=Hello%20World&client=t where q={your word you want to translate} and tl={your language}

Community
  • 1
  • 1
AhmedHamad
  • 131
  • 5