Speech to Text in the Browser - No Backend, No Bill

The browser can listen as well as speak. Using the SpeechRecognition API, I built a multilingual voice-to-text app with copy, download, and live interim results - zero server, zero cost. Part 2 of the build-it-small series.

In part 1 of this series I used the browser's SpeechSynthesis API to make it speak. This time it listens.

The SpeechRecognition API is the other half of the Web Speech API. Same idea: built into the browser, free, no account required. You speak, the browser transcribes. Live.

The API

const SpeechRecognition = window.SpeechRecognition || window.webkitSpeechRecognition
const recognition = new SpeechRecognition()

recognition.lang = 'en-US'
recognition.continuous = true
recognition.interimResults = true

recognition.onresult = (e) => {
  // e.results contains both interim and final segments
}

recognition.start()

Two flags matter here:

  • continuous: true keeps the microphone open after a pause instead of stopping after the first sentence
  • interimResults: true sends partial results as you speak, so the text appears live rather than only after you stop

Interim vs Final Results

Each result in e.results has an isFinal flag. Final results are locked in. Interim results are the engine's best current guess and may change as you keep talking.

recognition.onresult = (e) => {
  let final = ''
  let interim = ''

  for (let i = 0; i < e.results.length; i++) {
    if (e.results[i].isFinal) {
      final += e.results[i][0].transcript + ' '
    } else {
      interim += e.results[i][0].transcript
    }
  }

  setTranscript((prev) => prev + final)
  setInterim(interim)
}

In the UI, final text appears in solid white and interim text appears dimmed - so you can see what is confirmed versus what is still being processed.

What I Built

For project 02 of the build-it-small series, I built a clean multilingual STT app with React and Tailwind. Features:

  • 8 language options: English (US/UK), Spanish, Portuguese, French, German, Italian, Japanese
  • Live interim results shown as you speak, in a lighter colour
  • Word count that updates in real time
  • Copy to clipboard with a confirmation tick
  • Download transcript as a .txt file
  • Clear button to start fresh
  • Works entirely in the browser, zero backend

Browser Support

This is the one limitation worth knowing. SpeechRecognition works well in Chrome and Edge on desktop. Firefox does not support it. Safari has partial support. If you need it to work everywhere, you would need a cloud fallback - but for most use cases, Chrome is fine.

The app shows a clear error state when the browser does not support the API.

Why This Matters

Voice input is the fastest way most people can produce text. Faster than typing, faster than dictation apps that bill per minute. For note-taking, journaling, meeting transcription, or accessibility tools, the browser is good enough - and free.

Combined with project 01 (Text to Speech), you now have both directions of the Web Speech API working in the browser. In the final project of this series, both will come together in a single app.

The Stack

  • React 18 + Vite
  • Tailwind CSS
  • Zero dependencies beyond that
  • No backend, no environment variables

Clone it, run npm install && npm run dev, and start speaking.

Try It

Source on GitHub: github.com/paolinellih/build-it-small

Look in the 02-stt-browser folder.

Previous in the series: Text to Speech in the Browser

More articles