forked from pirtleshell/lwt
-
Notifications
You must be signed in to change notification settings - Fork 2
/
tts.php
29 lines (22 loc) · 749 Bytes
/
tts.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<?php
$ttsjs_lang = getSettingWithDefault("set-ttsjs-lang");
$ttsjs_rate = getSettingWithDefault("set-ttsjs-rate");
?>
<script>
function readTextAloud(text) {
var msg = new SpeechSynthesisUtterance()
msg.text = text
msg.lang = "<?php echo $ttsjs_lang;?>"
msg.rate = "<?php echo $ttsjs_rate;?>"
window.speechSynthesis.speak(msg)
}
function applyTTS() {
document.querySelectorAll('.textToSpeak, #textToSpeak, span.click.word.wsty').forEach(item => {
console.log("added listener")
item.addEventListener('click', event => {
console.log("this is great")
readTextAloud(item.textContent)
})
})
}
</script>