From 8ad178b02fd9269f3224739d0c878b81eda93679 Mon Sep 17 00:00:00 2001 From: chris Date: Thu, 3 Mar 2022 22:06:25 -0500 Subject: [PATCH] fixed up speak --- .vscode/settings.json | 3 +++ speak/index.html | 2 +- speak/script.js | 29 +++++++++++++++++++---------- speak/style.css | 5 ++++- 4 files changed, 27 insertions(+), 12 deletions(-) create mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..6f3a291 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "liveServer.settings.port": 5501 +} \ No newline at end of file diff --git a/speak/index.html b/speak/index.html index 0c8a476..6542ccb 100644 --- a/speak/index.html +++ b/speak/index.html @@ -7,7 +7,7 @@ - Document + Speak diff --git a/speak/script.js b/speak/script.js index d2ae51e..88225b9 100644 --- a/speak/script.js +++ b/speak/script.js @@ -5,6 +5,22 @@ const textInput = document.getElementById('text') const speedInput = document.getElementById('speed') let currentCharacter + +const utterance = new SpeechSynthesisUtterance() + +utterance.addEventListener('end', () => { + +textInput.disabled = false + +}) + +utterance.addEventListener('boundary', e => { + +currentCharacter = e.charIndex + +}) + + playButton.addEventListener('click', () => { playText(textInput.value) }) @@ -15,14 +31,6 @@ speedInput.addEventListener('input', () => { playText(utterance.text.substring(currentCharacter)) }) -const utterance = new SpeechSynthesisUtterance() -utterance.addEventListener('end', () => { - textInput.disabled = false -}) -utterance.addEventListener('boundary', e => { - currentCharacter = e.charIndex -}) - function playText(text) { if (speechSynthesis.paused && speechSynthesis.speaking) { @@ -40,6 +48,7 @@ function pauseText() { } function stopText() { - speechSynthesis.resume() - speechSynthesis.cancel() + speechSynthesis.resume(); + speechSynthesis.cancel(); + document.getElementById("text").value = "" } \ No newline at end of file diff --git a/speak/style.css b/speak/style.css index b088548..44c084a 100644 --- a/speak/style.css +++ b/speak/style.css @@ -11,7 +11,7 @@ display: flex; justify-self: center; margin: auto; width: 75%; -margin-top: 40%; +margin-top: 30vh; padding: 7px; border-radius: 15px; font-size: 2rem; @@ -27,6 +27,9 @@ label{ width: 1rem; } +#pause-button{ + display: none; +} .buttons_div{ display: flex; flex-direction: row;