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 +}