fix(frontend): handle voice PCM data as JSON instead of binary

- Add onVoicePcmData and onVoiceActiveUser handlers to WebSocket interface
- Add voice_pcm_data and voice_active_user event cases in socket message handler
- Update useAudioPlayback to decode base64 PCM from JSON format
- Connect onVoicePcmData to audio.handleIncomingPcm in App.tsx

Format change:
- Old: Binary (4 bytes userId + PCM buffer)
- New: JSON {userId: string, pcm: base64string}

This matches the format sent by discord-gateway via Redis.
Now PCM audio will flow correctly: Discord → Gateway → Redis → Backend → WebSocket → Browser!

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
MythEclipse
2026-06-08 21:22:00 +07:00
co-authored by Claude Opus 4.8
parent 1c7b7e6398
commit 2e9e9c1a06
3 changed files with 31 additions and 7 deletions
+1 -1
View File
@@ -76,7 +76,7 @@ export default function App() {
);
const socket = useDashboardSocket({
onBinary: audio.handleIncomingPcm,
onVoicePcmData: (d) => audio.handleIncomingPcm(d as { userId: string; pcm: string }),
onUserState: (users) => setActiveSpeakers(users as ActiveSpeaker[]),
onMessageCreated: (m) =>
messages.setMessages((prev) => mergeMessages(prev, [m as MessageRecord])),