Created
February 7, 2018 14:38
-
-
Save yskszk63/414e87c0d143c4dd45b2cdfa8ed28090 to your computer and use it in GitHub Desktop.
I can speak.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<form> | |
<input type="text" class="content" value="" autofocus placeholder="Input text for speak. And enter key press."/> | |
</form> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const $form = document.querySelector('form'); | |
const $text = document.querySelector('.content'); | |
$form.addEventListener('submit', event => { | |
event.preventDefault(); | |
const text = $text.value; | |
if (!text) { | |
return; | |
} | |
const uttar = new SpeechSynthesisUtterance($text.value); | |
$text.value = ''; | |
uttar.addEventListener('end', () => { | |
console.log("END"); | |
window.speaking = null; | |
}); | |
speechSynthesis.speak(uttar); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
input { | |
font-size: 32px; | |
width: 100%; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment