MediaPipeTasksAudio Framework Reference

TTSStream

final class TTSStream: Sendable

Bidirectional / pull-based streaming synthesis handle supporting Level 2 incremental LLM text pushing (pushText + finishInput) alongside readNext() and cancel().

  • Lock-free cancellation for this stream.

    Declaration

    Swift

    final func cancel()
  • Cancels any in-flight synthesis and marks this stream as closed.

    The underlying native MpTextToSpeechStreamPtr is destroyed in deinit once all in-flight calls on self have returned.

    Declaration

    Swift

    final func close()
  • Marks the end of incremental text input, flushing any trailing partial sentence.

    Declaration

    Swift

    final func finishInput() throws
  • Appends an incremental text fragment into the sentence chunker.

    Declaration

    Swift

    final func pushText(_ textDelta: String) throws
  • Pulls the next synthesized AudioChunk synchronously on the calling thread, or returns nil when the stream reaches end-of-stream.

    Declaration

    Swift

    final func readNext() throws -> AudioChunk?