SpeechStream constructor

SpeechStream(
  1. SseClient _client
)

Implementation

SpeechStream(this._client) {
  events = _client.stream.map((sse) {
    final json = jsonDecode(sse.data) as Map<String, dynamic>;
    return SpeechEvent.fromJson(json);
  });

  // Auto-close once we see the terminal event.
  events.where((e) => e is SpeechAudioDone || e is TranscriptTextDone).map((_) async => await close());
}