Closed billyking991 closed 5 years ago
mapbox-speech-swift does expose a way to modify the gender but it is not exposed via the MapboxVoiceController
in the Navigation SDK.
You could subclass MapboxVoiceController
and override fetchAndSpeak(instruction:)
.
class MyVoiceController: MapboxVoiceController {
override func fetchAndSpeak(instruction: SpokenInstruction) {
let ssmlText = instruction.ssmlText
let options = SpeechOptions(ssml: ssmlText)
options.speechGender = .male // Set SpeechGender on SpeechOptions
if let locale = locale {
options.locale = locale
}
if let locale = routeProgress?.route.speechLocale {
options.locale = locale
}
speech.audioData(with: options) { [weak self] (data, error) in
guard let data = data else { return }
self?.cache(data, forKey: ssmlText)
}
}
}
However, the MapboxVoiceController.cache(_:forKey:)
would have to become public.
Hi Fredrik,
Thank you for this explanation. I really appreciate it and will be working on it this week to see if I can make it work in my code.
Would it make sense to expose the gender for all developers? I have had several people (male and female) who have asked for a male voice. I'm sure there are other users out there who would like to be able to change the gender as well. If it's not too difficult, I would love the option to be available in the SDK.
Thank you, Billy
Is it possible to switch the Polly voice to a male voice? The AWS docs show that there are male voices for many of the different voices, but so far, I'm only able to select female Polly voices in the NavigationRouteOptions (ie options.locale = [NSLocale localeWithLocaleIdentifier:@"en-GB"];)
My app only works in English and I like to give my users as many options in the app as possible. This is definitely not a need and more of a want, but I'd love to have the extra choices.
Here are the AWS docs pertaining to this: https://docs.aws.amazon.com/polly/latest/dg/voicelist.html
Mapbox Navigation SDK version: 0.32.0