TextToSpeechEngine

public protocol TextToSpeechEngine

TextToSpeechEngine provides interface of the text to speech engine.

Important

This is a Public Preview API. It may be changed or removed at any time.
  • Defines supported alphabets of the phonetic transcriptions.

    Declaration

    Swift

    var supportedAlphabets: [String] { get }
  • A delegate to respond to events that occur during playback.

    Declaration

    Swift

    var delegate: TextToSpeechEngineDelegate? { get set }
  • A locale that defines the voice’s language.

    Declaration

    Swift

    var locale: Locale { get }
  • Initializes vocalization of the message.

    Declaration

    Swift

    func play(message: TTSMessage)

    Parameters

    message

    The TTSMessage that contains text message and options, that define how the message should be handled.

  • Immediately stops the playback.

    Declaration

    Swift

    func stop()
  • Sets the audio volume to one of the predefined levelas.

    Declaration

    Swift

    func setVolume(_ volume: SpeechVolume)

    Parameters

    volume

    One of the predefined volume levels.

  • Sets the language code of the messages.

    Throws

    TextToSpeechEngineError.unavailableLocaleInVoices if there is no speech voice for the given locale.

    Declaration

    Swift

    func changeLocale(with locale: Locale) throws

    Parameters

    locale

    The locale to change to.

  • Checks if the specified voice’s language is available on the device.

    Declaration

    Swift

    static func isLanguageAvailable(for locale: Locale) -> Bool

    Parameters

    locale

    Locale used to identify the language

    Return Value

    true if the specified language is available, false otherwise.