diff --git a/frontend/src/hooks/useConversation.ts b/frontend/src/hooks/useConversation.ts index b1c2543..8f44cc6 100644 --- a/frontend/src/hooks/useConversation.ts +++ b/frontend/src/hooks/useConversation.ts @@ -151,28 +151,14 @@ export function useConversation() { break; case 'audio': { - // Incoming PCM16 audio from Kira + // Incoming Opus audio from TTS (full response, not streamed) if (msg.data && audioRef.current) { - // Accumulate audio chunks and create a blob const binary = atob(msg.data); const bytes = new Uint8Array(binary.length); for (let i = 0; i < binary.length; i++) { bytes[i] = binary.charCodeAt(i); } - audioBufferRef.current.push(bytes); - - // Convert accumulated PCM16 to WAV blob for playback - const allChunks = audioBufferRef.current; - const totalLen = allChunks.reduce((s, c) => s + c.length, 0); - const combined = new Uint8Array(totalLen); - let offset = 0; - for (const chunk of allChunks) { - combined.set(chunk, offset); - offset += chunk.length; - } - - const wav = pcm16ToWav(combined); - const blob = new Blob([wav], { type: 'audio/wav' }); + const blob = new Blob([bytes], { type: 'audio/ogg' }); const url = URL.createObjectURL(blob); audioRef.current.src = url; audioRef.current.play().catch(() => {});