Skip to content

Instantly share code, notes, and snippets.

@brito
Created June 25, 2022 23:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brito/112dc5d3ac0a1bdc53ac889f0c1cd698 to your computer and use it in GitHub Desktop.
Save brito/112dc5d3ac0a1bdc53ac889f0c1cd698 to your computer and use it in GitHub Desktop.
Minimal webkit speech recognition and synthesis demo
// Voice Driven Web Apps
//developer.chrome.com/blog/voice-driven-web-apps-introduction-to-the-web-speech-api
with (new webkitSpeechRecognition)
continuous =
interimResults =
true,
onstart =
onerror =
onend =
console.info,
voice = speechSynthesis.getVoices()[50],
onresult =
e => [...e.results]
.map(result => {
with(result[0])
if (result.isFinal)
speechSynthesis.speak(new SpeechSynthesisUtterance(transcript)),
stop()
else
(confidence > .618 ? console.warn : console.debug)(result[0])
}),
start()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment