Skip to content

Add --save-transcript and --save-dir flags for transcript/audio file output#191

Merged
alexkroman merged 1 commit into
mainfrom
claude/dazzling-planck-f2taqc
Jun 16, 2026
Merged

Add --save-transcript and --save-dir flags for transcript/audio file output#191
alexkroman merged 1 commit into
mainfrom
claude/dazzling-planck-f2taqc

Conversation

@alexkroman

Copy link
Copy Markdown
Collaborator

Adds transcript and audio file saving to assembly stream, with two modes:

  • --save-transcript PATH: Write finalized turns to a plain-text file, one line per turn
  • --save-dir DIR --name "Title": Auto-name both transcript and WAV under DIR/YYYY-MM-DD/ with a timestamped, slugged stem

Key changes

New modules:

  • aai_cli/streaming/naming.py: Filename assembly for --save-dir (date bucketing, slug generation, path validation)
  • aai_cli/streaming/transcript.py: TranscriptWriter class that appends finalized turns to a UTF-8 text file, flushing per turn for robustness against Ctrl-C

Modified modules:

  • aai_cli/commands/stream/_exec.py:
    • Added save_transcript, save_dir, name fields to StreamOptions
    • New _reject_save_with_show_code() validation (save flags incompatible with --show-code)
    • New _resolve_save_targets() to assemble final paths from flags, with mutual-exclusivity checks
    • Wired transcript writer into StreamSession initialization
  • aai_cli/streaming/session.py:
    • Added _finalized_turn_line() helper to format turns for the transcript (matching text renderer's speaker prefixes)
    • Added save_transcript field to StreamSession
    • Integrated TranscriptWriter into turn recording and LLM follow mode
  • aai_cli/commands/stream/__init__.py: Added CLI options for --save-transcript, --save-dir, --name with help text and examples

Test coverage:

  • tests/test_stream_session.py: Refactored to focus on session lifecycle and transcript saving; removed system-audio tests (moved to new file)
  • tests/test_stream_system_audio.py: New file with all --system-audio family tests (parallel sessions, worker errors, mic/system wiring)
  • tests/test_stream_exec.py: Added tests for transcript writing, file validation, and --save-dir auto-naming with date bucketing
  • tests/test_streaming_naming.py: Unit tests for slug generation, path resolution, and directory creation
  • tests/test_streaming_transcript.py: Unit tests for TranscriptWriter and path validation

Implementation details

  • Transcript lines are written only for finalized, non-empty turns; partials and empty turns are skipped
  • Speaker labels (diarization) are prefixed exactly as the text renderer does, so saved transcripts match on-screen output
  • --save-dir auto-names files with a sortable timestamp (YYYY-MM-DD-HHMMSS) and optional slug from --name, bucketed under DIR/YYYY-MM-DD/
  • Mutual exclusivity: --save-dir cannot combine with explicit --save-audio/--save-transcript paths, and cannot be used with --system-audio (two parallel streams can't share one WAV)
  • File validation happens before streaming starts (missing parent directories fail cleanly up front)
  • Flushing per turn ensures a Ctrl-C still leaves a complete transcript of turns seen so far
  • Test file split: system-audio tests moved to dedicated test_stream_system_audio.py to keep test_stream_session.py under the 500-line gate

https://claude.ai/code/session_01UcH9QQmiZXviKzCpof7gJ4

Adds three save flags to `assembly stream`, grouped under a new "Saving"
help panel alongside the existing --save-audio:

- --save-transcript PATH: write finalized turns to a text file, one per
  line (the same plain text `-o text` emits), flushed per turn so a Ctrl-C
  leaves a complete transcript so far.
- --save-dir DIR + --name TITLE: hand filename assembly to the CLI. Files
  land under DIR/YYYY-MM-DD/ with a timestamped, slugged stem
  (YYYY-MM-DD-HHMMSS[-slug]), and a matching WAV shares the stem — so a
  wrapper script's hand-rolled date(1) + tr/sed slug block can go away.

New core pieces: streaming/transcript.py (the turn-by-turn text writer,
parallel to record.tee_wav) and streaming/naming.py (slug + path
assembly). StreamSession grows a transcript writer opened/closed in
_guarded and fed from both the plain and --llm turn paths.

Also splits the --system-audio tests out of test_stream_session.py into
test_stream_system_audio.py to stay under the 500-line file gate.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UcH9QQmiZXviKzCpof7gJ4
@alexkroman alexkroman enabled auto-merge June 16, 2026 21:10
@alexkroman alexkroman added this pull request to the merge queue Jun 16, 2026
Merged via the queue into main with commit 162720c Jun 16, 2026
19 checks passed
@alexkroman alexkroman deleted the claude/dazzling-planck-f2taqc branch June 16, 2026 21:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants