Streaming STT provides real-time transcription as audio is being captured, without waiting for the full recording to complete. This enables live captioning, real-time voice interfaces, and interactive dictation.
import { STT } from '@runanywhere/web'// Create a streaming sessionconst session = STT.createStreamingSession()// Feed audio chunks as they arrive from the microphonefunction onAudioChunk(samples: Float32Array) { session.acceptWaveform(samples) // Check for partial results const result = session.getResult() if (result.text) { console.log('Partial:', result.text) }}// When done speakingsession.inputFinished()const finalResult = session.getResult()console.log('Final:', finalResult.text)// Clean upsession.destroy()
interface STTStreamingSession { /** Feed audio samples into the session */ acceptWaveform(samples: Float32Array, sampleRate?: number): void /** Signal that no more audio will be provided */ inputFinished(): void /** Get the current transcription result */ getResult(): { text: string; isEndpoint: boolean } /** Reset the session for a new utterance */ reset(): void /** Release all resources */ destroy(): void}