2
我想突出显示特定段落/列表及其相应的语音。ResponsiveVoice为多个话语只拨打一次电话号码
在respondvoice.js中是否有任何回调?我得到了一个回调函数,但它不工作。
每当我把控制台,而不是突出显示,它只产生一个而不是三个。
我觉得onend只对第一次以后打电话。但它应该为所有对工作/ UL
请帮我..
我的代码: -
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="http://code.responsivevoice.org/develop/1.5.2/responsivevoice.js"></script>
<script>
var currentDataValue =0;
$(document).ready(function(){
$("#1").click(function(){
$("p,ul").each(function(index, element){
responsiveVoice.speak($(this).text(),$('UK English Female').val(),{
pitch: .7,
onend: function() {
$(this).css("backgroundColor", "yellow");
}
});
});
});
});
$(document).ready(function(){
$("#2").click(function(){
responsiveVoice.pause();
});
});
$(document).ready(function(){
$("#3").click(function(){
responsiveVoice.resume();
});
});
$(window).load(function(){
$("#4").click(function(){
responsiveVoice.cancel();
});
});
</script>
</head>
<body>
<h2>This is a heading</h2>
<p>This is a paragraph.</p>
<ul>
<li>this unoder list </li>
</ul>
<p id="test">This is another paragraph.</p>
<button id="1">start</button>
<button id="2">pause</button>
<button id="3">resume</button>
<button id="4">stop</button>
</body>
</html>
感谢响应。语音正确地拨打但问题仅仅是一个回调,并不是为每个para/ul拨打电话。 U也可以通过$(this).css(“backgroundColor”,“yellow”)来检查;与一些日志(打印)。它只打印一次,但在每个para/ul的语音合成后应该是3次。 –
好吧,我更新了答案 –
因为他们(响应式语音)处理了很多情况。例如: - 大型会议(超过200字),语音质量,浏览器兼容性等。所以我使用它们。我会像你一样(这对演示有效),那么我必须处理很多情况。 –