Push: openStream
Pull: transcribeStream
Signatures
openStream returns a promise here.
Live from the microphone
MediaStream keeps the browser’s
recording indicator lit.
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Transcribe speech as it arrives
const stream = await RunAnywhere.stt.openStream({
encoding: 'pcmF32Le',
sampleRate: 16000,
channels: 1,
})
// per buffer
stream.pushFrame({ samples, sampleCount })
// when the utterance ends
stream.flush()
stream.finish()
await stream.close()
for await (const event of RunAnywhere.stt.transcribeStream(audioIterable)) {
if (event.type === 'partial') preview.textContent = event.text
if (event.type === 'final') transcript += event.transcription.text
}
openStream(format: AudioFormatSpec, options?: SttOptions): Promise<SttStream>
transcribeStream(audio: AsyncIterable<AudioInput>, options?: SttOptions): AsyncIterable<TranscriptionEvent>
openStream returns a promise here.
import { AudioCapture } from '@runanywhere/web/browser'
const capture = new AudioCapture()
const stream = await RunAnywhere.stt.openStream({
encoding: 'pcmF32Le',
sampleRate: 16000,
channels: 1,
})
capture.onFrame((frame) => stream.pushFrame(frame))
await capture.start()
stopButton.addEventListener('click', async () => {
await capture.stop()
stream.flush()
stream.finish()
await stream.close()
})
MediaStream keeps the browser’s
recording indicator lit.