Skip to content

RevAISTT

Add real-time speech recognition with punctuated, confidence-scored transcripts to your voice pipeline using Rev AI's streaming WebSocket API.

Use RevAISTT when you need real-time transcription with punctuated, confidence-scored final transcripts, profanity filtering, disfluency removal, and custom vocabularies across nine languages.

Prerequisites

No peer dependencies are required. RevAISTT connects through a raw WebSocket managed by the SDK’s built-in WebSocketManager.

For production, set up a proxy server so your access token stays server-side.

Basic setup

import { CompositeVoice, MicrophoneInput, RevAISTT, AnthropicLLM, NativeTTS } from 'composite-voice';

const agent = new CompositeVoice({
  providers: [
    new MicrophoneInput(),
    new RevAISTT({
      proxyUrl: '/api/proxy/revai',
    }),
    new AnthropicLLM({
      proxyUrl: '/api/proxy/anthropic',
      model: 'claude-haiku-4-5',
      systemPrompt: 'You are a helpful voice assistant. Keep responses brief.',
    }),
    new NativeTTS(),
  ],
});

await agent.initialize();
await agent.startListening();

Configuration options

OptionTypeDefaultDescription
proxyUrlstringURL of your CompositeVoice proxy endpoint (recommended)
apiKeystring | () => Promise<string>Rev AI access token, or an async factory returning one
contentTypestringbuilt from audio optionsFull content_type override (e.g. 'audio/x-flac')
layoutstring'interleaved'Channel layout for raw audio
sampleRatenumber16000Audio sample rate in Hz (8000-48000, raw audio only)
audioFormatstring'S16LE'Raw sample format (case-sensitive GStreamer string)
numChannelsnumber1Number of audio channels (1-10, raw audio only)
languagestring'en'Language code (en, fr, de, it, ja, ko, cmn, pt, es)
filterProfanitybooleanfalseReplace profanities with asterisks (English only)
removeDisfluenciesbooleanfalseRemove “ums” and “uhs” (English only)
customVocabularyIdstringCustom vocabulary for domain-specific terms
detailedPartialsbooleanfalseTimestamps and confidence on partial hypotheses
maxSegmentDurationSecondsnumberForce a final hypothesis every 5-30 seconds
transcriberstringRev AI defaultTranscription model (e.g. 'machine_v2')
enableSpeakerSwitchbooleanfalseLabel speaker changes (requires machine_v2)
skipPostprocessingbooleanfalseSkip capitalization/punctuation for lower latency
prioritystring'speed''speed' or 'accuracy' (English/Spanish, machine_v2)
interimResultsbooleantrueEmit partial transcripts while the user speaks
timeoutnumber10000Connection timeout in milliseconds

See the API reference for the full list.

Complete example

import { CompositeVoice, MicrophoneInput, RevAISTT, AnthropicLLM, NativeTTS } from 'composite-voice';

const agent = new CompositeVoice({
  providers: [
    new MicrophoneInput(),
    new RevAISTT({
      proxyUrl: '/api/proxy/revai',
      language: 'en',
      filterProfanity: true,
      maxSegmentDurationSeconds: 10,
    }),
    new AnthropicLLM({
      proxyUrl: '/api/proxy/anthropic',
      model: 'claude-haiku-4-5',
      maxTokens: 256,
      systemPrompt: 'You are a helpful voice assistant. Keep responses under two sentences.',
    }),
    new NativeTTS({ voiceLang: 'en-US' }),
  ],
  conversationHistory: { enabled: true, maxTurns: 10 },
  logging: { enabled: true, level: 'info' },
});

agent.on('transcription.final', (event) => {
  console.log('User said:', event.text);
});

agent.on('response.text', (event) => {
  console.log('Assistant:', event.text);
});

await agent.initialize();
await agent.startListening();

Utterance completion

Rev AI streams two kinds of hypotheses. partial hypotheses are the engine’s best guess of the words spoken so far — RevAISTT joins them into interim results as you speak. When the engine is confident in a segment (typically after a pause, or when maxSegmentDurationSeconds elapses), it sends a final hypothesis with punctuation, capitalization, per-word timestamps, and confidence scores. The provider emits each final hypothesis with utteranceComplete: true, which is the flag CompositeVoice checks to trigger LLM processing.

Tune maxSegmentDurationSeconds (5-30) to force finals sooner during long monologues, at a small accuracy cost.

Tips and gotchas

  • Always keep keys server-side in production. Rev AI authenticates the WebSocket via an access_token query parameter (upgrade headers are not supported), so a browser-visible apiKey ends up on the connection URL. Pass proxyUrl instead — the proxy appends the token server-side.
  • No peer dependencies. RevAISTT uses the SDK’s built-in WebSocketManager — no extra packages to install.
  • Declare your audio format up front. The content_type is fixed for the session and must match the streamed audio exactly. The default (audio/x-raw;layout=interleaved;rate=16000;format=S16LE;channels=1) matches MicrophoneInput’s 16 kHz mono PCM output.
  • Wait-for-connected is handled for you. Rev AI requires clients to wait for its connected message before sending audio; connect() does not resolve until it arrives.
  • English-only options. filterProfanity, removeDisfluencies, and customVocabularyId cannot be combined with a non-English language.
  • Word detail in metadata. Final results include metadata.elements — the hypothesis elements with per-word timing (ts/end_ts), confidence, and speaker_id labels when enableSpeakerSwitch is on.
  • Errors arrive as close codes. Rev AI closes the socket with 4001 (bad token), 4002 (bad content_type), or 4013 (no worker available). The provider maps these to descriptive errors and emits an error result on an established session.
  • Graceful disconnect. When you call disconnect(), the provider sends the EOS text frame so Rev AI returns the last final hypothesis before closing. Never close the socket without EOS — Rev AI treats that as an invalid payload (1007).
  • No preflight signals. RevAISTT does not emit preflight/eager end-of-turn events. If you need the eager LLM pipeline, use DeepgramFlux instead.

© 2026 CompositeVoice. All rights reserved.

Font size
Contrast
Motion
Transparency