8000 [android] TTS fixes by AndrewShkrob · Pull Request #11757 · organicmaps/organicmaps · GitHub
[go: up one dir, main page]

Skip to content

Conversation

@AndrewShkrob
Copy link
Member
@AndrewShkrob AndrewShkrob commented Nov 17, 2025

Add check for bluetooth sco device.
If BleSCO is used we wait 1500 ms before playing sound Updated utterance listener

  • do not re-request audio focus for each string - we already requested it at start
  • abandon audio focus only after all strings are played

Added logs

Updated play logic to reset old request:

  • Each time we ask TTS to play strings (on speak() or on playTurnNotifications()) we flush the buffer
  • The first string in the queue flushes the buffer
  • Other strings are added to the buffer

Should be beta tested especially with bluetooth devices

Related issues:
#11429
#11339
#5176
#5661
#11369
#5109

Some of them may already be resolved by my other TTS fixes

@AndrewShkrob AndrewShkrob requested a review from a team as a code owner November 17, 2025 20:34
@AndrewShkrob AndrewShkrob added Android Android development TTS Text-to-Speech Beta PRs ready to be tested before merging them to master, or issues found in beta versions. labels Nov 17, 2025
@AndrewShkrob
Copy link
Member Author

It is said everywhere (docs and stackoverflow) that we have to call setBluetoothScoOn if we want to communicate over ble sco. But we don't want to. We only want the system to p 8000 lay our sound via whatever device is currently being active.
I have added a check "If current device is BleSCO -> change AudioManager mode to IN_COMMUNICATION". This mode is recommended to be used with SCO

Copy link
Member
@biodranik biodranik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Delaying TTS announcements may lead to road accidents.

@AndrewShkrob
Copy link
Member Author

Delaying TTS announcements may lead to road accidents.

Right now they’re either not played at all, or the first announcement gets cut off. Please propose a better solution.

@biodranik
Copy link
Member
  1. Will announcing something (silence? short pleasant sound? "Let's go" phrase?) at the start of the navigation fix the issue?
  2. How are delays related to the "not working at all" case? Is it a separate fix?

@AndrewShkrob
Copy link
Member Author
  1. Yes, this is the time needed to establish connection between device and bluetooth speaker. 1500ms should be ok, to fix the issue when first phrase is cut off
  2. Delays (the first phrase is cut off) is one issue, non-working notifications is another issue.

Add check for bluetooth sco device.
If BleSCO is used we wait 1500 ms before playing sound
Updated utterance listener
 * do not re-request audio focus for each string - we already requested it at start
 * abandon audio focus only after all strings are played
Added logs
Updated play logic to reset old request:
 * Each time we ask TTS to play strings (on speak() or on playTurnNotifications()) we flush the buffer
 * The first string in the queue flushes the buffer
 * Other strings are added to the buffer

Signed-off-by: Andrei Shkrob <github@shkrob.dev>
@AndrewShkrob
Copy link
Member Author

Updated PR - removed 1500ms delay for bluetooth connection

Copy link
Member
@biodranik biodranik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! LGTM if it works )


protected void onAudioFocusChange(int focusChange)
{
Logger.w(TAG, "Unexpected audio focus change: " + focusChange);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is it unexpected?

if (isBluetoothScoDeviceUsed())
{
Logger.d(TAG, "Bluetooth SCO device is used for audio output");
mAudioManager.setMode(AudioManager.MODE_IN_COMMUNICATION);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if active device changes after requestAudioFocus() was called? Does it make sense to monitor changes and use the related setMode if a new device is SCO/not SCO? https://developer.android.com/develop/connectivity/bluetooth/ble-audio/audio-manager#java

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Android Android development Beta PRs ready to be tested before merging them to master, or issues found in beta versions. TTS Text-to-Speech

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

< 156D /ghcc-consent>
0