# TTSStream

    final class TTSStream: Sendable

Bidirectional / pull-based streaming synthesis handle supporting Level 2 incremental LLM text pushing (`pushText` + `finishInput`) alongside `readNext()` and `cancel()`.
- `
  ### [cancel()](https://developers.google.com/edge/api/mediapipe/swift/audio/Classes/TTSStream.md.txt#/s:19MediaPipeTasksAudio9TTSStreamC6cancelyyF)

  ` Lock-free cancellation for this stream.

  #### Declaration

  Swift

      final func cancel()

- `
  ### [close()](https://developers.google.com/edge/api/mediapipe/swift/audio/Classes/TTSStream.md.txt#/s:19MediaPipeTasksAudio9TTSStreamC5closeyyF)

  ` 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()

- `
  ### [finishInput()](https://developers.google.com/edge/api/mediapipe/swift/audio/Classes/TTSStream.md.txt#/s:19MediaPipeTasksAudio9TTSStreamC11finishInputyyKF)

  ` Marks the end of incremental text input, flushing any trailing partial sentence.

  #### Declaration

  Swift

      final func finishInput() throws

- `
  ### [pushText(_:)](https://developers.google.com/edge/api/mediapipe/swift/audio/Classes/TTSStream.md.txt#/s:19MediaPipeTasksAudio9TTSStreamC8pushTextyySSKF)

  ` Appends an incremental text fragment into the sentence chunker.

  #### Declaration

  Swift

      final func pushText(_ textDelta: String) throws

- `
  ### [readNext()](https://developers.google.com/edge/api/mediapipe/swift/audio/Classes/TTSStream.md.txt#/s:19MediaPipeTasksAudio9TTSStreamC8readNextAA0D5ChunkVSgyKF)

  ` 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?