在Javascript中使用Google文本转语音 [英] Using Google Text-To-Speech in Javascript
本文介绍了在Javascript中使用Google文本转语音的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要在JavaScript中播放 Google文字转语音。
想法是使用网络服务:
I need to play Google text-to-speech in JavaScript.
The idea is to use the web service:
http://translate.google.com/translate_tts?tl=en&q=This%20is%20just %20a%20test
并在certian行动中播放,例如点击按钮。
And play it on a certian action, e.g. a button click.
但它似乎不像加载普通的wav / mp3文件:
But it seems that it is not like loading a normal wav/mp3 file:
<audio id="audiotag1" src="audio/example.wav" preload="auto"></audio>
<script type="text/javascript">
function play() {
document.getElementById('audiotag1').play();
}
</script>
我该怎么做?
推荐答案
以下是我找到的代码段:
Here is the code snippet I found:
var audio = new Audio();
audio.src ='http://translate.google.com/translate_tts?ie=utf-8&tl=en&q=Hello%20World.';
audio.play();
这篇关于在Javascript中使用Google文本转语音的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文