Skip to content

Instantly share code, notes, and snippets.

@trupakufi
Created May 23, 2021 20:51
Show Gist options
  • Save trupakufi/684f5eee07391b38d0023284ab84645a to your computer and use it in GitHub Desktop.
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.
<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>
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;
}
@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