TextToSpeech
final class TextToSpeech : @unchecked SendableMediaPipe TextToSpeech task interface for Swift (iOS / macOS).
-
Creates and initializes a
TextToSpeechinstance configured withTextToSpeechOptions.Declaration
Swift
public init(options: TextToSpeechOptions) throws -
Queries available voices for this initialized
TextToSpeechinstance.Declaration
Swift
public func listVoices() throws -> [TtsVoiceInfo] -
Synchronously synthesizes text and returns the
TtsAudioResult.Declaration
Swift
public func synthesize(_ text: String, options: TtsSynthesisOptions? = nil) throws -> TtsAudioResult -
Asynchronously synthesizes text off the main thread with structured concurrency cancellation.
Declaration
Swift
public func synthesizeAsync(_ text: String, options: TtsSynthesisOptions? = nil) async throws -> TtsAudioResult -
Streams synthesized PCM
TtsAudioChunkvalues as each sentence completes.Declaration
Swift
public func synthesizeStream(_ text: String, options: TtsSynthesisOptions? = nil) -> AsyncThrowingStream -
Opens a
TtsStreamfor incremental LLM text streaming (pushText+finishInput) or pull iteration (readNext).Declaration
Swift
public func openStream(_ initialText: String = "", options: TtsSynthesisOptions? = nil, finishInput: Bool = false) throws -> TtsStream -
Thread-safe, lock-free barge-in cancellation of any in-flight synthesis.
Declaration
Swift
public func cancel()