TomTomSDKDefaultTextToSpeech
TomTomSDKDefaultTextToSpeech
The Default Text To Speech module provides the default implementation of the TextToSpeechEngine protocol. It serves as a core component for enabling Text-to-Speech (TTS) functionality within navigation applications, ensuring that voice instructions are generated accurately and efficiently.
For more detailed examples and use cases, refer to the following documentation:
API Overview
-
Provides text-to-speech capabilities using the system’s speech synthesis engine. Converts text into speech using the specified language and optional gender preferences.
This class leverages the
AVSpeechSynthesizer
to convert text messages into spoken voice. It allows customization of the voice’s language and gender. It supports various message formats, including plain text and Speech Synthesis Markup Language (SSML).You could use the following code to check if the specific voice for the given language is present on your device or not.
import AVFoundation let languageCode = "en-US" // you can change this to the desired language code if SystemTextToSpeechEngine.isVoiceAvailable(for: languageCode) { // Creates an instance of ``SystemTextToSpeechEngine`` } else { // Guide the user to download the voice or use a fallback }
For more details about the
AVSpeechSynthesisVoice
read the Apple documentation: https://developer.apple.com/documentation/avfaudio/avspeechsynthesisvoiceImportant
This is a Public Preview API. It may be changed or removed at any time.Declaration
Swift
public class SystemTextToSpeechEngine : TextToSpeechEngine