Refactor transcript file handling to use JSON metadata

This commit changes the way transcriptions are stored and accessed.
Instead of using plain text files (`.transcript.txt`), transcriptions
will now be part of a JSON metadata file (`<stem>.json`). This allows
for richer metadata to be stored alongside the transcript, such as
duration, and provides a more robust mechanism for tracking
transcription states.

The changes include:
- Updating documentation and code to reflect the new `.json` file
  extension.
- Modifying file handling logic to read and write JSON metadata.
- Adjusting tests to accommodate the new file format.
This commit is contained in:
2026-04-27 13:08:36 +02:00
parent 66b3b7e4c8
commit c15590f3e0
10 changed files with 78 additions and 46 deletions
+4 -4
View File
@@ -319,10 +319,10 @@ mod tests {
}
/// Seed a `<stem>.json` next to a (presumed already-touched)
/// `<stem>.m4a`. Variant is `Transcript::Silent` because these
/// tests historically used an empty `.transcript.txt`, which
/// mapped to `TranscriptState::Silent`. Tests that need real
/// content call `seed_meta_with` with the desired variant.
/// `<stem>.m4a`. Variant is `Transcript::Silent` — these tests
/// only care that the recording is in *some* terminal state
/// (transcribed), not what was actually said. Tests that need
/// real content call `seed_meta_with` with the desired variant.
async fn seed_meta(case_dir: &std::path::Path, stem: &str) {
crate::paths::write_recording_meta_sync(
case_dir,
+3 -4
View File
@@ -176,10 +176,9 @@ pub async fn delete_oneliner_unless_manual(
/// to it with the `.json` extension.
///
/// This is the single reader of that sidecar's transcript field.
/// Every call-site that used to do
/// `tokio::fs::read_to_string(...).ok()` or
/// `with_extension("transcript.txt").exists()` should go through here
/// so the three-state semantics stay consistent across the codebase.
/// Every "is this recording transcribed?" check should go through
/// here so the three-state semantics (Pending / Silent / Content)
/// stay consistent across the codebase.
pub async fn read_transcript_state(audio_stem_path: &Path) -> TranscriptState {
TranscriptState::from_meta(read_recording_meta(audio_stem_path).await.as_ref())
}