Skip to content

Commit fcf71cc

Browse files
vNeeL-codeclaude
andcommitted
Fix audio: send raw PCM to LiteRT-LM instead of WAV
Content.AudioBytes expects raw PCM (16kHz mono 16-bit), not WAV with 44-byte RIFF header. The header bytes were being parsed as audio samples causing "Failed to read pcm frames, error code: -2". Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 352c339 commit fcf71cc

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

app/src/main/kotlin/com/gemma/api/mcp/MCPServer.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ class MCPServer(
355355
return ToolResult(false, "", "No microphone permission")
356356
}
357357

358-
val audioData = audioRecorder.record(duration, rawPcm = false)
358+
val audioData = audioRecorder.record(duration, rawPcm = true) // Raw PCM for LiteRT-LM
359359
?: return ToolResult(false, "", "Audio recording failed")
360360

361361
// Deliver audio bytes via callback so GemmaService can queue them for next inference

app/src/main/kotlin/com/gemma/api/ui/InputOverlay.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ class InputOverlay(
163163
recordingJob = CoroutineScope(Dispatchers.Main).launch {
164164
Timber.i("InputOverlay: Recording up to 30s audio...")
165165
val audio: ByteArray? = withContext(Dispatchers.IO) {
166-
audioRecorder.record(30, false)
166+
audioRecorder.record(30, true) // Raw PCM for LiteRT-LM (no WAV header)
167167
}
168168

169169
// Recording finished (either released or hit 30s cap)

0 commit comments

Comments
 (0)