getStreamingAudio method

  1. @override
Stream<TextToSpeechResponseUpdate> getStreamingAudio(
  1. String text, {
  2. TextToSpeechOptions? options,
  3. CancellationToken? cancellationToken,
})
override

Synthesizes text into audio and returns a stream of response updates.

Implementation

@override
Stream<TextToSpeechResponseUpdate> getStreamingAudio(
  String text, {
  TextToSpeechOptions? options,
  CancellationToken? cancellationToken,
}) async* {
  developer.Timeline.startSync(
    '${OpenTelemetryConsts.textToSpeechSpanName}.streaming',
    arguments: _buildArguments(options),
  );
  try {
    yield* super.getStreamingAudio(
      text,
      options: options,
      cancellationToken: cancellationToken,
    );
    developer.Timeline.finishSync();
  } catch (e) {
    developer.Timeline.finishSync();
    rethrow;
  }
}