osmandapp / OsmAnd

OsmAnd
https://osmand.net
Other
4.6k stars 1.01k forks source link

Voice prompts via Bluetooth connection are very quiet #16204

Open Zirochkabila opened 1 year ago

Zirochkabila commented 1 year ago

Description

When connecting a smartphone to a car via Bluetooth, voice commands work with errors, namely:

  1. When listening to the car radio, voice commands are not heard
  2. When selecting Bluetooth as the audio source, the navigation voice is played, but if you also play music via Bluetooth, the voice volume becomes too low even with Android's "focused audio"
  3. If you put the program sound as a "separate program tone" on the phone speaker (this feature is provided by Samsung) - it works perfectly with Nokia Here Maps (it is possible to stream music to the car via Bluetooth and turn on the radio, navigation instructions are heard in the phone speaker). But, if you add OsmAnd to a separate list of tones in the application, OsmAnd still transmits the audio channel via Bluetooth. It seems that the channel is "hard coded" and not transmitted by Android.

Steps to reproduce

Connect OsmAnd to your car via Bluetooth and start navigation with voice guidance enabled

Actual result

Voice prompts via Bluetooth connection work with errors

Expected result

Voice guidance works according to the selected mode in Navigation > Settings > Sound settings > Output (Voice guidance output)

Your Environment

OsmAnd Version: OsmAnd~ 4.4.0#14082mqta, released: 2023-01-09 Android/iOS version: Android 13 Device model: Samsung S20 FE

sonora commented 1 year ago

Are these observations for connecting the phone via the Android Auto mechanism, or simply using the phone as an AUX/BT input source on a non-AA capable car radio?

EugeneZmeuk commented 1 year ago

simply using BT input source. I want to test BT too. Because I have something similar with OsmAnd voice with BT connection by my Samsung S10e. I listen to OsmAnd voice prompts during calls connection like the third person starts discussing together with us :) It's only one way to hear something from OsmAnd (not during Radio, Music and etc connections)

sonora commented 1 year ago

For the use case "simply as BT input source", to my knowledge, it's as follows:

Sunsurfer89 commented 1 year ago

For the use case "simply as BT input source", to my knowledge, it's as follows:

  • The car radio will simply play what you set it's input to: If it is set to radio, it will play the radio. Any signal coming in via BT is ignored.
  • The only exception I have been able to find and implemented in OsmAnd is via using Navigation Settings > Voice prompts > Voice guidance output > Phone call audio (for your car profile): In that case, the phone simulates an incoming telephone call to the car radio's hands free function via a special mechanism, and that is the only way I know to get a dumm car stereo to interrupt its radio play.

But the wish is actually not interrupting anything. Just separating the OsmAnd App sound to the phone speaker, regardless where the music comes actually from. Because once the phone is connected via Bluetooth to the car and BT is not the audio source in the car, your hear no voice commands at all.

sonora commented 1 year ago

I understood this as a bug report regarding standard audio stream handling. But it's a feature request to support Samsung Separate App Sound or something?

If it's a mixture of both, we should probably separate the two?

sonora commented 1 year ago

@Sunsurfer89 Have you tried setting OsmAnd to use Notification audio? On most phones I know, Android routes Media audio to BT output (if one is connected), while leaving the Notification stream locally on the device.

(OsmAnd does not hard-code anything, simply uses the standard Android audio streams as provided and routed by the OS.)

Sunsurfer89 commented 1 year ago

@sonora of course, I did. Even with disconnecting BT, closing OsmAnd... regardless of the selected option in OsmAnd, any voice command will be played via BT, once BT connected. And that is the problem: even "separate app tone" is ignored to force to play any OsmAnd sound on the phone.

sonora commented 1 year ago

Maybe you are suffering from this Samsung issue? https://forum.xda-developers.com/t/android-10-did-they-fix-no-notification-sound-through-speaker-with-bt-media-device.4024649/

See also https://eu.community.samsung.com/t5/galaxy-s22-series/sound-notifications-emit-only-through-bluetooth-not-phone/td-p/6201994 and https://support.google.com/android/thread/13530164?hl=en

sonora commented 1 year ago

I am not currently sure what could be done about this in OsmAnd.

Sunsurfer89 commented 1 year ago

Good morning, @sonora Today morning, I had the chance to test thanks to the links you sent yesterday. Actually, the board threads are very close to the problem that is happening with OsmAnd. I was surprised that this is already an issue since Android 9... 😳

However, in one of the threads, it was told that for Samsung, there is an app called "Sound Assistant". I installed it and forced OsmAnd to play sound of notifications on the phone, regardless of being connected via BT or not. So, during my ride this morning, it was working 🙂 (I also set up OsmAnd to submit the sound as notification) Even if I was connected via BT, the voice was submitted as notification. Only small risk that I see because I will turn the notification volume to max is that if a message, e-mail or whatever comes in, I will be blasted by the any "ding" sound 🤣

So far so good, we have a workaround. For long term, the support of separate app sound is much appreciated. I tried to find a dev docu but so far nothing found. Hahaha: you can ask the Here Maps guys... there it is working 😉

EugeneZmeuk commented 1 year ago

Hi @sonora and @Sunsurfer89

Yesterday I tested the sound output through Bluetooth headphones and in the car for my S10e It turned out that the headphones muffles the music and there is an instruction from Osmand.

For the Bluetooth of the car (Volvo 2013), Osmand prompts can be heard from the car's speakers in only one case - "Phone call audio", but the sound of the radio goes to zero.

I read @Sunsurfer89 's comment about "Sound Assistant" and installed it. I will test today the sound. @Sunsurfer89 you wrote that you tested Voice guidance output > "Notification audio". What is about "Media/navigation audio" setting for voice output?

Sunsurfer89 commented 1 year ago

Hello @EugeneZmeuk

Well, this afternoon, I tested with the OsmAnd setup "Media/Navigation Audio" and the tweak with Sound Assistant but without success. And I believe I know the reason:

In the Sound Assistant app, there is just one interesting option called "Warning Sound" (or similar... I'm using the app in the German language). When I turned off the option to pass warnings (such as notifications) to BT, I was able to bypass the OsmAnd voice to the phone's speaker. This is why I call it "tweak" because I'm actually misusing another intended behavior. And that's why it is just an interim work-around. And it requires that OsmAnd is submitting the voice as notification...

sonora commented 1 year ago

Yes, but it's more than a 'tweak'. It is the intented solution why in OsmAnd we offer the option to route its voice output via 'Notificantion audio' (that"s the official wording): to exactly facilitate keeping it separate from the 'regular' Media output, which by default is used (potentially in parallel) to e.g. listen to nusic, watch videos, etc.

Sunsurfer89 commented 1 year ago

Hello @sonora

For me, it's still a tweak. Why? Obviously, Samsung users need to download another app (that was unknown for me too until we started this discussion) to adapt somehow a setting that prevents notification audio from OsmAnd to be played on the phone... this requires some knowledge and is not so straightforward as for example, the "separate app tone" option (which is not working here). So, nothing out of the box like for Here Maps app. I guess you agree: good UX looks different...

So: for the moment, it is Ok for me, but for the long term, a small update of OsmAnd for the special behavior of Samsung (and maybe other brands??) is still appreciated. Just to keep the high level of an amazing UX in OsmAnd. 😉 It's not urgent, for sure, but it shouldn't be forgotten. I can not estimate the effort and user story size, but at least I'm happy if the subject can find its way to the backlog. 🙂

sonora commented 1 year ago

Ran a test today, here's the protocol: Samsung XCover 4s, stock firmware Android 11, BT connected to a car radio (not AA capable).

The Samsung XCover 4s has an Android setting called "Separate App sound" with explanation "Play media sound from one app on a different audio device". Let's test this (I understand this will have an effect on media audio only):

Conclusions:

(A) I suggest no action regarding (4), this seems intended system behavior these days. Workaround allegedly possible via 3rd party apps.

(B) Regarding (7), it seems that Samsung 'Separate app sound' somehow decides that it will not re-route OsmAnd's TTS output to the phone, just its recorded sound. Can investigate. Possible reason is that OsmAnd output is (correctly...) tagged with CONTENT_TYPE_SPEECH and USAGE_ASSISTANCE_NAVIGATION_GUIDANCE., could be this causes 'Separate app sound' to not reroute TTS.

sonora commented 1 year ago

I have tried a few more apps using TTS: For none of them I succeed with routing the TTS output to the phone via 'Separate app sound' while a BT speaker is connected. Does anybody know of apps where this works?

I am beginning to believe that 'Seperate app sound' may only act upon the Android MediaPlayer object, not the TextToSpeech object. So if you wanted to use it, you may first have to set your system's main output device to "Phone", e.g. via https://businessinsider.mx/how-to-change-the-audio-output-on-an-android-without-disconnecting-your-headphones-or-speakers-2/, then use 'Separate app sound' to route your music to BT.

Sunsurfer89 commented 1 year ago

With Here Maps/Here WeGo it works with separate app sound: https://play.google.com/store/apps/details?id=com.here.app.maps

If I navigate with it, the voice guidance is played on the phone, regardless of how my phone is connected via BT or playing music.

sonora commented 1 year ago

Yes, but are you convinced this uses live-synthesized TTS, and not just dull recordings? I am not familiar with the apps, but on all videos I just watched on YouTube I only heard sounds like "Turn left" or "In a quarter of a mile, at the roundabout, take the first exit.", all of which sound like combined pre-recorded snippets. Do you ever hear it pronounce e.g. a street name, which is clearly not pre-recorded?

In OsmAnd, when you select a pre-recorded voice, 'Separate app sound' (by my tests) also works as expected. And that is although it is tagged with the same AudioAttributes as our TTS output, so it seems the tagging may not be the culprit.

Sunsurfer89 commented 1 year ago

Very true, I have no evidence that this is full TTS or just simple recordings...

But, what you mention here gives me an idea: When we know that TTS is affected, maybe we have to add the TTS engine to the list of separate app sounds. I will test this later today. 😉

Edit: Sh*t... the Samsung TTS engine app, is a kind of background app/service that cannot be selected in the list of apps for separate app sounds... 🙁 Was an idea...

sonora commented 1 year ago

I have just installed HERE We Go 4.7..000 and have the same Issue: It claims in its 'Voice options' that it uses TTS - ok.

Sunsurfer89 commented 1 year ago

I feel more and more that the bug is more on Android/Samsung side...

I was asking myself if it makes a difference to select the Google TTS service instead of the Samsung's one... 🤔

I will test this, but I strongly believe it doesn't matter...

sonora commented 1 year ago

Yes... and the only non-deprecated way I find so far to programmatically override the more recent Android systems' behaviors of routing their audio output is using AudioManager's setSpeakerphoneOn(true) method, with all sorts of side effects (because this is actually intended for phone calls), and with varying degrees of success on devices of different manufacturers.

I think for now I see nothing of general benefit I would be willing to try / risk changing in OsmAnd. Would instead advise to experiment overriding audio routing with the various 3rd party apps out there, which all seem manufacturer-specific, likely for a reason, to see if there is a solution for one's particular setup.

Zirochkabila commented 1 year ago

Voice prompts work quietly over Bluetooth headphones as well.

vshcherb commented 1 year ago

ChatGPT Yes, you can configure the volume for Text-to-Speech (TTS) Engine in Android API using the AudioManager class. Here's an example of how to set the volume:

// Create an instance of AudioManager
AudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);

// Set the volume of TTS to the maximum
int maxVolume = audioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC);
audioManager.setStreamVolume(AudioManager.STREAM_MUSIC, maxVolume, 0);

In the code above, we first create an instance of the AudioManager class using the getSystemService method. Then, we get the maximum volume for the music stream using the getStreamMaxVolume method, and set the volume to the maximum using the setStreamVolume method.

You can adjust the volume by changing the second argument of the setStreamVolume method to a value between 0 and the maximum volume.

Yogurt4 commented 1 year ago

I have a similar issue. Even though the phone volume is set to maximum, it's very hard to hear the voice prompts. Now I get a heart attack should anything else make a sound on my phone during navigation.

sonora commented 1 year ago

I had totally overlooked @vshcherb 's Chat GPT answer above. Has anybody who can reproduce the issue tried it perhaps someone in the OsmAnd dev team?

vshcherb commented 1 year ago

I think this is the same as turning volume up yourself, which has same flaws as before that music will be too loud at the same time.

sonora commented 1 year ago

Yes I thought so. I had researched setStreamVolume at the time of implementation and somehow decided we do not need it.

Important seems wd follow this practice https://developer.android.com/guide/topics/media-apps/volume-and-earphones, i.e. call setVolumeControlStream in the roght places to ensure the active volume slider is the correct one. But I have no indication so far ir is not.

Cannot reliably reproduce the issue described here anyway, cannot rule out it is device or firmware bugs. Really hard to do much useful about it under the circumstances.

Chances are on some older car BT stereos this might help: https://www.businessinsider.com/guides/tech/android-disable-absolute-bluetooth-volume

Sunsurfer89 commented 1 year ago

I have another app that shows a very good implementation of the audio settings and features: Blitzer.de PLUS

There, the app allows to set-up where the notifications shall be played on and also what the volume shall be. And what happens with music/podcast in parallel. See screenshots. If OsmAnd could have the same rich features, job done. 😎 Problem: I don't think that the source code of Blitzer.de is public...

DmitryAlexei commented 1 year ago

Have you tried this option? https://osmand.net/docs/user/navigation/guidance/voice-navigation#voice-guidance-output

sonora commented 1 year ago

@Sunsurfer89 Hard to say what's different at all from the settings we have. In OsmAnd you can also select the output channel, including the possibility to simulate a call.

Regarding to set an own app volume independent of the system volume settings, and to unconditionally force the speaker even if the system has re-routed a certain stream to BT, that may not actually work on all devices and versions of Android.

Sunsurfer89 commented 1 year ago

@DmitryAlexei yes, and even advanced as described in a post before: https://github.com/osmandapp/OsmAnd/issues/16204#issuecomment-1378415376

However, it is still not the best solution. Other apps (like HERE or Blitzer.de) do a better job... unfortunately...

surajak commented 1 year ago

I tried with my bt earphone and car bt. Navigation voice is low as compare to music from same phone over bt. Both modes notification and media tried. Phone call simulation gives better audio. But it shows an incoming call on car display. Every time a notification cames up from osmand(4.5.3). Other navigation apps works fine like gmaps, Waze, mapple. Without bt connected, voice is good with notification or media mode from phones speaker.

sonora commented 1 year ago

@surajak

  1. Can you please conform this is TTS only?
  2. While connected to BT, have you tuurned up the volume all the way on the smartphone and during an OsmAnd announcement? What output channel does the volume indicator show as used, and is it set to 100%? (You can force an announcement by tapping on the turn-by-turn arrow top left oft the map screen during navigation, then turn up the volume all the way during the announcement.).
sonora commented 1 year ago

Here's another idea of what could be tried if the volume conttol behaves strange on older car BT systems: https://www.businessinsider.com/guides/tech/android-disable-absolute-bluetooth-volume

whitedavidp commented 1 year ago

Here's another idea of what could be tried if the volume conttol behaves strange on older car BT systems: https://www.businessinsider.com/guides/tech/android-disable-absolute-bluetooth-volume

Thanks for this. I stumbled into this while searching for a resolution to issues with some BT headsets I own. I was vaguely aware that there were BT settings in my phone's developer settings. But did not know of this specific one. Cheers

Sunsurfer89 commented 1 year ago

Here's another idea of what could be tried if the volume conttol behaves strange on older car BT systems: https://www.businessinsider.com/guides/tech/android-disable-absolute-bluetooth-volume

Many thanks for this suggestion. However, the absolute volume in my Volkswagen is well supported and I don't want to miss the feature while being connected to other devices (BT speakers, etc.) So, turning off the absolute volume will have a master effect to all BT devices and not only the car. So, it COULD maybe fix something here (for OSMand), but leads definitively to a bad user experience in other aspects... I guess, you see my concerns. 😉