mapbox / mapbox-navigation-ios

Turn-by-turn navigation logic and UI in Swift on iOS
https://docs.mapbox.com/ios/navigation/
Other
858 stars 308 forks source link

Enable developers to set/adjust the volume of spoken instructions #1977

Open akitchen opened 5 years ago

akitchen commented 5 years ago

It should be possible for developers to easily set the volume of spoken instructions during turn-by-turn navigation. Unfortunately this may be more complicated than it seems as the SDK adaptively switches between a media player and the built-in TTS system depending on network and other conditions.

Ideally we could address #1826 , but at least we should make it possible to set the volume programmatically so that developers can control this and/or expose it to their users for finer-grained control.

We have some code in place which appears to be trying to do this, but I don't think it is working as expected. Therefore I've also marked this as a bug.

1ec5 commented 5 years ago

AVAudioPlayer.volume and AVSpeechUtterance.volume are both relative to the system audio volume on a scale of 0–1, with 1 being the default. Per #1826, an MPVolumeView is the preferred way to set the system audio volume on an absolute basis. For a non-UI setting, AVMutableAudioMixInputParameters.setVolume(_:at:) might do the trick, as described in QA1716. Another option is to modify the <prosody volume="…"> attribute in the SSML instructions. However, the SSML is generated by the Directions API; since we don’t have ready access to an XML parser, we should avoid munging XML strings as much as possible.

billyking991 commented 5 years ago

I think I may know what is going on. I've been testing with 4 of the different English Polly voices and comparing what I'm hearing between Mapbox and other GPS providers. I think it may not be that the voice isn't loud enough...it may be that the voice is equalized so that it's too mellow. Is there a way to adjust the the way the voice is equalized so that it's much more treble and stands out against all of the other noises in a car?

The reason I've come to this conclusion is because when there is a terrible connection, the Polly voice its replaced with the Text-To-Speech voice I've set on the device. That voice has much more treble in it and is much easier to hear in the car. I feel that the Polly voices are two mellow and focused toward the midrange of the sound spectrum. Does this make sense?

Regardless, I keep getting asked by users to make the voice louder, if possible. Any changes that could be made would be really nice.

1ec5 commented 3 years ago

Is there a way to adjust the the way the voice is equalized so that it's much more treble and stands out against all of the other noises in a car?

MapboxSpeechSynthesizer currently uses an AVAudioPlayer to play back the MP3 files returned by the Mapbox Voice API. It is possible to apply equalizer effects using AVAudioEngine, but I don’t know if that would play well with the AVAudioSession ducking settings.

On the backend, we might be able to have the Directions API set a higher volume and pitch in SSML, but I don’t know if this option will yield the desired improvement and whether there would be any downsides for other languages.

zacharyblank commented 3 years ago

@jyrigo @AhmerKhan1 we are getting reports from iOS drivers that the spoken instructions are too low and they can't hear them regardless of the volume of their device. This is for both iOS and Android. Does this ticket track an update that will allow us to remedy this?

cc @mapbox/straightaway-android-team @mapbox/straightaway-ios-team