RouteVoiceController
open class RouteVoiceController : NSObject, AVSpeechSynthesizerDelegate
A route voice controller plays spoken instructions as audio using the Speech Synthesis framework, also known as VoiceOver.
You initialize a voice controller using a NavigationService
instance. The voice controller observes when the navigation service hints that the user has passed a spoken instruction point and responds by reading aloud the contents of a SpokenInstruction
object using an AVSpeechSynthesizer
object.
The Speech Synthesis framework does not require a network connection, but the speech quality may be limited in some languages including English. By default, a NavigationViewController
plays spoken instruction susing a subclass, MapboxVoiceController
, that is powered by the MapboxSpeech framework instead of the Speech Synthesis framework.
If you need to supply a third-party speech synthesizer, define a subclass of RouteVoiceController
that overrides the speak(_:)
method. If the third-party speech synthesizer requires a network connection, you can instead subclass MapboxVoiceController
to take advantage of its prefetching functionality.
-
If true, a noise indicating the user is going to be rerouted will play prior to rerouting.
Declaration
Swift
public var playRerouteSound: Bool
-
Sound to play prior to reroute. Inherits volume level from
volume
.Declaration
Swift
public var rerouteSoundPlayer: AVAudioPlayer
-
Delegate used for getting metadata information about a particular spoken instruction.
Declaration
Swift
public weak var voiceControllerDelegate: VoiceControllerDelegate?
-
Default initializer for
RouteVoiceController
.Declaration
Swift
public init(navigationService: NavigationService)
-
Reads aloud the given instruction.
Declaration
Swift
open func speak(_ instruction: SpokenInstruction)
Parameters
instruction
The instruction to read aloud.