I am using this code:
using System.Net;
function() {
using (WebClient Client = new WebClient())
{
Client.DownloadFile("http://translate.google.com/translate_tts?tl=en&q=hello", "a.mp3");
}
}
Its working fine. Notice please the English language I am downloading. The main problem comes when I'd like to do the same with language using non-latin letter, for example Thai:
using System.Net;
function() {
using (WebClient Client = new WebClient())
{
Client.DownloadFile("http://translate.google.com/translate_tts?tl=th&q=สวัสดี", "a.mp3");
}
}
But this is giving me such a nonsence mp3 without that word sound. How to fix it please?
Notice the main structure of this website:
...translate.google.com/translate_tts?tl=**en**&q=**hello**"
...translate.google.com/translate_tts?tl=**th**&q=**สวัสดี**"
Use HttpUtility.UrlPathEncode("สวัสดี")
to encode the Unicode characters.