SystemTextToSpeechEngine
public class SystemTextToSpeechEngine : TextToSpeechEngine
Important
This is a Public Preview API. It may be changed or removed at any time.-
Creates an instance of
SystemTextToSpeechEngine. The initializer will throw an error if voices are not downloaded to the iOS device. 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
AVSpeechSynthesisVoiceread the Apple documentation: https://developer.apple.com/documentation/avfaudio/avspeechsynthesisvoiceThrows
TextToSpeechEngineError.unavailableLocaleInVoicesif there is no speech voice for the givenlanguage.Declaration
Swift
public init(language: Locale = Locale(identifier: "en_US"), gender: AVSpeechSynthesisVoiceGender? = nil) throwsParameters
languageIdentifies in which language the voice instructions will be spoken. The
Locale(identifier: "en_US")is used by default.genderThe gender for a voice. If the
genderisnilthen the gender voice will be used that exists for the givenlanguageon the device.
-
Declaration
Swift
public var supportedAlphabets: [String] -
A locale that defines the voice’s language.
Declaration
Swift
public var locale: Locale { get } -
Declaration
Swift
public weak var delegate: TextToSpeechEngineDelegate? { get set } -
Declaration
Swift
public static func isLanguageAvailable(for locale: Locale) -> Bool -
Declaration
Swift
public func play(message: TTSMessage) -
Declaration
Swift
public func stop() -
Declaration
Swift
public func setVolume(_ volume: SpeechVolume) -
Sets the language code of the messages.
Declaration
Swift
public func changeLocale(with locale: Locale) throwsParameters
localeThe locale to change to.
Throws
TextToSpeechEngineError.unavailableLocaleInVoicesif there is no speech voice for the givenlocale.
TomTom SDK for iOS (0.53.1)
SystemTextToSpeechEngine