Compare commits
No commits in common. "74f47b786e32fe5a6a5188d182941f592bafe108" and "19ea14b38cf2fd7dcbab76b3da8bc743a4edb0c8" have entirely different histories.
74f47b786e
...
19ea14b38c
|
@ -3,7 +3,6 @@ var Reader = (function() {
|
||||||
let current_position = 0;
|
let current_position = 0;
|
||||||
let original_position = 0;
|
let original_position = 0;
|
||||||
let to_speak = "";
|
let to_speak = "";
|
||||||
let current_rate = 1; // 添加这一行,设置默认速率为 1
|
|
||||||
|
|
||||||
function makeUtterance(str, rate) {
|
function makeUtterance(str, rate) {
|
||||||
let msg = new SpeechSynthesisUtterance(str);
|
let msg = new SpeechSynthesisUtterance(str);
|
||||||
|
@ -25,24 +24,12 @@ var Reader = (function() {
|
||||||
reader.speak(msg);
|
reader.speak(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateRate(rate) {
|
|
||||||
// 停止当前的朗读
|
|
||||||
stopRead();
|
|
||||||
|
|
||||||
// 更新当前速率
|
|
||||||
current_rate = rate;
|
|
||||||
|
|
||||||
// 重新开始朗读
|
|
||||||
read(to_speak, current_rate);
|
|
||||||
}
|
|
||||||
|
|
||||||
function stopRead() {
|
function stopRead() {
|
||||||
reader.cancel();
|
reader.cancel();
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
read: read,
|
read: read,
|
||||||
stopRead: stopRead,
|
stopRead: stopRead
|
||||||
updateRate: updateRate // 添加这一行,将 updateRate 方法暴露出去
|
|
||||||
};
|
};
|
||||||
}) ();
|
}) ();
|
||||||
|
|
|
@ -420,12 +420,6 @@
|
||||||
|
|
||||||
savedArticlesDropdown.selectedIndex = -1;
|
savedArticlesDropdown.selectedIndex = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
document.getElementById('rangeComponent').addEventListener('input', function() {
|
|
||||||
var rate = this.value;
|
|
||||||
Reader.updateRate(rate);
|
|
||||||
});
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
<style>
|
<style>
|
||||||
|
|
Loading…
Reference in New Issue