Skip to content

feat(notifications): add Text-to-Speech (TTS) read aloud feature for incoming messages - #12

Open
ralexandrec wants to merge 1 commit into
GPTmadeit:mainfrom
ralexandrec:feature/read-aloud-tts
Open

ralexandrec wants to merge 1 commit into
GPTmadeit:mainfrom
ralexandrec:feature/read-aloud-tts

Conversation

@ralexandrec

Copy link
Copy Markdown

Summary

This PR introduces an optional Text-to-Speech (TTS) read-aloud feature for incoming mesh messages, designed to provide eyes-free / hands-free audio announcements on Wear OS smartwatches.

Key Highlights & Architecture

  1. Text-to-Speech Integration (Notifier.kt):

    • Implements TextToSpeech.OnInitListener inside Notifier to synthesize incoming chat messages ("$senderName: ${message.text}").
    • Configures AudioAttributes (USAGE_ASSISTANT, CONTENT_TYPE_SPEECH) for proper Wear OS audio routing to speakers or Bluetooth headsets.
    • Leverages native Android offline TTS voice data for off-grid operation.
  2. Power & Screen-Off Execution (Notifier.kt):

    • Acquires a brief PARTIAL_WAKE_LOCK (5s) upon message arrival to prevent CPU sleep during speech synthesis, allowing incoming messages to be announced even when the display is off.
  3. User Control & Persistence (Prefs.kt, SettingsScreen.kt):

    • Adds a read_notifications_tts preference in Prefs (backed by SharedPreferences and StateFlow).
    • Adds a Wear Compose SwitchButton under the Messaging subheader in SettingsScreen titled "Read aloud (TTS)" with clear status subtitles.
    • Defaults to enabled (true) for immediate out-of-the-box functionality.
  4. Locale Formatting Fix in Unit Tests (MeshModels.kt):

    • Passes Locale.US to String.format in formatDistance to ensure unit test consistency across non-US system locales (e.g. preventing , decimal separator issues in pt_BR).

Verification

  • ✅ All 33 unit tests pass (BUILD SUCCESSFUL).
  • ✅ Verified on target Wear OS hardware.

@ralexandrec
ralexandrec force-pushed the feature/read-aloud-tts branch from 2c67f51 to 2e9980b Compare September 1, 2026 23:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant