aboutsummaryrefslogtreecommitdiffhomepage
path: root/script.js
diff options
context:
space:
mode:
Diffstat (limited to 'script.js')
-rw-r--r--script.js11
1 files changed, 10 insertions, 1 deletions
diff --git a/script.js b/script.js
index 7116e29..c51e6c2 100644
--- a/script.js
+++ b/script.js
@@ -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)
+}