Created
January 12, 2019 13:30
-
-
Save yfuruyama/fb9fc99b2fcffe450dda69428419ba3a to your computer and use it in GitHub Desktop.
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
<!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