TextToSpeechEngineDelegate

public protocol TextToSpeechEngineDelegate : AnyObject

Delegate for receiving updates about text-to-speech playback events. Provides methods to handle playback readiness, start, stop, pause, resume, completion, and errors.

The TextToSpeechEngineDelegate protocol defines a set of methods that a delegate of a TextToSpeechEngine object can implement to receive notifications about the status of text-to-speech playback. Implement these methods to handle playback events effectively.

Important

This is a Public Preview API. It may be changed or removed at any time.
  • onReady() Default implementation

    Notifies that the text-to-speech engine is ready.

    This method is called when the TTS engine has completed its initialization and is ready for playback.

    Default Implementation

    Default implementation for when the TTS engine is ready. The default implementation does nothing.

    Declaration

    Swift

    func onReady()
  • didFinish(message:) Default implementation

    Notifies that the playback of a message has finished.

    This method is called when the TTS engine completes playing a message.

    Default Implementation

    Default implementation for when a message has finished playing. The default implementation does nothing.

    Declaration

    Swift

    func didFinish(message: TTSMessage)

    Parameters

    message

    The TTSMessage that was played.

  • didFinish(message:withError:) Default implementation

    Notifies that an error occurred during playback of a message.

    This method is called when the TTS engine encounters an error while playing a message.

    Default Implementation

    Default implementation for when an error occurs during message playback. The default implementation does nothing.

    Declaration

    Swift

    func didFinish(message: TTSMessage, withError: Error)

    Parameters

    message

    The TTSMessage that was being played when the error occurred.

    withError

    The error that occurred.

  • didStart(message:) Default implementation

    Notifies that the playback of a message has started.

    This method is called when the TTS engine starts playing a message.

    Default Implementation

    Default implementation for when a message starts playing. The default implementation does nothing.

    Declaration

    Swift

    func didStart(message: TTSMessage)

    Parameters

    message

    The TTSMessage that is being played.

  • didStop(message:) Default implementation

    Notifies that the playback of a message has been stopped.

    This method is called when the TTS engine stops playing a message.

    Default Implementation

    Default implementation for when a message is stopped. The default implementation does nothing.

    Declaration

    Swift

    func didStop(message: TTSMessage)

    Parameters

    message

    The TTSMessage that was stopped.

  • didPause(message:) Default implementation

    Notifies that the playback of a message has been paused.

    This method is called when the TTS engine pauses playing a message.

    Default Implementation

    Default implementation for when a message is paused. The default implementation does nothing.

    Declaration

    Swift

    func didPause(message: TTSMessage)

    Parameters

    message

    The TTSMessage that was paused.

  • didContinue(message:) Default implementation

    Notifies that the playback of a message has been resumed after a pause.

    This method is called when the TTS engine resumes playing a message after it was paused.

    Default Implementation

    Default implementation for when a paused message is resumed. The default implementation does nothing.

    Declaration

    Swift

    func didContinue(message: TTSMessage)

    Parameters

    message

    The TTSMessage that was resumed.