{"record":{"id":"d2719d1c3df3759c","repo":"tinyhumansai/openhuman","slug":"audio-blob-is-empty-d2719d","errorCode":null,"errorMessage":"audio blob is empty","messagePattern":"audio blob is empty","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"app/src/features/human/voice/wavEncoder.ts","lineNumber":23,"sourceCode":" *\n * Why this exists: the hosted STT upstream (GMI Whisper) rejects\n * Opus-in-WebM payloads with \"Invalid JSON payload\", and Chromium-based\n * runtimes (including the CEF webview Tauri ships) don't reliably support\n * `MediaRecorder` with MP4. WAV at Whisper's native 16kHz is the most\n * portable thing we can hand the backend without standing up an ffmpeg\n * dependency in the desktop app.\n *\n * Implementation: `OfflineAudioContext` decodes + resamples in one pass,\n * then we mix to mono and write a standard RIFF/WAVE header in front of\n * the 16-bit little-endian samples. Synchronous after the decode promise\n * resolves so we can pipe it straight into the STT client.\n */\n\nconst TARGET_SAMPLE_RATE = 16_000;\n\nexport async function encodeBlobToWav(blob: Blob): Promise<Blob> {\n  if (!blob || blob.size === 0) {\n    throw new Error('audio blob is empty');\n  }\n  const arrayBuffer = await blob.arrayBuffer();\n  // `decodeAudioData` consumes the buffer, so use a copy if the caller\n  // happens to reuse `blob` afterwards.\n  const decoded = await decodeToBuffer(arrayBuffer.slice(0));\n  const mono = mixDownToMono(decoded);\n  const wav = buildWav(mono, TARGET_SAMPLE_RATE);\n  return new Blob([wav], { type: 'audio/wav' });\n}\n\n/**\n * Decode arbitrary compressed audio into an `AudioBuffer` at\n * `TARGET_SAMPLE_RATE`. Uses `OfflineAudioContext` so the resample\n * happens during decode rather than via a separate render step.\n */\nasync function decodeToBuffer(arrayBuffer: ArrayBuffer): Promise<AudioBuffer> {\n  // OfflineAudioContext requires concrete length/channels up front, but\n  // `decodeAudioData` returns a buffer at the source rate. Trick: decode","sourceCodeStart":5,"sourceCodeEnd":41,"githubUrl":"https://github.com/tinyhumansai/openhuman/blob/a221052e0df5b1f7598fceba7329fd1af95d6699/app/src/features/human/voice/wavEncoder.ts#L5-L41","documentation":"Required-flag error from `openhuman memory query`. After the parsing loop, `--namespace` was never supplied. Unlike ingest (which defaults to namespace 'cli'), query deliberately has no namespace default — you must name the namespace to search explicitly.","triggerScenarios":"`openhuman memory query --query \"hello\"` (query given, namespace missing); `openhuman memory query -v`; a script that only passes -q because the author assumed the ingest default applies to query too.","commonSituations":"Assuming the 'cli' default from ingest carries over to query; scripts where the namespace variable is empty and the flag is conditionally skipped; exploring a fresh workspace and not knowing which namespaces exist.","solutions":["Add `-n/--namespace <ns>` to the query command","List existing namespaces first with `openhuman memory namespaces`","In scripts, fail fast when the namespace variable is empty instead of silently dropping the flag"],"exampleFix":"# before\nopenhuman memory query --query \"hello\"\n# after\nopenhuman memory namespaces   # pick a ns, then:\nopenhuman memory query --namespace cli --query \"hello\"","handlingStrategy":"validation","validationCode":"# bash: refuse to invoke query without a namespace\n[ -n \"${NS:-}\" ] || { echo '--namespace is required for query' >&2; exit 2; }\nopenhuman memory query --namespace \"$NS\" --query \"$Q\"","typeGuard":null,"tryCatchPattern":"if ! out=$(openhuman memory query \"$@\" 2>&1); then\n  case \"$out\" in *\"--namespace is required\"*) openhuman memory namespaces >&2; exit 2;; esac\n  printf '%s\\n' \"$out\" >&2; exit 1\nfi","preventionTips":["Do not assume ingest's 'cli' default applies to query — it does not","Discover valid namespaces with `openhuman memory namespaces` before scripting queries"],"tags":["cli","required-argument","usage","memory","query"],"backgroundTag":null,"analyzedSha":"a221052e0df5b1f7598fceba7329fd1af95d6699","analyzedAt":"2026-08-16T12:47:06.542Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}