EarLLM One — Build & Maintain
Overview
Build, maintain, and extend the EarLLM One Android project — a Kotlin/Compose app that connects Bluetooth earbuds to an LLM via voice pipeline.
When to Use This Skill
- When the user mentions "earllm" or related topics
- When the user mentions "earbudllm" or related topics
- When the user mentions "earbud app" or related topics
- When the user mentions "voice pipeline kotlin" or related topics
- When the user mentions "bluetooth audio android" or related topics
- When the user mentions "sco microphone" or related topics
Do Not Use This Skill When
- The task is unrelated to earllm build
- A simpler, more specific tool can handle the request
- The user needs general-purpose assistance without domain expertise
How It Works
EarLLM One is a multi-module Android app (Kotlin + Jetpack Compose) that captures voice from Bluetooth earbuds, transcribes it, sends it to an LLM, and speaks the response back.
Project Location
C:\Users\renat\earbudllm
Module Dependency Graph
app ──→ voice ──→ audio ──→ core-logging
│ │
├──→ bluetooth ──→ core-logging
└──→ llm ──→ core-logging
Modules And Key Files
| Module |
Purpose |
Key Files |
| core-logging |
Structured logging, performance tracking |
EarLogger.kt, PerformanceTracker.kt |
| bluetooth |
BT discovery, pairing, A2DP/HFP profiles |
BluetoothController.kt, BluetoothState.kt, BluetoothPermissions.kt |
| audio |
Audio routing (SCO/BLE), capture, headset buttons |
AudioRouteController.kt, VoiceCaptureController.kt, HeadsetButtonController.kt |
| voice |
STT (SpeechRecognizer + Vosk stub), TTS, pipeline |
SpeechToTextController.kt, TextToSpeechController.kt, VoicePipeline.kt |
| llm |
LLM interface, stub, OpenAI-compatible client |
LlmClient.kt, StubLlmClient.kt, RealLlmClient.kt, SecureTokenStore.kt |
| app |
UI, ViewModel, Service, Settings, all screens |
MainViewModel.kt, EarLlmForegroundService.kt, 6 Compose screens |
Build Configuration
- SDK: minSdk 26, targetSdk 34, compileSdk 34
- Build tools: AGP 8.2.2, Kotlin 1.9.22, Gradle 8.5
- Compose BOM: 2024.02.00
- Key deps: OkHttp, AndroidX Security (EncryptedSharedPreferences), DataStore, Media
Target Hardware
| Device |
Model |
Key Details |
| Phone |
Samsung Galaxy S24 Ultra |
Android 14, One UI 6.1, Snapdragon 8 Gen 3 |
| Earbuds |
Xiaomi Redmi Buds 6 Pro |
BT 5.3, A2DP/HFP/AVRCP, ANC, LDAC |
Critical Technical Facts
These are verified facts from official documentation and device testing. Treat them as ground truth when making decisions:
Bluetooth SCO is limited to 8kHz mono input on most devices. Some support 16kHz mSBC. BLE Audio (Android 12+, TYPE_BLE_HEADSET = 26) supports up to 32kHz stereo. Always prefer BLE Audio when available.
startBluetoothSco() is deprecated since Android 12 (API 31). Use AudioManager.setCommunicationDevice(AudioDeviceInfo) and clearCommunicationDevice() instead. The project already implements both paths in AudioRouteController.kt.
Samsung One UI 7/8 has a known HFP corruption bug where A2DP playback corrupts the SCO link. The app handles this with silence detection and automatic fallback to the phone's built-in mic.
Redmi Buds 6 Pro tap controls must be set to "Default" (Play/Pause) in the Xiaomi Earbuds companion app. If set to ANC or custom functions, events are handled internally by the earbuds and never reach Android.
Android 14+ requires FOREGROUND_SERVICE_MICROPHONE permission and foregroundServiceType="microphone" in the service declaration. RECORD_AUDIO must be granted before startForeground().
VOICE_COMMUNICATION audio source enables AEC (Acoustic Echo Cancellation), which is critical to prevent TTS audio output from feeding back into the STT microphone input. Never change this source without understanding the echo implications.
Never play TTS (A2DP) while simultaneously recording via SCO. The correct sequence is: stop playback → switch to HFP → record → switch to A2DP → play response.
Data Flow
Headset button tap
→ MediaSession (HeadsetButtonController)
→ TapAction.RECORD_TOGGLE
→ VoicePipeline.toggleRecording()
→ VoiceCaptureController captures PCM (16kHz mono)
→ stopRecording() returns ByteArray
→ SpeechToTextController.transcribe(pcmData)
→ LlmClient.chat(messages)
→ TextToSpeechController.speak(response)
→ Audio output via A2DP to earbuds
Adding A New Feature
- Identify which module(s) are affected
- Read existing code in those modules first
- Follow the StateFlow pattern — expose state via
MutableStateFlow / StateFlow
- Update
MainViewModel.kt if the feature needs UI integration
- Add unit tests in the module's
src/test/ directory
- Update docs if the feature changes behavior
Modifying Audio Capture
VoiceCaptureController.kt handles PCM recording at 16kHz mono
- WAV headers use hex byte values (not char literals) to avoid shell quoting issues
- VU meter: RMS calculation → dB conversion → normalized 0-1 range
- Buffer size:
getMinBufferSize().coerceAtLeast(4096)
Changing Bluetooth Behavior
BluetoothController.kt manages discovery, pairing, profile proxies
- Earbuds detection uses name heuristics: "buds", "earbuds", "tws", "pods", "ear"
- Always handle both Bluetooth Classic and BLE Audio paths
Modifying The Llm Integration
LlmClient.kt defines the interface — keep it generic
StubLlmClient.kt for offline testing (500ms simulated delay)
RealLlmClient.kt uses OkHttp to call OpenAI-compatible APIs
- API keys stored in
SecureTokenStore.kt (EncryptedSharedPreferences)
Generating A Build Artifact
After code changes, regenerate the ZIP:
## From Project Root
powershell -Command "Remove-Item 'EarLLM_One_v1.0.zip' -Force -ErrorAction SilentlyContinue; Compress-Archive -Path (Get-ChildItem -Exclude '*.zip','_zip_verify','.git') -DestinationPath 'EarLLM_One_v1.0.zip' -Force"
Running Tests
./gradlew test --stacktrace # Unit tests
./gradlew connectedAndroidTest # Instrumented tests (device required)
Phase 2 Roadmap
- Real-time streaming voice conversation with LLM through earbuds
- Smart assistant: categorize speech into meetings, shopping lists, memos, emails
- Vosk offline STT integration (currently stubbed)
- Wake-word detection to avoid keeping SCO open continuously
- Streaming TTS (Android built-in TTS does NOT support streaming)
Stt Engine Reference
| Engine |
Size |
WER |
Streaming |
Best For |
| Vosk small-en |
40 MB |
~10% |
Yes |
Real-time mobile |
| Vosk lgraph |
128 MB |
~8% |
Yes |
Better accuracy |
| Whisper tiny |
40 MB |
~10-12% |
No (batch) |
Post-utterance polish |
| Android SpeechRecognizer |
0 MB |
varies |
Yes |
Online, no extra deps |
Best Practices
- Provide clear, specific context about your project and requirements
- Review all suggestions before applying them to production code
- Combine with other complementary skills for comprehensive analysis
Common Pitfalls
- Using this skill for tasks outside its domain expertise
- Applying recommendations without understanding your specific context
- Not providing enough project context for accurate analysis
1---
2name: earllm-build
3description: Build, maintain, and extend the EarLLM One Android project — a Kotlin/Compose app that connects Bluetooth earbuds to an LLM via voice pipeline. Use this skill whenever working on the earbudllm...
4risk: safe
5source: community
6date_added: '2026-03-06'
7author: renat
8tags:
9- android
10- kotlin
11- bluetooth
12- llm
13- voice
14tools:
15- claude-code
16- antigravity
17- cursor
18- gemini-cli
19- codex-cli
20metadata:
21 source: https://skillmd.com/skills/kursku/earllm-build
22---
23
24# EarLLM One — Build & Maintain
25
26## Overview
27
28Build, maintain, and extend the EarLLM One Android project — a Kotlin/Compose app that connects Bluetooth earbuds to an LLM via voice pipeline.
29
30## When to Use This Skill
31
32- When the user mentions "earllm" or related topics
33- When the user mentions "earbudllm" or related topics
34- When the user mentions "earbud app" or related topics
35- When the user mentions "voice pipeline kotlin" or related topics
36- When the user mentions "bluetooth audio android" or related topics
37- When the user mentions "sco microphone" or related topics
38
39## Do Not Use This Skill When
40
41- The task is unrelated to earllm build
42- A simpler, more specific tool can handle the request
43- The user needs general-purpose assistance without domain expertise
44
45## How It Works
46
47EarLLM One is a multi-module Android app (Kotlin + Jetpack Compose) that captures voice from Bluetooth earbuds, transcribes it, sends it to an LLM, and speaks the response back.
48
49## Project Location
50
51`C:\Users\renat\earbudllm`
52
53## Module Dependency Graph
54
55```
56app ──→ voice ──→ audio ──→ core-logging
57 │ │
58 ├──→ bluetooth ──→ core-logging
59 └──→ llm ──→ core-logging
60```
61
62## Modules And Key Files
63
64| Module | Purpose | Key Files |
65|--------|---------|-----------|
66| **core-logging** | Structured logging, performance tracking | `EarLogger.kt`, `PerformanceTracker.kt` |
67| **bluetooth** | BT discovery, pairing, A2DP/HFP profiles | `BluetoothController.kt`, `BluetoothState.kt`, `BluetoothPermissions.kt` |
68| **audio** | Audio routing (SCO/BLE), capture, headset buttons | `AudioRouteController.kt`, `VoiceCaptureController.kt`, `HeadsetButtonController.kt` |
69| **voice** | STT (SpeechRecognizer + Vosk stub), TTS, pipeline | `SpeechToTextController.kt`, `TextToSpeechController.kt`, `VoicePipeline.kt` |
70| **llm** | LLM interface, stub, OpenAI-compatible client | `LlmClient.kt`, `StubLlmClient.kt`, `RealLlmClient.kt`, `SecureTokenStore.kt` |
71| **app** | UI, ViewModel, Service, Settings, all screens | `MainViewModel.kt`, `EarLlmForegroundService.kt`, 6 Compose screens |
72
73## Build Configuration
74
75- **SDK**: minSdk 26, targetSdk 34, compileSdk 34
76- **Build tools**: AGP 8.2.2, Kotlin 1.9.22, Gradle 8.5
77- **Compose BOM**: 2024.02.00
78- **Key deps**: OkHttp, AndroidX Security (EncryptedSharedPreferences), DataStore, Media
79
80## Target Hardware
81
82| Device | Model | Key Details |
83|--------|-------|-------------|
84| Phone | Samsung Galaxy S24 Ultra | Android 14, One UI 6.1, Snapdragon 8 Gen 3 |
85| Earbuds | Xiaomi Redmi Buds 6 Pro | BT 5.3, A2DP/HFP/AVRCP, ANC, LDAC |
86
87## Critical Technical Facts
88
89These are verified facts from official documentation and device testing. Treat them as ground truth when making decisions:
90
911. **Bluetooth SCO is limited to 8kHz mono input** on most devices. Some support 16kHz mSBC. BLE Audio (Android 12+, `TYPE_BLE_HEADSET = 26`) supports up to 32kHz stereo. Always prefer BLE Audio when available.
92
932. **`startBluetoothSco()` is deprecated since Android 12 (API 31).** Use `AudioManager.setCommunicationDevice(AudioDeviceInfo)` and `clearCommunicationDevice()` instead. The project already implements both paths in `AudioRouteController.kt`.
94
953. **Samsung One UI 7/8 has a known HFP corruption bug** where A2DP playback corrupts the SCO link. The app handles this with silence detection and automatic fallback to the phone's built-in mic.
96
974. **Redmi Buds 6 Pro tap controls must be set to "Default" (Play/Pause)** in the Xiaomi Earbuds companion app. If set to ANC or custom functions, events are handled internally by the earbuds and never reach Android.
98
995. **Android 14+ requires `FOREGROUND_SERVICE_MICROPHONE` permission** and `foregroundServiceType="microphone"` in the service declaration. `RECORD_AUDIO` must be granted before `startForeground()`.
100
1016. **`VOICE_COMMUNICATION` audio source enables AEC** (Acoustic Echo Cancellation), which is critical to prevent TTS audio output from feeding back into the STT microphone input. Never change this source without understanding the echo implications.
102
1037. **Never play TTS (A2DP) while simultaneously recording via SCO.** The correct sequence is: stop playback → switch to HFP → record → switch to A2DP → play response.
104
105## Data Flow
106
107```
108Headset button tap
109 → MediaSession (HeadsetButtonController)
110 → TapAction.RECORD_TOGGLE
111 → VoicePipeline.toggleRecording()
112 → VoiceCaptureController captures PCM (16kHz mono)
113 → stopRecording() returns ByteArray
114 → SpeechToTextController.transcribe(pcmData)
115 → LlmClient.chat(messages)
116 → TextToSpeechController.speak(response)
117 → Audio output via A2DP to earbuds
118```
119
120## Adding A New Feature
121
1221. Identify which module(s) are affected
1232. Read existing code in those modules first
1243. Follow the StateFlow pattern — expose state via `MutableStateFlow` / `StateFlow`
1254. Update `MainViewModel.kt` if the feature needs UI integration
1265. Add unit tests in the module's `src/test/` directory
1276. Update docs if the feature changes behavior
128
129## Modifying Audio Capture
130
131- `VoiceCaptureController.kt` handles PCM recording at 16kHz mono
132- WAV headers use hex byte values (not char literals) to avoid shell quoting issues
133- VU meter: RMS calculation → dB conversion → normalized 0-1 range
134- Buffer size: `getMinBufferSize().coerceAtLeast(4096)`
135
136## Changing Bluetooth Behavior
137
138- `BluetoothController.kt` manages discovery, pairing, profile proxies
139- Earbuds detection uses name heuristics: "buds", "earbuds", "tws", "pods", "ear"
140- Always handle both Bluetooth Classic and BLE Audio paths
141
142## Modifying The Llm Integration
143
144- `LlmClient.kt` defines the interface — keep it generic
145- `StubLlmClient.kt` for offline testing (500ms simulated delay)
146- `RealLlmClient.kt` uses OkHttp to call OpenAI-compatible APIs
147- API keys stored in `SecureTokenStore.kt` (EncryptedSharedPreferences)
148
149## Generating A Build Artifact
150
151After code changes, regenerate the ZIP:
152```powershell
153
154## From Project Root
155
156powershell -Command "Remove-Item 'EarLLM_One_v1.0.zip' -Force -ErrorAction SilentlyContinue; Compress-Archive -Path (Get-ChildItem -Exclude '*.zip','_zip_verify','.git') -DestinationPath 'EarLLM_One_v1.0.zip' -Force"
157```
158
159## Running Tests
160
161```bash
162./gradlew test --stacktrace # Unit tests
163./gradlew connectedAndroidTest # Instrumented tests (device required)
164```
165
166## Phase 2 Roadmap
167
168- Real-time streaming voice conversation with LLM through earbuds
169- Smart assistant: categorize speech into meetings, shopping lists, memos, emails
170- Vosk offline STT integration (currently stubbed)
171- Wake-word detection to avoid keeping SCO open continuously
172- Streaming TTS (Android built-in TTS does NOT support streaming)
173
174## Stt Engine Reference
175
176| Engine | Size | WER | Streaming | Best For |
177|--------|------|-----|-----------|----------|
178| Vosk small-en | 40 MB | ~10% | Yes | Real-time mobile |
179| Vosk lgraph | 128 MB | ~8% | Yes | Better accuracy |
180| Whisper tiny | 40 MB | ~10-12% | No (batch) | Post-utterance polish |
181| Android SpeechRecognizer | 0 MB | varies | Yes | Online, no extra deps |
182
183## Best Practices
184
185- Provide clear, specific context about your project and requirements
186- Review all suggestions before applying them to production code
187- Combine with other complementary skills for comprehensive analysis
188
189## Common Pitfalls
190
191- Using this skill for tasks outside its domain expertise
192- Applying recommendations without understanding your specific context
193- Not providing enough project context for accurate analysis