在网页加载时运行ResponsiveVoice语音 [英] Run ResponsiveVoice speech on page load
本文介绍了在网页加载时运行ResponsiveVoice语音的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这可以正常工作,它会在点击时显示文本区域,但是我怎样才能将它改为 onload
?
< script src =http://responsivevoice.org/responsivevoice/responsivevoice.js>< / script>
< script src =http://code.jquery.com/jquery-git2.js>< / script>
< textarea id =textcols =45rows =3> HHHH< / textarea的>
< select id =voiceselection>< / select> $($#
$ b< input onclick =responsiveVoice.speak($('#text')。val(),$('#voiceselection')。val()); type =buttonvalue =播放/>
< br>
< button id =isPlaying>正在播放:< / button>
< p id =r>?< / p>
文字区域现在只说四个字母。
我想这是关键部分,但不能适合任何正确的执行:
responsiveVoice.speak($('#text')。val(),$('US English Female')。val());
我试过了:
< script src =http://responsivevoice.org/responsivevoice/responsivevoice.js>< / script>< script src =http://code.jquery.com/jquery-git2.js>< / script>< textarea id =textcols =45rows =3>它读取< / texttarea>< select id =voiceselection>< / select>< script>< / script>< input onclick =responsiveVoice.speak($('#text').val(),$ ('美国英语女性')。val()); 但是我收到了没有找到没有发现的语音:undefined的错误。 / code>处理程序,然后尝试在默认语音等被加载时说话:
responsiveVoice.OnVoiceReady = function() {console.log(演讲时间?); responseVoice.speak($('#text').val());};
< script src =// cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js\"></script><script src = //responsivevoice.org/responsivevoice/responsivevoice.js\"></script><textarea id =textcols =45rows =3>一二三三< / textarea>
This works properly, it speaks the text area on click, but how can I change it to speak onload
?
<script src="http://responsivevoice.org/responsivevoice/responsivevoice.js"></script>
<script src="http://code.jquery.com/jquery-git2.js"></script>
<textarea id="text" cols="45" rows="3"> HHHH</textarea>
<select id="voiceselection"></select>
<input onclick="responsiveVoice.speak($('#text').val(),$('#voiceselection').val());" type="button" value="Play" />
<br>
<button id="isPlaying">Playing:</button>
<p id="r">?</p>
Text area just says four letters now.
I imagine this is the key part, but can not fit it into anything properly to execute:
responsiveVoice.speak($('#text').val(),$('US English Female').val());
I tried:
var voicelist = responsiveVoice.getVoices();
var vselect = $("#voiceselection");
$.each(voicelist, function() {
vselect.append($("<option />").val(this.name).text(this.name));
});
// Yours
$('#isPlaying').on('click', function() {
$('#r').text(window.speechSynthesis.speaking)
})
$(document).ready(function() { //short code: $(function() { ... });
responsiveVoice.speak($('#text').val(), $('US English Female').val());
});
<script src="http://responsivevoice.org/responsivevoice/responsivevoice.js"></script>
<script src="http://code.jquery.com/jquery-git2.js"></script>
<textarea id="text" cols="45" rows="3">It reads this</textarea>
<select id="voiceselection"></select>
<script>
</script>
<input onclick="responsiveVoice.speak($('#text').val(),$('US English Female').val());" type="button" value="Play" />
But I get a "No voice found for: undefined" error.
解决方案 Hook into the OnVoiceReady
handler, then try to speak once the default voice, etc. is loaded:
responsiveVoice.OnVoiceReady = function() {
console.log("speech time?");
responsiveVoice.speak($('#text').val());
};
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script src="//responsivevoice.org/responsivevoice/responsivevoice.js"></script>
<textarea id="text" cols="45" rows="3">one two three</textarea>
这篇关于在网页加载时运行ResponsiveVoice语音的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文