📚 Encyclopedia

Web Development · updated 2026-10-13

Browser dictation with Web Speech and MediaRecorder

web-speechspeechrecognitionmediarecordermicrophonechrome

A web page can do live speech-to-text and keep the raw audio at the same time, with no server, by combining SpeechRecognition (Web Speech API) with MediaRecorder. Built into the Story app (~/dev/story, July 2026), a local tool for dictating story ideas and having Claude arrange them.

Setup

  1. Call navigator.mediaDevices.getUserMedia({audio: true}) first. One permission prompt then covers both the recorder and recognition.
  2. Start a MediaRecorder on that stream; on stop, assemble the chunks into a Blob and store it (IndexedDB handles blobs well). Play takes back with URL.createObjectURL(blob).
  3. Start recognition: new (window.SpeechRecognition || window.webkitSpeechRecognition)() with continuous = true, interimResults = true, lang = navigator.language.
  4. In onresult, append final results to the text with sensible spacing, and show interim results separately (a "listening" bar) so they do not get committed twice.

Gotchas

See also

Linked from

Sources: story project memory