From 856f6b76b57ff7dee09d387da48c823b81d4797a Mon Sep 17 00:00:00 2001 From: AJOO7 <67185443+AJOO7@users.noreply.github.com> Date: Sun, 24 Jan 2021 00:37:53 +0530 Subject: [PATCH] Update script.js --- script.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/script.js b/script.js index 760c548..4b7f4c5 100644 --- a/script.js +++ b/script.js @@ -11,8 +11,11 @@ playButton.addEventListener('click', () => { pauseButton.addEventListener('click', pauseText) stopButton.addEventListener('click', stopText) speedInput.addEventListener('input', () => { - stopText() + if (speechSynthesis.speaking) { + stopText() playText(utterance.text.substring(currentCharacter)) + } + }) const utterance = new SpeechSynthesisUtterance() @@ -41,4 +44,4 @@ function pauseText() { function stopText() { speechSynthesis.resume() speechSynthesis.cancel() -} \ No newline at end of file +}