TomTomSDKTextToSpeechEngine
TomTomSDKTextToSpeechEngine
The Text To Speech Engine module defines a protocol that outlines the functionalities of the Text-to-Speech (TTS) engine. This module is essential for applications that require TTS capabilities, enabling the conversion of text messages into spoken audio.
With TextToSpeechEngine serving as the entry point.
Functionalities
- Supported Alphabets: The module defines available alphabets for phonetic transcriptions, ensuring that the TTS engine can accurately pronounce text across different languages.
- Playback Event Delegation: It includes a delegate property that allows for responding to events that occur during audio playback, enabling applications to manage user interactions effectively.
- Voice Localization: The module provides a locale property that defines the language of the voice used for playback, ensuring that users receive audio output in their preferred language.
API Overview
-
Defines various message types that can be consumed by the TTS engine. Specifies the format of the message content.
The
MessageType
enum provides two types of messages that can be processed by the Text-to-Speech (TTS) engine: plain text and Speech Synthesis Markup Language (SSML). Useplain
for simple text messages, andssml
for more complex messages that include speech synthesis markup tags.Important
This is a Public Preview API. It may be changed or removed at any time.Declaration
Swift
public enum MessageType
-
PhoneticPair
defines a pair of original string and its phonetic transcription.Defines a pair of an original string and its phonetic transcription. The purpose is to provide a way to handle and process phonetic representations of strings.
The
PhoneticPair
struct holds an original string and its phonetic transcription. It processes the phonetic transcription to replace unsupported IPA phonemes with ones supported byAVSpeechSynthesizer
. This is useful for text-to-speech operations where phonetic accuracy and compatibility are required.Important
This is a Public Preview API. It may be changed or removed at any time.Declaration
Swift
public struct PhoneticPair
-
Represents the phonetic transcription of a message part used in voice messages.
The
PhoneticTranscription
struct holds phonetic transcriptions for a message part, along with the languages in which the transcriptions are encoded, the tag for the original string, and the format of the phonetic transcriptions alphabet.Example usage:
let phoneticTranscription = PhoneticTranscription( transcriptions: [], languages: [Locale(identifier: "en-US")], tag: "exampleTag", alphabet: "IPA" )
Important
This is a Public Preview API. It may be changed or removed at any time.Declaration
Swift
public struct PhoneticTranscription : Equatable
-
Defines volume levels for speech output. Provides different volume levels that can be set for speech output independently of the device’s sound volume.
The
SpeechVolume
enum specifies three volume levels (low
,medium
,high
) that can be set for speech output. This is useful in scenarios where speech volume needs to be adjusted independently of the device’s overall sound volume. For example, a navigation app might use this to ensure that voice instructions are clearly audible regardless of the device’s current volume settings.Example usage:
let speechVolume: SpeechVolume = .medium // Use `speechVolume` to set the desired volume level for speech output.
Important
This is a Public Preview API. It may be changed or removed at any time.Declaration
Swift
public enum SpeechVolume
-
Defines a message that should be vocalized. Represents different types of text-to-speech messages that can be vocalized.
The
TTSMessage
enum specifies different types of messages that can be used in text-to-speech (TTS) operations. It provides cases for messages with handling options and messages with phonetic transcriptions. This is useful in scenarios where text needs to be converted to speech with specific handling options or phonetic accuracy.Example usage:
let ttsMessage: TTSMessage = .audio(message: "Welcome to TomTom!", type: .plain) // Use `ttsMessage` to vocalize the message.
Important
This is a Public Preview API. It may be changed or removed at any time.Declaration
Swift
public enum TTSMessage : Equatable
-
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.Declaration
Swift
public protocol TextToSpeechEngine
-
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 aTextToSpeechEngine
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.Declaration
Swift
public protocol TextToSpeechEngineDelegate : AnyObject
-
Errors that can occur in the TextToSpeechEngine.
The
TextToSpeechEngineError
enum defines the error types that can be encountered when using theTextToSpeechEngine
. These errors provide information about specific issues such as unsupported alphabets in phonetics or unavailable voices for a set locale.Important
This is a Public Preview API. It may be changed or removed at any time.Declaration
Swift
public enum TextToSpeechEngineError : Error