Skip to content

Instantly share code, notes, and snippets.

@yfuruyama
Created January 12, 2019 13:30
Show Gist options
  • Save yfuruyama/fb9fc99b2fcffe450dda69428419ba3a to your computer and use it in GitHub Desktop.
Save yfuruyama/fb9fc99b2fcffe450dda69428419ba3a to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<script>
var recognition = new webkitSpeechRecognition();
recognition.lang = 'en-US';
recognition.continuous = true;
recognition.interimResults = true;
recognition.onresult = function(event) {
if (event.results.length > 0) {
const result = event.results[event.resultIndex]
console.log(result);
if (result.isFinal) {
document.getElementById('results').value += result[0].transcript + ", ";
}
}
}
</script>
</head>
<body style="margin-left: 100px;">
<div>
<h1>Speech Recognition</h1>
<input type="button" value="Start" onclick="recognition.start()">
<input type="button" value="Stop" onclick="recognition.stop()">
</div>
<div>
<textarea style="font-family: inherit; font-size: 200%; padding: 20px;" id="results" cols="60" rows="10"></textarea>
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment