Thursday, October 21, 2010

Windows Phone 7 and Google TTS

To make it work, you need a website that can handle php, mod_rewrite, and curl. Sorry for the extra line breaks.

translate.php
header('Content-type:audio/mpeg');
$word = $_GET['word'];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://translate.google.com/translate_tts?l=en&q='.$word);
curl_setopt($ch, CURLOPT_HEADER, false);
$data = curl_exec($ch);
$info = curl_getinfo($ch);
curl_close($ch);

.htacess
AddHandler php5-script .php
rewriteengine on
RewriteRule ^(.*)\.mp3$ http://test.tier4support.net/GoogleAPI/Translate.php?word=$1 [NC]

Now just point the MediaElement source to:
new System.Uri("http://test.tier4support.net/test.mp3")

No comments:

Post a Comment