Skip to content

Commit 59123a0

Browse files
committed
audio playback working
1 parent fec4e63 commit 59123a0

7 files changed

Lines changed: 546 additions & 65 deletions

File tree

bun.lock

Lines changed: 48 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
"ghcr:release": "npm run ghcr:build && npm run ghcr:push"
3838
},
3939
"dependencies": {
40-
"@augmentos/sdk": "^1.1.2",
40+
"@augmentos/sdk": "^1.1.8",
4141
"@aws-sdk/client-s3": "^3.812.0",
4242
"@types/cookie-parser": "^1.4.8",
4343
"@types/cors": "^2.8.17",

src/services/recordings.service.ts

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,24 +63,50 @@ class RecordingsService {
6363
const text = transcription.text.toLowerCase();
6464

6565
if (text.includes('start recording')) {
66-
await this.startRecording(userId, sessionId);
66+
// Send event before starting recording
67+
streamService.broadcastToUser(userId, 'voice-command', {
68+
command: 'start-recording',
69+
timestamp: Date.now()
70+
});
71+
72+
const recordingId = await this.startRecording(userId, sessionId);
73+
6774
session.layouts.showReferenceCard(
6875
"Recording Started",
6976
"Say 'stop recording' when done",
7077
{ view: ViewType.MAIN, durationMs: 3000 }
7178
);
79+
80+
// Send additional confirmation event with the ID
81+
streamService.broadcastToUser(userId, 'recording-started-by-voice', {
82+
id: recordingId,
83+
timestamp: Date.now()
84+
});
7285
}
7386
else if (text.includes('stop recording')) {
87+
// Send event before stopping recording
88+
streamService.broadcastToUser(userId, 'voice-command', {
89+
command: 'stop-recording',
90+
timestamp: Date.now()
91+
});
92+
7493
const recording = Array.from(this.activeRecordings.values())
7594
.find(r => r.sessionId === sessionId && r.userId === userId);
7695

7796
if (recording) {
7897
await this.stopRecording(recording.recordingId);
98+
7999
session.layouts.showReferenceCard(
80100
"Recording Stopped",
81101
"Processing your recording...",
82102
{ view: ViewType.MAIN, durationMs: 3000 }
83103
);
104+
105+
// Send additional confirmation event with the ID
106+
streamService.broadcastToUser(userId, 'recording-stopped-by-voice', {
107+
id: recording.recordingId,
108+
timestamp: Date.now()
109+
});
84110
}
85111
}
86112
}

webview/src/App.tsx

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import RecordingImproved from './screens/RecordingImproved';
44
import PlaybackImproved from './screens/PlaybackImproved';
55
import { useRecordings } from './hooks/useRecordings';
66
import { RecordingI } from './types/recording';
7+
import api from './Api';
78

89
type Screen = 'list' | 'recording' | 'playback';
910

@@ -24,6 +25,37 @@ const ImprovedApp: React.FC = () => {
2425
renameRecording,
2526
getDownloadUrl
2627
} = useRecordings();
28+
29+
// Listen for voice commands via SSE
30+
useEffect(() => {
31+
const handleVoiceCommand = (data: { command: string, timestamp: number }) => {
32+
console.log(`[APP] Received voice command: ${data.command}`);
33+
34+
if (data.command === 'start-recording' && currentScreen !== 'recording') {
35+
console.log('[APP] Voice command is starting a recording');
36+
navigateToRecording();
37+
} else if (data.command === 'stop-recording' && currentScreen === 'recording') {
38+
console.log('[APP] Voice command is stopping a recording');
39+
// The actual stop will be handled by the recording component
40+
}
41+
};
42+
43+
// Set up event listener using our centralized API
44+
console.log('[APP] Setting up voice command listener');
45+
api.events.connect(); // Ensure connection is established
46+
api.events.addEventListener('voice-command', (event) => {
47+
try {
48+
const data = JSON.parse(event.data);
49+
handleVoiceCommand(data);
50+
} catch (error) {
51+
console.error('[APP] Error handling voice command event:', error);
52+
}
53+
});
54+
55+
return () => {
56+
// No need to remove listener explicitly as it will be handled by the central API
57+
};
58+
}, [currentScreen]);
2759

2860
// Navigation handlers
2961
const navigateToList = () => {

0 commit comments

Comments
 (0)