TextToSpeechEngine
public protocol TextToSpeechEngine
Interface for a text-to-speech engine, providing methods to vocalize messages, manage playback, and configure settings. Allows applications to convert text messages into spoken words using various voices and languages.
The TextToSpeechEngine protocol defines the necessary functions and properties for implementing a text-to-speech engine.
It supports multiple languages and provides functionalities to start, stop, and configure playback. Additionally, it enables setting
the audio volume and changing the language of the messages.
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 (starts playback) of the given message.
Declaration
Swift
func play(message: TTSMessage)Parameters
messageThe
TTSMessagethat contains the text message and options defining how the message should be handled. -
Immediately Stops any ongoing text-to-speech playback.
Declaration
Swift
func stop() -
Allows setting the audio volume of the text-to-speech playback to one of the predefined levels.
Declaration
Swift
func setVolume(_ volume: SpeechVolume)Parameters
volumeOne of the predefined volume levels.
-
Sets the language for the text-to-speech engine to the specified locale, if a speech voice is available for that locale.
Throws
TextToSpeechEngineError.unavailableLocaleInVoicesif there is no speech voice for the givenlocale.Declaration
Swift
func changeLocale(with locale: Locale) throwsParameters
localeThe locale to change to.
-
Checks if the text-to-speech engine supports the specified locale.
Declaration
Swift
static func isLanguageAvailable(for locale: Locale) -> BoolParameters
localeLocale used to identify the language.
Return Value
trueif the specified language is available,falseotherwise.
TomTom SDK for iOS (0.71.1)
TextToSpeechEngine