mapbox / mapbox/mapbox-navigation-ios
Speech synthesizer locale is overwritten by route locale at every spoken instruction point
Nobody has claimed this yet.
- Dominant language
- Swift
- Stars
- 918
- Forks
- 326
- Avg merge
- 1h 16m
- Merged PRs (30d)
- 3
Description
The speech synthesizer’s locale is overwritten by the route’s locale at every spoken instruction point, preventing the application from hard-coding a particular locale for selecting the text-to-speech voice.
Background
Normally, the navigation SDK is designed to speak spoken instructions in the same locale that is indicated in the route data. After all, if the guidance instructions are phrased as appropriate for French, they should be spoken by a French voice, not an American English one. 🙉 We want to do the right thing by default, without the developer needing to remember to set both locale settings.
However, the application should have the opportunity to hard-code the voice locale, for example, Hong Kong English instructions spoken by a British English voice. This is normally quite a contrived scenario, but a practical need for this mismatch can arise due to missing language support in either the Directions API or the Voice API.
Problem
Currently, developers get the impression that they can simply set SpeechSynthesizing.locale to the desired voice locale, such as in the process of configurating NavigationOptions. Unfortunately, RouteVoiceController.didPassSpokenInstructionPoint(notification:) overwrites this locale with the requested Directions API locale immediately before prefetching or saying an instruction. The prefetching and speaking is based on the resolved locale in the route response.
This issue even affects any custom speech synthesizer that the application provides per #3747.
Proposed solution
We should move this locale-setting code so that it executes less frequently, like once at the beginning of the route, since we don’t support switching languages in the middle of a route anyways. We should only set overwrite the locale if it’s nil or equivalent to Locale.autoupdatingCurrent.
/ref #1649 #2348
/cc @mapbox/navigation-ios @Guardiola31337 @browndp08 @jinny-nam @dgearhart (FYI)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in Sources/MapboxNavigation/RouteVoiceController.swift at didPassSpokenInstructionPoint(notification:), especially the locale assignment around lines 156–157. Trace when the route begins and when instructions are prefetched or spoken, then ensure the application’s configured speech locale is not overwritten at every instruction point. Done means a hard-coded synthesizer locale remains effective while the default still follows the route locale.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- swift
- Domain
- mobile
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100