twin_stream library

TwinStream

Simultaneous speech-to-text and audio file recording for Flutter.

Solves the Android microphone lock issue that prevents using recording and speech recognition at the same time.

Quick Start

import 'package:twin_stream/twin_stream.dart';

final controller = TwinStreamController();
await controller.initialize();

controller.stateStream.listen((state) {
  print('Live transcript: ${state.currentTranscript}');
});

await controller.start();
// ... user speaks ...
final result = await controller.stop();

print('Audio: ${result.audioFilePath}');
print('Text: ${result.transcript}');

controller.dispose();

Classes

TwinStreamConfig
Configuration for a TwinStream session.
TwinStreamController
Main controller for simultaneous speech-to-text and audio recording.
TwinStreamResult
The result of a completed TwinStream session.
TwinStreamState
An immutable snapshot of the TwinStream controller's current state.

Enums

AndroidRecordingStrategy
Defines how TwinStream handles simultaneous recording and speech recognition on Android, where the OS restricts shared microphone access.
TwinStreamStatus
Status of the TwinStream controller.

Exceptions / Errors

TwinStreamException
Base exception for all TwinStream errors.
TwinStreamInitializationException
Thrown when the TwinStream controller fails to initialize.
TwinStreamMicrophoneLockException
Thrown when the microphone is locked by another process or plugin, typically on Android when attempting simultaneous access.
TwinStreamPermissionException
Thrown when the required microphone or speech recognition permissions have not been granted by the user.
TwinStreamRecordingException
Thrown when an error occurs during an active recording or speech recognition session.