Skip to content

Add VTT subtitle export and --chars-per-caption option#126

Merged
alexkroman merged 1 commit into
mainfrom
claude/funny-cray-vqio2e
Jun 12, 2026
Merged

Add VTT subtitle export and --chars-per-caption option#126
alexkroman merged 1 commit into
mainfrom
claude/funny-cray-vqio2e

Conversation

@alexkroman

Copy link
Copy Markdown
Collaborator

Summary

Adds support for VTT (WebVTT) subtitle export alongside the existing SRT format, and introduces a --chars-per-caption option to control caption line length for both subtitle formats.

Key Changes

  • New subtitle format: Added vtt as an output choice (-o vtt) for both transcribe and transcripts get commands, mirroring the existing SRT support
  • Caption line length control: Introduced --chars-per-caption option (integer ≥1) that forwards to the SDK's subtitle export methods for both SRT and VTT formats
  • Validation: Added validate_chars_per_caption() to ensure the flag is only used with subtitle output formats, rejecting it for text/id/status/utterances/json with a helpful error message
  • Refactored subtitle handling: Extracted SRT/VTT export logic into a _SUBTITLE_RENDERERS dict separate from _FIELD_RENDERERS, allowing both formats to share the chars_per_caption parameter handling
  • Protocol definition: Added _SubtitleTranscript protocol to type-hint the subtitle export interface
  • Code generation: Updated --show-code to emit correct export calls with chars_per_caption when specified (e.g., transcript.export_subtitles_vtt(chars_per_caption=42))
  • Help text and examples: Updated command help, snapshot tests, and documentation to reflect VTT as an available output format

Implementation Details

  • The chars_per_caption parameter is validated early in both transcribe and transcripts get commands before any API calls
  • Both subtitle export paths (stdout and --out file) correctly forward the parameter
  • The --show-code feature generates executable Python that includes the chars_per_caption argument in subtitle export calls
  • All existing SRT tests updated to explicitly assert chars_per_caption=None is passed when not specified
  • New tests cover VTT export, parameter forwarding, validation errors, and code generation with the new option

https://claude.ai/code/session_01VkY5GdVBVM31FbGwpb9sb9

Two gaps vs on-device transcription CLIs (e.g. yap):

- `-o vtt` exports WebVTT captions via the SDK's /vtt endpoint, next to
  the existing `-o srt`, on both `transcribe` and `transcripts get`.
- `--chars-per-caption N` caps the caption line length for the srt/vtt
  exports (the API's chars_per_caption knob). The flag is shared via an
  options.py factory and rejected up front with any non-subtitle `-o`,
  before any upload/fetch.

--show-code mirrors both: `-o vtt` generates export_subtitles_vtt(), and
the knob lands in the generated export call as a kwarg.

https://claude.ai/code/session_01VkY5GdVBVM31FbGwpb9sb9
@alexkroman alexkroman enabled auto-merge June 12, 2026 20:34
@alexkroman alexkroman added this pull request to the merge queue Jun 12, 2026
Merged via the queue into main with commit cccd0d1 Jun 12, 2026
16 checks passed
@alexkroman alexkroman deleted the claude/funny-cray-vqio2e branch June 12, 2026 20:41
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