demo · v135

Live transcription bench

Pass a microphone MediaStreamTrack directly to SpeechRecognition.start(track) and watch the same source drive both an audio meter and live transcript. Switch to a processed Web Audio output to confirm the recognizer can consume a track produced by a filter chain, not only the default mic.

SpeechRecognition: ? start(track): ?

Audio meters

Raw microphone

Processed output

source: idle track: none

Live transcript

-
recognizer: idle

the code

const stream = await navigator.mediaDevices.getUserMedia({ audio: true });
const micTrack = stream.getAudioTracks()[0];

const ctx = new AudioContext();
const src = ctx.createMediaStreamSource(stream);
const filter = ctx.createBiquadFilter();
const dest = ctx.createMediaStreamDestination();
src.connect(filter);
filter.connect(dest);

const track = useProcessedOutput
  ? dest.stream.getAudioTracks()[0]
  : micTrack;

const rec = new SpeechRecognition();
rec.continuous = true;
rec.interimResults = true;
rec.start(track);             // Chrome 135+
track.onended = () => rec.abort();

see also