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

256 lines
13 KiB
Markdown
Raw Normal View History

2026-12-01 14:52:09 +00:00
# Multi-Format Audio Inputs and Shared Discovery
Status: Implemented and verified
2026-12-01 14:52:09 +00:00
## 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](audit/discussion.md#7-give-preparation-and-inspection-the-same-audio-selection-rules),
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](audit/catalog.md#cat-12--p2-share-audio-discovery-and-accept-valid-same-basename-recordings-in-inspection).
The original audit identified inconsistent discovery under the old behavior;
the multi-format scope follows the operator's later decision.
## Historical Baseline
2026-12-01 14:52:09 +00:00
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](../../internal/stage/prepare.go),
[inspection](../../internal/app/operator_inspection.go),
[transcription](../../internal/stage/transcribe.go),
[preparation reuse](../../internal/stage/prepare_resume.go),
[speaker reconciliation](../../internal/stage/transcribe_reconciliation.go),
[speaker state](../../internal/manifest/transcribe_state.go), and
[multipart upload](../../internal/adapters/whisperx/multipart_body.go).
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.
Detect remaining same-stem collisions across different extensions during shared
discovery, after applying existing prepared-name disambiguation. Identify both
source paths and ask the operator to select one encoding or give the recordings
distinct names. Preserve stem-based speaker IDs rather than adding automatic
renaming for cross-extension collisions. This moves an existing transcription
failure earlier; it does not add content-based audio deduplication.
2026-12-01 14:52:09 +00:00
### 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.
S3 discovery deals with object entries; local regular-file checks apply to local
sources and materialized copies rather than inventing filesystem types for S3.
### Broad extension filtering for automatic discovery
Use one shared, case-insensitive extension filter when scanning a local audio
directory or S3 prefix. The initial discovery set is:
```text
.aac .aif .aifc .aiff .alac .amr .ape .au .caf .flac
.m4a .m4b .mka .mp2 .mp3 .mp4 .oga .ogg .opus .snd
.wav .wave .weba .webm .wma .wv
```
These suffixes identify candidates, including common audio-bearing containers;
they do not guarantee backend decoding or the presence of a valid audio stream.
Keep the set in one central, discoverable location in the shared audio-selection
owner. Preserve existing enumeration scope and directory-marker handling.
Automatic scans ignore nonmatching entries such as `ignore.txt`, unfamiliar
suffixes, and extensionless files. Explicit local file selections remain
extension-agnostic, as do already registered manifest audio inputs. The discovery
set is not a universal codec-validation rule. Document its scope, including that
S3 currently selects by prefix and therefore uses this filter; no new S3 override
or per-object selector is introduced by this feature.
Automatic scans in preparation, inspection, preparation reuse, and transcription
must use the same filter. This supports mixed-content source directories without
submitting obvious sidecars and avoids divergent format lists among consumers.
2026-12-01 14:52:09 +00:00
### 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 shared extension set to automatic source discovery and transcription's
2026-12-01 14:52:09 +00:00
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
Detect unresolved same-stem ambiguity consistently during shared discovery,
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.
2026-12-01 14:52:09 +00:00
Keep speaker mappings, raw transcript paths, and checkpoint keys consistent with
the existing IDs. Report both ambiguous sources and direct the operator to select
one encoding or rename recordings. Preserve actual format suffixes and the
established disambiguation of identical full basenames. Do not silently choose
an encoding or extend automatic naming to the unresolved cross-extension case.
2026-12-01 14:52:09 +00:00
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. Automatic scans recognize the shared suffix set
case-insensitively and ignore nonmatching sidecars; explicit files with other
suffixes or no extension are not rejected solely by their names.
2026-12-01 14:52:09 +00:00
- 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 unresolved cross-extension same-stem cases fail during
discovery with both sources identified, before transcription is dispatched.
2026-12-01 14:52:09 +00:00
- 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. CAT-12 is closed after implementation and verification; the
historical audit reports remain unchanged.
2026-12-01 14:52:09 +00:00
The agreed source-identity and transfer-size changes in
[topic 4](audit/discussion.md#4-keep-downloaded-audio-and-its-source-identity-together)
are implemented, as is streaming local audio copying (CAT-04, CAT-06, and
CAT-08 are closed in the catalog). Build on those acquisition paths while
changing discovery; preserve their identity, transfer bounds, and streaming
behavior. This feature does not reopen the storage/resource remediation scope.
2026-12-01 14:52:09 +00:00
The implemented [publication-import workflow](../operations.md#restore-workflow) enables downstream work without
2026-12-01 14:52:09 +00:00
raw audio. This roadmap concerns workflows that actually select and transcribe
audio. These features have independent scopes. Remote execution
2026-12-01 14:52:09 +00:00
checkpoints, new audio-size caps, additional format conversions, and live-stream
input support are outside this scope.