MapboxVoiceController
@objc(MBMapboxVoiceController)
open class MapboxVoiceController : RouteVoiceController, AVAudioPlayerDelegate
MapboxVoiceController
extends the default RouteVoiceController
by providing a more robust speech synthesizer via the Mapbox Speech API. RouteVoiceController
will be used as a fallback during poor network conditions.
-
Number of seconds a request can wait before it is canceled and the default speech synthesizer speaks the instruction.
Declaration
Swift
@objc public var timeoutIntervalForRequest: TimeInterval
-
Number of steps ahead of the current step to cache spoken instructions.
Declaration
Swift
@objc public var stepsAheadToCache: Int
-
An
AVAudioPlayer
through which spoken instructions are played.Declaration
Swift
@objc public var audioPlayer: AVAudioPlayer?
-
Speaks an instruction.
The cache is first checked to see if we have already downloaded the speech file. If not, the instruction is fetched and played. If there is an error anywhere along the way, the instruction will be spoken with the default speech synthesizer.
Declaration
Swift
@objc open override func speak(_ instruction: SpokenInstruction)
-
Speaks an instruction with the built in speech synthesizer.
This method should be used in cases where
fetch(instruction:)
orplay(_:)
fails.Declaration
Swift
@objc open func speakWithDefaultSpeechSynthesizer(_ instruction: SpokenInstruction, error: Error?)
-
Fetches and plays an instruction.
Declaration
Swift
@objc open func fetchAndSpeak(instruction: SpokenInstruction)
-
Caches an instruction in an in-memory cache.
Declaration
Swift
@objc open func downloadAndCacheSpokenInstruction(instruction: SpokenInstruction)
-
Plays an audio file.
Declaration
Swift
@objc open func play(_ data: Data)