MapboxSpeechApi

class MapboxSpeechApi @JvmOverloads constructor(    context: Context,     accessToken: String,     language: String,     options: MapboxSpeechApiOptions = MapboxSpeechApiOptions.Builder().build())

Mapbox Speech Api that allows you to generate an announcement based on VoiceInstructions

Parameters

context

Context

accessToken

String

language

Locale language (IETF BCP 47)

options

Constructors

Link copied to clipboard
fun MapboxSpeechApi(    context: Context,     accessToken: String,     language: String,     options: MapboxSpeechApiOptions = MapboxSpeechApiOptions.Builder().build())

Functions

Link copied to clipboard
fun cancel()

The method stops the process of retrieving the file voice instruction SpeechAnnouncement and destroys any related callbacks.

Link copied to clipboard
fun clean(announcement: SpeechAnnouncement)

Given the SpeechAnnouncement the method may cleanup any associated files previously generated.

Link copied to clipboard
fun generate(voiceInstruction: VoiceInstructions, consumer: MapboxNavigationConsumer<Expected<SpeechError, SpeechValue>>)

Given VoiceInstructions the method will try to generate the voice instruction SpeechAnnouncement including the synthesized speech mp3 file from Mapbox's API Voice. NOTE: this method will try downloading an mp3 file from server. If you use voice instructions predownloading (see VoiceInstructionsPrefetcher), invoke generatePredownloaded instead of this method in your VoiceInstructionsObserver.

Link copied to clipboard
fun generatePredownloaded(voiceInstruction: VoiceInstructions, consumer: MapboxNavigationConsumer<Expected<SpeechError, SpeechValue>>)

Given VoiceInstructions the method will try to generate the voice instruction SpeechAnnouncement including the synthesized speech mp3 file from Mapbox's API Voice. NOTE: this method will NOT try downloading an mp3 file from server. It will either use an already predownloaded file or an onboard speech synthesizer. Only invoke this method if you use voice instructions predownloading (see VoiceInstructionsPrefetcher), otherwise invoke generatePredownloaded in your VoiceInstructionsObserver.