Compare commits

...

3 Commits

Author SHA1 Message Date
mrlan 74f47b786e Merge pull request 'Fix bug 547' (#146) from Bug547-FanWenQi-Adapted into Alpha-snapshot20240618
Reviewed-on: #146
2024-09-01 07:28:15 +08:00
Lan Hui d00432cee1 Resolve merge conflicts 2024-09-01 07:27:46 +08:00
Lan Hui 2095550f33 Fix bug 547 2024-06-22 09:04:25 +08:00
2 changed files with 20 additions and 1 deletions

View File

@ -3,6 +3,7 @@ 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);
@ -24,12 +25,24 @@ 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 方法暴露出去
}; };
}) (); }) ();

View File

@ -420,6 +420,12 @@
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>