memorix icon indicating copy to clipboard operation
memorix copied to clipboard

feat: audio ingestion via Whisper API

Open RaviTharuma opened this issue 8 months ago • 3 comments

Summary

Adds an memorix_ingest_audio MCP tool that transcribes audio files using the Whisper API and stores the transcript as a memorix observation.

What's included

  • src/multimodal/audio-loader.ts — Whisper API client with:
    • Configurable model (MEMORIX_WHISPER_MODEL, default: whisper-1)
    • Language hint and prompt support
    • Chunked file reading for large files
    • Automatic format detection from extension (mp3, wav, m4a, ogg, flac, webm, mp4)
  • src/multimodal/index.ts — shared multimodal utilities (MIME detection, file validation)
  • src/server.ts — MCP tool registration (memorix_ingest_audio)
  • tests/multimodal/audio-loader.test.ts — 8 tests covering:
    • Transcript extraction and observation storage
    • Unsupported format rejection
    • Missing file handling
    • Language and prompt passthrough
    • API error propagation

Design decisions

  • LLM-optional: requires MEMORIX_WHISPER_API_KEY (falls back to OPENAI_API_KEY). Tool returns clear error if unconfigured.
  • Stores transcript as how-it-works observation type with audio metadata in facts.
  • No new npm dependencies — uses native fetch for API calls and fs for file reading.

Tests

8 pass, 0 fail

RaviTharuma avatar Mar 29 '26 22:03 RaviTharuma

Thanks for pushing on multimodal ingestion — the capability is useful, but this one still has a couple of concrete blockers.

  1. The test file uses bun:test, while this repo runs vitest in CI. Right now that means the PR fails immediately in the standard test matrix.
  2. In src/server.ts, the object passed into storeObservation is inferred as type: string, but storeObservation expects a real ObservationType.
  3. More importantly, the config path is too loose for the implementation: transcribeAudio() pulls the generic Memorix LLM API key via getLLMApiKey(), but the code then talks specifically to OpenAI/Groq Whisper transcription endpoints. In a valid Memorix setup that is configured for Anthropic or another non-Whisper provider, this can end up sending the wrong credential/provider combination to an incompatible API.

So I don't think this is just a test-fix PR — it needs one more pass on provider/config semantics as well.

AVIDS2 avatar Mar 30 '26 13:03 AVIDS2

Thanks for the detailed breakdown — all three points are valid.

  1. bun:test → vitest: Will switch the test file imports to vitest globals.
  2. ObservationType inference: Will add an explicit cast / assertion so the object flowing into storeObservation satisfies the ObservationType constraint rather than widening to string.
  3. Provider/config semantics: This is the substantive one. The right fix is to add a Whisper-specific config path (e.g. MEMORIX_WHISPER_API_KEY / MEMORIX_WHISPER_BASE_URL) that is separate from the general LLM key, so audio ingestion doesn't assume the general LLM provider is Whisper-compatible. I'll update transcribeAudio() to use those dedicated config values and document them in the README section for audio ingestion.

RaviTharuma avatar Apr 08 '26 17:04 RaviTharuma

Leaving this open as a future ingestion candidate, but it still should not merge as-is.

The key blocker is the provider credential contract: provider=groq needs provider-correct key resolution, especially GROQ_API_KEY, and must not accidentally send an OpenAI credential to a Groq endpoint. After 1.0.8, this also needs CLI + MCP + docs parity if it becomes a native Memorix feature.

A safe next revision should tighten provider configuration first, then add the CLI-facing ingest path and docs.

AVIDS2 avatar Apr 21 '26 14:04 AVIDS2