diff options
Diffstat (limited to 'script.js')
-rw-r--r-- | script.js | 11 |
1 files changed, 10 insertions, 1 deletions
@@ -155,13 +155,22 @@ function generateObject() { if (randomSelector === 1) { current = whale; + speak(whaleDialog); console.log(whaleDialog); } else { current = petuniaBowl; + speak(flowerPotDialog); console.log(flowerPotDialog); } newObject = current.cloneNode(true); current.parentNode.replaceChild(newObject, current); newObject.classList.add("dropObject"); newObject.style.left = randomLeftOffset.toString() + "%"; -}
\ No newline at end of file +} + +function speak(message) { + const msg = new SpeechSynthesisUtterance(message); + const voices = window.speechSynthesis.getVoices(); + msg.voice = voices[0]; + window.speechSynthesis.speak(msg) +} |