Voice instructions
The Mapbox Navigation SDK allows you to provide prompt and detailed voice instructions to users of your application. You can use a voice instruction to notify the user of an upcoming turn or announce that a faster route has been detected.
The Navigation SDK uses the Mapbox Java SDK's VoiceInstructions
class to hold information that should be announced out loud by the device (for example, the street that the user should stay on for a certain distance).
Use default voice instructions
There are two steps to play voice instructions in your application: generate an announcement and then play an announcement.
Create an instance of the speech API
Before you can generate an announcement, you need to instantiate the speech API in your Activity
or Fragment
:
MapboxSpeechApi speechApi = new MapboxSpeechApi(this, Locale.US.toLanguageTag());
val speechApi = MapboxSpeechApi(this, Locale.US.toLanguageTag())