Skip to content

Commit 4acf666

Browse files
Merge pull request #85 from AnkushMalaker/mic-button
Mic button
2 parents 8cfb8fc + 4032654 commit 4acf666

11 files changed

Lines changed: 4390 additions & 1628 deletions

File tree

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,14 @@
1212
2. Configure your API keys and service settings manually
1313
3. Start with `docker compose up --build -d`
1414

15+
**Mobile App + Phone Audio (Latest Feature):**
16+
1. **Setup Backend**: Follow Advanced Backend setup above
17+
2. **Install Mobile App**: Go to `app/` directory and run `npm install && npm start`
18+
3. **Configure Mobile App**: Point to your backend IP in app settings
19+
4. **Enable Phone Audio**: Tap "Stream Phone Audio" in app for direct microphone streaming
20+
5. **Grant Permissions**: Allow microphone access when prompted
21+
6. **Start Streaming**: Speak into phone for real-time processing with live audio visualization
22+
1523
**Documentation:** See `CLAUDE.md` and `Docs/init-system.md` for detailed setup guide
1624

1725
## Overview

app/README.md

Lines changed: 76 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@ React Native mobile application for connecting OMI devices and streaming audio t
55
## Features
66

77
- **OMI Device Integration**: Connect via Bluetooth and stream audio
8+
- **Phone Audio Streaming**: Use phone's microphone directly (NEW)
89
- **Cross-Platform**: iOS and Android support using React Native
910
- **Real-time Audio Streaming**: OPUS audio transmission to backend services
1011
- **WebSocket Communication**: Efficient real-time data transfer
1112
- **Backend Selection**: Configure connection to any compatible backend
13+
- **Live Audio Visualization**: Real-time audio level meters
1214

1315
## Quick Start
1416

@@ -115,7 +117,7 @@ The app connects to any backend that accepts OPUS audio streams:
115117
- Good for testing and development
116118
- WebSocket endpoint: `/ws`
117119

118-
2. **Advanced Backend** (`backends/advanced-backend/`)
120+
2. **Advanced Backend** (`backends/advanced/`)
119121
- Full transcription and memory features
120122
- Real-time processing with speaker recognition
121123
- WebSocket endpoint: `/ws_pcm`
@@ -149,6 +151,60 @@ Backend URL: wss://[ngrok-subdomain].ngrok.io/ws_pcm
149151
- Public: `wss://[your-domain]/ws_pcm`
150152
5. **Save configuration**
151153

154+
## Phone Audio Streaming (NEW)
155+
156+
### Overview
157+
Stream audio directly from your phone's microphone to Friend-Lite backend, bypassing Bluetooth devices. This feature provides a direct audio input method for users who want to use their phone as the audio source.
158+
159+
### Features
160+
- **Direct Microphone Access**: Use phone's built-in microphone
161+
- **Real-time Audio Streaming**: Live audio processing with visualization
162+
- **Seamless Integration**: Switch between Bluetooth and phone audio modes
163+
- **Cross-Platform**: Works on both iOS and Android
164+
- **Live Audio Meters**: Visual feedback showing audio levels in real-time
165+
166+
### Setup & Usage
167+
168+
#### Enable Phone Audio Streaming
169+
1. **Open Friend-Lite app**
170+
2. **Configure Backend Connection** (see Backend Configuration section)
171+
3. **Grant Microphone Permissions** when prompted
172+
4. **Tap "Stream Phone Audio" button** in main interface
173+
5. **Start speaking** - audio streams in real-time to backend
174+
175+
#### Requirements
176+
- **iOS**: iOS 13+ with microphone permissions
177+
- **Android**: Android API 21+ with microphone permissions
178+
- **Network**: Stable connection to Friend-Lite backend
179+
- **Backend**: Advanced backend running with `/ws_pcm` endpoint
180+
181+
#### Switching Audio Sources
182+
- **Mutual Exclusion**: Cannot use Bluetooth and phone audio simultaneously
183+
- **Automatic Detection**: App disables conflicting options when one is active
184+
- **Visual Feedback**: Clear indicators show active audio source
185+
186+
### Troubleshooting Phone Audio
187+
188+
#### Audio Not Streaming
189+
- **Check Permissions**: Ensure microphone access granted
190+
- **Verify Backend URL**: Confirm `ws://[ip]:8000/ws_pcm` format
191+
- **Network Connection**: Test backend connectivity
192+
- **Authentication**: Verify JWT token is valid
193+
194+
#### Poor Audio Quality
195+
- **Check Signal Strength**: Ensure stable network connection
196+
- **Reduce Background Noise**: Use in quiet environment
197+
- **Restart Recording**: Stop and restart phone audio streaming
198+
199+
#### Permission Issues
200+
- **iOS**: Settings > Privacy & Security > Microphone > Friend-Lite
201+
- **Android**: Settings > Apps > Friend-Lite > Permissions > Microphone
202+
203+
#### No Audio Level Visualization
204+
- **Restart App**: Close and reopen the application
205+
- **Check Audio Input**: Ensure microphone is working in other apps
206+
- **Backend Logs**: Verify backend is receiving audio data
207+
152208
## User Workflow
153209

154210
### Device Connection
@@ -163,6 +219,7 @@ Backend URL: wss://[ngrok-subdomain].ngrok.io/ws_pcm
163219

164220
### Audio Streaming
165221

222+
#### Option 1: Bluetooth Audio (OMI Device)
166223
1. **Configure backend connection** (see Configuration Steps above)
167224
2. **Test connection**:
168225
- Tap "Test Connection" in settings
@@ -172,6 +229,16 @@ Backend URL: wss://[ngrok-subdomain].ngrok.io/ws_pcm
172229
- Speak into OMI device
173230
- Audio streams to backend in real-time
174231

232+
#### Option 2: Phone Audio Streaming
233+
1. **Configure backend connection** (see Configuration Steps above)
234+
2. **Enable phone audio**:
235+
- Tap "Stream Phone Audio" button
236+
- Grant microphone permissions when prompted
237+
3. **Start speaking**:
238+
- Speak directly into phone microphone
239+
- Watch real-time audio level visualization
240+
- Audio streams to backend automatically
241+
175242
### Monitoring
176243

177244
1. **Check connection status** in app header
@@ -197,6 +264,13 @@ Backend URL: wss://[ngrok-subdomain].ngrok.io/ws_pcm
197264
- Test with simple backend first
198265
- Monitor backend logs for connection attempts
199266

267+
**Phone Audio Streaming Issues:**
268+
- Grant microphone permissions in device settings
269+
- Ensure stable network connection to backend
270+
- Restart phone audio streaming if no data flowing
271+
- Check backend logs for audio data reception
272+
- Verify JWT authentication token is valid
273+
200274
**Build Errors:**
201275
- Clear Expo cache: `npx expo start --clear`
202276
- Clean prebuild: `npx expo prebuild --clean`
@@ -290,5 +364,5 @@ BluetoothService.onAudioData = (audioBuffer) => {
290364

291365
- **[Backend Setup](../backends/)**: Choose and configure backend services
292366
- **[Quick Start Guide](../quickstart.md)**: Complete system setup
293-
- **[Advanced Backend](../backends/advanced-backend/)**: Full-featured backend option
367+
- **[Advanced Backend](../backends/advanced/)**: Full-featured backend option
294368
- **[Simple Backend](../backends/simple/)**: Basic backend for testing

app/app.json

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@
1717
],
1818
"ios": {
1919
"supportsTablet": true,
20-
"bundleIdentifier": "com.cupbearer5517.friendlite"
20+
"bundleIdentifier": "com.cupbearer5517.friendlite",
21+
"infoPlist": {
22+
"NSMicrophoneUsageDescription": "Friend-Lite needs access to your microphone to stream audio to the backend for processing."
23+
}
2124
},
2225
"android": {
2326
"adaptiveIcon": {
@@ -29,12 +32,29 @@
2932
"android.permission.BLUETOOTH",
3033
"android.permission.BLUETOOTH_ADMIN",
3134
"android.permission.BLUETOOTH_CONNECT",
32-
"android.permission.ACCESS_NETWORK_STATE"
35+
"android.permission.ACCESS_NETWORK_STATE",
36+
"android.permission.FOREGROUND_SERVICE",
37+
"android.permission.FOREGROUND_SERVICE_DATA_SYNC",
38+
"android.permission.POST_NOTIFICATIONS",
39+
"android.permission.RECORD_AUDIO"
3340
],
3441
"usesCleartextTraffic": true
3542
},
3643
"newArchEnabled": true,
3744
"plugins": [
45+
[
46+
"@siteed/expo-audio-studio",
47+
{
48+
"enablePhoneStateHandling": true,
49+
"enableNotifications": true,
50+
"enableBackgroundAudio": true,
51+
"enableDeviceDetection": true,
52+
"iosBackgroundModes": { "useProcessing": true },
53+
"iosConfig": {
54+
"microphoneUsageDescription": "We use the mic for live audio streaming"
55+
}
56+
}
57+
],
3858
[
3959
"react-native-ble-plx",
4060
{
@@ -45,11 +65,30 @@
4565
"bluetoothAlwaysPermission": "This app uses Bluetooth to connect to and interact with nearby BLE devices."
4666
}
4767
],
68+
[
69+
"./plugins/with-ws-fgs",
70+
{
71+
"microphone": true,
72+
"android": {
73+
"permissions": [
74+
"FOREGROUND_SERVICE",
75+
"FOREGROUND_SERVICE_DATA_SYNC",
76+
"FOREGROUND_SERVICE_MICROPHONE",
77+
"POST_NOTIFICATIONS"
78+
]
79+
}
80+
}
81+
],
4882
[
4983
"expo-build-properties",
5084
{
5185
"android": {
52-
"usesCleartextTraffic": true
86+
"usesCleartextTraffic": true,
87+
"compileSdkVersion": 35,
88+
"targetSdkVersion": 35,
89+
"extraMavenRepos": [
90+
"../../node_modules/@notifee/react-native/android/libs"
91+
]
5392
}
5493
}
5594
]

0 commit comments

Comments
 (0)