LocalMode
Transformers

Speech-to-Text

Transcribe audio to text with Moonshine models.

Transcribe audio to text using Moonshine models running locally in the browser. Optimized for fast, efficient speech recognition with optional timestamps.

For full API reference (transcribe(), options, result types, and custom providers), see the Core Audio guide.

See it in action

Try Voice Notes and Meeting Assistant for working demos.

ModelSizeSpeedQualityUse Case
onnx-community/moonshine-tiny-ONNX~35MB⚡⚡⚡GoodQuick transcription, voice notes
onnx-community/moonshine-base-ONNX~65MB⚡⚡BetterHigher accuracy

Voice Notes Example

Based on the Voice Notes showcase app:

import { transformers } from '@localmode/transformers';
import { transcribe } from '@localmode/core';

const model = transformers.speechToText('onnx-community/moonshine-tiny-ONNX');

// Record audio from microphone
const stream = await navigator.mediaDevices.getUserMedia({ audio: true });
const recorder = new MediaRecorder(stream, { mimeType: 'audio/webm' });
const chunks: Blob[] = [];

recorder.ondataavailable = (e) => chunks.push(e.data);
recorder.start();

// Stop recording after some time...
recorder.stop();

recorder.onstop = async () => {
  const audioBlob = new Blob(chunks, { type: 'audio/webm' });

  const { text } = await transcribe({
    model,
    audio: audioBlob,
    abortSignal: controller.signal,
  });

  console.log('Transcription:', text);
};

With Timestamps

const { text, segments } = await transcribe({
  model,
  audio: audioBlob,
  returnTimestamps: true,
});

segments?.forEach((s) => {
  console.log(`[${s.start.toFixed(1)}s - ${s.end.toFixed(1)}s] ${s.text}`);
});

Audio Input Formats

The audio parameter accepts:

  • Blob — From MediaRecorder, file input, or fetch
  • ArrayBuffer — Raw audio data
  • Float32Array — PCM audio samples

Best Practices

STT Tips

  1. Start with moonshine-tiny — Fast to download (~35MB) and good enough for most use cases
  2. Use WebM or OGG — These formats work well with MediaRecorder
  3. Support cancellation — Transcription can take time; always pass abortSignal
  4. Handle permissions — Request microphone access gracefully with fallback UI

Showcase Apps

AppDescriptionLinks
Voice NotesRecord and transcribe audio with Moonshine modelsDemo · Source
Meeting AssistantTranscribe meeting recordings for summarizationDemo · Source

Next Steps

On this page