> ## Documentation Index
> Fetch the complete documentation index at: https://docs.runanywhere.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Streaming STT

> Transcribe speech as it arrives

Two shapes. Pick by where your audio comes from.

## Push: openStream

```dart theme={"theme":"css-variables"}
final stream = await RunAnywhere.stt.openStream(
  AudioFormatSpec(
    encoding: AudioEncoding.pcmF32Le,
    sampleRate: 16000,
    channels: 1,
  ),
);

// per buffer
stream.pushFrame(AudioFrame(samples: bytes, sampleCount: count));

// when the utterance ends
stream.flush();
stream.finish();
await stream.close();
```

`openStream` returns a `Future` here.

## Pull: transcribeStream

```dart theme={"theme":"css-variables"}
await for (final event in RunAnywhere.stt.transcribeStream(audioStream)) {
  if (event is TranscriptionEventPartial) {
    setState(() => _preview = event.text);
  }
  if (event is TranscriptionEventFinal) {
    setState(() => _transcript += event.transcription.text);
  }
}
```

## Signatures

```dart theme={"theme":"css-variables"}
Future<SttStream> openStream(AudioFormatSpec format, {SttOptions? options})
Stream<TranscriptionEvent> transcribeStream(Stream<AudioInput> audio, {SttOptions? options})
```

## Driving it from a recorder

```dart theme={"theme":"css-variables"}
final sttStream = await RunAnywhere.stt.openStream(
  AudioFormatSpec(
    encoding: AudioEncoding.pcmF32Le,
    sampleRate: 16000,
    channels: 1,
  ),
);

final subscription = recorder.audioStream.listen((chunk) {
  sttStream.pushFrame(AudioFrame(samples: chunk, sampleCount: chunk.length ~/ 4));
});

// when the user stops
await subscription.cancel();
sttStream.flush();
sttStream.finish();
await sttStream.close();
await recorder.stop();
```

Cancel the subscription and close the stream in `dispose`, or the microphone stays live.

## AudioCaptureManager

`package:runanywhere/runanywhere.dart` exports `AudioCaptureManager`, which wraps the native
capture path the voice session uses. Prefer it over wiring a recorder by hand.

## Choosing between them

Push suits a live microphone, since a recorder already hands you buffers in a callback. Pull
suits a source you can express as a `Stream<AudioInput>`.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.