Skip to main content

Overview

Streaming STT (also called “online” recognition) enables real-time transcription as audio is being captured. Unlike offline STT which processes complete files, streaming STT:
  • Provides partial results as you speak
  • Detects end-of-utterance automatically
  • Works with live microphone input
  • Supports low-latency applications like voice assistants
Use streaming STT when:
  • You need real-time transcription during recording
  • You want to show partial results to users
  • You’re building voice assistants or live captioning
Use offline STT when:
  • You have complete audio files to transcribe
  • You don’t need real-time results
  • You’re processing pre-recorded audio

Supported Models

Only specific model types support streaming:
Offline-only models like Whisper, SenseVoice, and Dolphin do not support streaming. Use getOnlineTypeOrNull() to check if a model supports streaming.

Quick Start

Checking Model Support

Before creating a streaming engine, check if the model supports streaming:

API Reference

createStreamingSTT(options)

Creates a streaming STT engine for real-time recognition.
src/stt/streaming.ts
Options:
ModelPathConfig
required
Model directory path configuration. Use { type: 'asset', path: '...' } for bundled models.
OnlineSTTModelType | 'auto'
default:"auto"
Model type: 'transducer', 'paraformer', 'zipformer2_ctc', 'nemo_ctc', 'tone_ctc', or 'auto' to detect.
boolean
default:"true"
Enable automatic end-of-utterance detection.
EndpointConfig
Fine-tune endpoint detection rules. See Endpoint Detection.
'greedy_search' | 'modified_beam_search'
default:"greedy_search"
Decoding algorithm. Beam search is slower but may be more accurate.
number
default:"4"
Beam size for beam search decoding.
string
Path to hotwords file (transducer models only).
number
default:"1.5"
Hotwords boost score.
number
default:"1"
Number of threads for inference.
string
default:"cpu"
Execution provider (e.g., 'cpu', 'qnn', 'nnapi').
boolean
default:"true"
Automatically scale audio chunks to optimal levels. Disable if your audio is already normalized.

StreamingSttEngine

The engine manages the recognizer and creates streams.
string
Read-only engine identifier.
(hotwords?: string) => Promise<SttStream>
Creates a new recognition stream. Optional hotwords string for per-stream contextual biasing.
() => Promise<void>
Releases native resources. Must be called when done.

SttStream

A stream represents one recognition session (e.g., one utterance).

acceptWaveform(samples, sampleRate)

Feed audio samples to the stream.

isReady()

Check if there’s enough audio buffered to decode.

decode()

Run decoding on buffered audio. Call when isReady() returns true.

getResult()

Get the current partial or final result.

isEndpoint()

Check if end-of-utterance was detected.

reset()

Reset stream state for reuse. Call after endpoint or to start a new utterance.

inputFinished()

Signal that no more audio will be fed. Use when recording stops.

release()

Release native stream resources. Do not use the stream after this.

processAudioChunk(samples, sampleRate)

Convenience method that combines accept + decode + getResult in one call.
Use processAudioChunk() to reduce bridge round-trips from 5 calls to 1 per audio chunk.

Endpoint Detection

Endpoint detection automatically determines when the user has stopped speaking.

Default Rules

Three rules are evaluated in order (first match wins):
  1. Rule 1: 2.4s of trailing silence (no speech required)
  2. Rule 2: 1.4s of trailing silence + speech detected
  3. Rule 3: Max utterance length of 20s

Custom Endpoint Configuration

Live Microphone Integration

For live microphone capture with automatic resampling, use the PCM Live Stream API:

Common Patterns

Typical Recognition Loop

Using processAudioChunk (Simplified)

Multiple Streams

Create multiple streams from one engine (e.g., for different channels):

Hotwords in Streaming

For transducer models, you can use hotwords for contextual biasing:

Input Normalization

By default, processAudioChunk() applies adaptive normalization to handle varying microphone levels:
Normalization scales each chunk so the peak is around 0.8, which helps with quiet iOS mics or varying Android devices.

Performance Tips

Threading

Hardware Acceleration

Reduce Latency

  • Use processAudioChunk() instead of separate method calls
  • Keep audio chunk sizes reasonable (e.g., 0.1s - 0.5s worth of samples)
  • Increase numThreads on multi-core devices
  • Use hardware acceleration when available

Troubleshooting

Only transducer, paraformer, zipformer2_ctc, nemo_ctc, and tone_ctc support streaming. Whisper, SenseVoice, and Dolphin are offline-only. Use getOnlineTypeOrNull() to check support.
  • Ensure audio is 16 kHz mono
  • Check microphone permissions and quality
  • Verify audio samples are in range [-1, 1]
  • Try disabling enableInputNormalization if audio is already normalized
  • Increase hotwordsScore for better keyword recognition
Adjust endpointConfig rules:
  • Too early: Increase minTrailingSilence
  • Too late: Decrease minTrailingSilence
  • For long utterances: Increase minUtteranceLength in rule3
  • Reduce audio chunk size
  • Increase numThreads
  • Use hardware acceleration (QNN, NNAPI)
  • Use processAudioChunk() to reduce bridge calls

Next Steps

Offline STT

Transcribe complete audio files

Model Setup

Learn how to bundle and load models

Execution Providers

Hardware acceleration options

Text-to-Speech

Generate speech from text