Created
May 23, 2021 20:51
-
-
Save trupakufi/684f5eee07391b38d0023284ab84645a to your computer and use it in GitHub Desktop.
Um robô que lê conteúdo Digitado pelo Usuário, Javacript, Speech Utterance.
This file contains hidden or 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
<body class="m-auto text-center"> | |
<div | |
class="border border-purple m-4" | |
contenteditable | |
oninput="setText(event)"> Seu texto Aqui </div> | |
<button | |
onclick="speak()" | |
class="p-4 bg-purple-200 rounded shadow"> Falar </button> | |
<button | |
onclick="stop()" | |
class="p-4 bg-purple-700 text-white rounded shadow"> Parar </button> | |
<body> |
This file contains hidden or 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 utterance = new SpeechSynthesisUtterance(); | |
utterance.lang = "pt-BR"; | |
//utterance.rate = 2; | |
function speak() { | |
speechSynthesis.speak(utterance); | |
} | |
function stop() { | |
speechSynthesis.cancel(); | |
} | |
function setText(event) { | |
utterance.text = event.target.innerText; | |
} |
This file contains hidden or 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
@import "https://cdnjs.cloudflare.com/ajax/libs/tailwindcss/1.8.10/tailwind.min.css"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment