[英]jquery for google tts no voice
When I use this code let google_tts speak word voice, the code is ok but have a problem. 当我使用此代码时,让google_tts说出语音,该代码可以,但是有问题。 The word voice must listen http://translate.google.com/translate_tts?tl=en&q=dog(word) first then run this code the rusult is OK, but when I won't listen http://translate.google.com/translate_tts?tl=en&q=dog(word) first the code can't speak the word.I reference Google Translate TTS problem ,I want to know the real problem and how to fix it ? 语音一词必须首先收听http://translate.google.com/translate_tts?tl=zh&q=dog(word),然后运行此代码,但效果很好,但是当我不收听http://translate.google时。 com / translate_tts?tl = zh&q = dog(word)首先,该代码不会讲单词。我参考了Google Translate TTS问题 ,我想知道真正的问题以及如何解决?
I want to know how to fix let IE and Firefox browser run successful, thank a lot 我想知道如何解决让IE和Firefox浏览器成功运行的问题,非常感谢
HTML 的HTML
<form id="say-form">
<button id="say-button">Say!</button>
<audio id="audio" preload controls>
<source id="s1" />
</audio>
</form>
JQuery jQuery查询
$('#say-form').submit(function(){
var ar = new Array("dog","egg","what","big")
var i=0,file = $("#audio")
console.log(ar[0])
$("#s1").attr("src", "http://translate.google.com/translate_tts?tl=en&q="+ar[0]).detach().appendTo("#audio");
file[0].load();
file[0].play();
i++;
// when it play end, play next word until ar array it's finish
file.on( "ended", function(){
if(i!=ar.length)
{
$("#s1").attr("src", "http://translate.google.com/translate_tts?tl=en&q="+ar[i]).detach().appendTo("#audio");
$(this)[0].load();
$(this)[0].play();
i++;
}
});
return false;
});
Why do not you use Php? 为什么不使用Php?
$text = urlencode('my text');
$url = "http://translate.google.com/translate_tts?ie=utf-8&tl=en&q=".$text;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1)");
curl_setopt($ch, CURLOPT_TIMEOUT, 60);
$return = curl_exec($ch);
curl_close($ch);
echo $return;
?> like this Google tts api giving me blank mp3 or this http://ctrlq.org/code/19147-text-to-speech-php ?>像这样的Google tts api给我空白的mp3或这个http://ctrlq.org/code/19147-text-to-speech-php
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.