Ok, I am trying to use the google translate speech api to say something. Here’s my code:
<script>
function say(words){
var a=new Audio();
a.src='http://translate.google.com/translate_tts?q='+words;
a.play();
};
</script>
<div id="button onclick="say('hello');">Click to say hello!</div>
When I click the button, nothing happens. Can anyone see where I’ve gone wrong?
Thanks.
You need to add the language (
tl=) parameter (and add a closing quote after your ID attribute). Here’s an example using English:Google’s TTS API does not return any content if a non-matching Referrer header is set though.