TranscriptionStream constructor

TranscriptionStream(
  1. SseClient _client
)

Implementation

TranscriptionStream(this._client) {
  events = _client.stream.map((e) {
    final json = jsonDecode(e.data) as Map<String, dynamic>;
    return TranscriptEvent.fromJson(json); // cast helper
  });

  // Close when the terminal event arrives.
  events.where((ev) => ev is TranscriptTextDone).map(
        (_) async => await close(),
      );
}