Files
narratio/docs/roadmap/audio-inputs.md

14 KiB

Multi-Format Audio Inputs and Shared Discovery

Status: Core direction agreed; discovery and naming decisions remain open

Goal

Accept ordinary audio recordings without a FLAC-only restriction. MP3, AAC, OGG, WAV, FLAC, and other audio formats can be supplied to the transcription backend. The backend determines whether it can decode a recording; Narratio coordinates selection, preparation, upload, and local progress.

Use shared read-only discovery so preparation and operator inspection agree on the selected sources. Apply the regular-file requirement approved during audit topic 7, incorporating the subsequent operator clarification permitting multiple audio formats. Earlier FLAC-only descriptions are not the target contract.

This is a feature roadmap, not a staged implementation plan. It extends the shared-discovery remediation in CAT-12. The original audit identified inconsistent discovery under the old behavior; the multi-format scope follows the operator's later decision.

Current Baseline

Reviewed against aa0379294fba8422f7e6469261e4730b1c19bd8e.

Area Current behavior
Local preparation Explicit paths must have a .flac extension; directory scanning filters to FLAC.
S3 preparation Object discovery filters to FLAC keys.
Operator inspection Independently repeats local/S3 FLAC filtering and disagrees with preparation on duplicates.
Transcription Both manifest-selected audio validation and fallback directory discovery independently require FLAC.
Preparation reuse Reconstructs source inventory through preparation's discovery functions.
Speaker naming Removes the final filename extension to derive speaker ID and raw transcript path.
Local copying/S3 materialization Preserves selected filenames and copies bytes without transcoding.
WhisperX upload Preserves the prepared basename and uses a generic multipart file part; no FLAC media type is forced.
Speaker checkpoints Store paths, byte identities, and settings without a FLAC-specific schema requirement.

Relevant owners are preparation, inspection, transcription, preparation reuse, speaker reconciliation, speaker state, and multipart upload.

Two naming cases need to remain distinct:

  • Different local sources with the same full basename are already given distinct prepared names. Inspection currently rejects those valid selections.
  • speaker.mp3 and speaker.wav have different basenames but derive the same speaker ID, speaker. Existing preparation disambiguation does not resolve this case. Transcription currently detects the ambiguity before dispatch rather than silently overwriting transcripts/raw/speaker.json.

Existing tests explicitly expect MP3 rejection and FLAC-only directory selection. Those expectations encode behavior intentionally changed by this feature.

Agreed Target

One selection responsibility

Share path resolution, source eligibility, deterministic selection order, and duplicate handling between preparation and inspection. Keep file copying, workspace writes, and manifest transitions with preparation. Inspection remains read-only; it does not execute preparation to discover inputs.

Use the existing audio-focused owner or another narrow shared operation where dependency direction requires it. A discovery framework or public reusable library is unnecessary.

Preserve these established behaviors:

  • Reject repeated selection of the same resolved local source path.
  • Preserve distinct local recordings sharing a full basename through the existing prepared-name disambiguation.
  • Keep the existing local and S3 duplicate-basename rules distinct.
  • Preserve ordinary unambiguous speaker IDs and prepared names.

Same-stem collisions across different extensions are addressed by the open naming decision below. This scope adds no content-based audio deduplication.

Regular files, without a codec allowlist for explicit sources

An explicitly selected local recording must resolve to a regular file. It need not have a .flac suffix or belong to a Narratio-maintained codec allowlist. Existing path rules remain applicable; this decision adds no blanket symlink prohibition or unrelated filesystem hardening.

Automatic directory and S3-prefix discovery must use a consistent policy for selecting candidate audio and handling sidecars. That policy remains open below. S3 discovery deals with object entries; local regular-file checks apply to local sources and materialized copies rather than inventing filesystem types for S3.

Carry selected audio through the whole pipeline

Remove FLAC-only acceptance checks from transcription, including its manifest input path and fallback directory path. A recording selected during preparation must not be rejected later solely because of its extension.

Preserve the actual bytes and meaningful filename suffix during copying, disambiguation, S3 materialization, and upload. Keep the existing format-neutral multipart transport and replay mechanics. This feature requires no transcoding, new MIME registry, or local decoder/probe before submitting audio.

Backend rejection of unsupported or malformed audio remains a transcription failure. Accepting a candidate in Narratio is not a guarantee that every backend deployment supports every codec or container.

Retain local retry and reuse

Preparation, its reuse checks, and inspection must derive the same source inventory under the chosen discovery policy. Transcription must continue to checkpoint and reuse individual speakers with mixed-format inputs.

Keep path, checksum, size, and observable transcription settings as ordinary local reuse evidence. No codec-specific manifest fields or schema migration are required merely to admit additional formats. Keep existing unambiguous FLAC inputs reusable under their ordinary evidence rather than renaming them wholesale.

After transcription, merge and later stages consume transcript JSON; this feature does not require codec changes in Audita, Notarius, or Scriptorium.

Required Changes

Discovery and eligibility

Replace duplicated isFlac/isInspectionFlacPath selection rules and error messages in local and S3 discovery. Implement the approved regular-file check consistently for local recordings. Resolve same-source duplicates and the existing basename disagreement through the shared selection owner.

Apply the chosen automatic-discovery policy to source discovery and transcription's fallback enumeration. Manifest-registered audio is already explicitly selected; it should not encounter another extension-based gate.

Primary areas: internal/stage/prepare.go, internal/app/operator_inspection.go, internal/audio, and internal/stage/transcribe.go.

Speaker identity and prepared destinations

Apply the chosen same-stem policy consistently before transcription dispatch. Account for prepared filenames as well as original source paths: checking original stems alone must not reject the distinct same-basename inputs that preparation already disambiguates successfully.

Keep speaker mappings, raw transcript paths, and checkpoint keys consistent with the resulting IDs. Retain errors that identify ambiguous sources if early rejection is selected; preserve actual format suffixes if naming is extended. Use existing reporting paths to make any derived names understandable to operators.

Primary areas: preparation's destination naming, buildTranscribeJobs, source inspection, and the speaker/input mapping documentation.

Reuse and transport verification

Review source-inventory reconstruction in prepare_resume.go and input discovery used by transcribe reconciliation. Preserve per-speaker success across ordinary retries with mixed formats. The current generic copy, hash, checkpoint, and upload mechanisms should be reused rather than replaced with format-specific machinery.

Confirm that multipart filenames and audio bytes survive initial submission and transport replay unchanged. The existing generic file-part content type is not a FLAC-only assumption and need not change for this feature.

Documentation and tests

Update configuration, operations, preparation/transcription internals, examples, and the WhisperX integration description where needed to explain the approved discovery and naming behavior. FLAC can remain an example; it should not be presented as the only permissible input format. Keep backend-specific decoding capabilities under the backend's ownership.

Replace tests whose purpose is to reject MP3 or require FLAC-only selection with tests of the chosen contract. Retain unrelated file, path, and failure coverage; do not mechanically rename every FLAC fixture.

Validation Outcomes

Use representative offline behavior tests with real temporary files and fakes at the transcription/storage boundaries:

  • Preparation and inspection agree for explicit mixed-format sources and for directory/S3 discovery, including sidecar behavior under the selected policy.
  • Non-FLAC audio registered in the manifest reaches transcription. Fallback discovery follows the same candidate-selection policy.
  • Duplicate resolved paths are rejected, distinct same-basename local recordings remain usable, and cross-extension same-stem cases follow the selected rule.
  • Copying and S3 materialization retain the selected bytes and suffixes; upload and replay retain the multipart filename and payload.
  • A partial mixed-format transcription can retry without repeating previously checkpointed speakers, while changed inputs still receive normal reconciliation.
  • Non-regular local inputs are rejected consistently, and ordinary existing FLAC inputs retain their established naming and reuse behavior.
  • Backend decoding errors remain visible failures; discovery does not claim to have validated the actual encoding.

Offline tests verify Narratio's selection and transport, not a live backend's codec support. No paid/live transcription gate, local codec toolchain, or new benchmark requirement is introduced.

Relationship to Other Work

This roadmap owns the multi-format extension and shared discovery work associated with CAT-12. Original audit findings remain open until implementation is verified.

The agreed source-identity and transfer-size changes in topic 4 remain separate acquisition corrections. Coordinate shared audio code without turning this feature into a general storage/resource refactor.

The session-restore roadmap enables downstream work without raw audio. This roadmap concerns workflows that actually select and transcribe audio. Neither roadmap requires completing the other first. Remote execution checkpoints, new audio-size caps, additional format conversions, and live-stream input support are outside this scope.

Open Decisions

Automatic directory and S3-prefix discovery

Explicit file selection can be extension-agnostic. Automatic discovery still needs a policy: current filtering ignores sidecars such as ignore.txt; simply removing that filter would select them too.

Recommendation: Treat the configured audio directory or prefix as a collection of intended audio selected by the operator. Select regular local files and ordinary S3 object entries, retaining existing enumeration scope and directory-marker handling, without an extension filter. Let the backend reject a non-audio entry. Use explicit local file selection when the surrounding directory contains other material.

This is the least complex extension-independent rule, works for unfamiliar suffixes and extensionless recordings, and avoids maintaining a codec registry. The tradeoff is an operator-visible change: sidecars previously ignored can now be submitted and cause transcription failure. An audio-only source convention is a proposed operational contract requiring approval, not an already agreed restriction on source directories.

Alternative: Use a shared, broad audio-extension discovery filter, including the named common formats, while leaving explicit file selection unrestricted. This preserves convenient mixed-content folders and avoids submitting obvious sidecars. However, unfamiliar suffixes can still be silently excluded, the list needs maintenance, and S3 currently offers prefix selection rather than an explicit per-object list. Supporting arbitrary suffixes there would need an operator override or another selection mechanism. Those additions require an explicit scope choice; a discovery filter should not become a universal codec validation rule.

Same speaker stem across different audio extensions

speaker.mp3 and speaker.wav both derive speaker ID speaker. This ambiguity must be handled consistently even though both formats are acceptable. Current transcription already rejects the duplicate ID.

Recommendation: Preserve current stem-based speaker IDs and detect remaining ambiguities during shared discovery, after applying existing prepared-name disambiguation. Identify both source paths and ask the operator to select one encoding or give recordings distinct names. This moves an existing failure earlier, preserves established speaker mappings/checkpoint identities, and avoids new automatic naming behavior for a pair that may be two encodings of the same recording. It preserves the existing acceptance of distinct local sources with the same full basename; their prepared names are already disambiguated.

Alternative: Extend deterministic prepared-name disambiguation to collisions in derived speaker IDs, preserving each format suffix. This accepts both recordings without manual renaming and can reuse the existing naming technique. It adds identity/naming cases, requires source-to-ID visibility for speaker mappings, and may transcribe duplicate encodings that the operator did not intend as separate sources. Preserve existing unique IDs and decide how this applies to local and S3 inputs before adopting it; do not merge recordings or choose one encoding silently.