Skip to content

Commit 908f439

Browse files
feat(cli): let transcribe --to write srt or vtt straight from a media file (#5215)
* feat(cli): let transcribe --to write srt or vtt straight from a media file * fix(cli): fail a missing transcribe --output folder before decoding * fix(cli): reject a transcribe --output that names a folder * test(cli): check CJK caption grouping on the parsed cues * fix(cli): keep transcribe --output from overwriting the media or its transcript - Refuse an --output that resolves to the input file or the transcript.json the run writes, before the engine starts. - When the caption file cannot be written after transcribing, say the transcript was saved and name the caption path and reason, instead of reporting a failed transcription. - Docs: a one-run export groups cues for languages without spaces; exporting the saved transcript later may split them differently. * fix(cli): refuse caption paths that alias the media or transcript - The overwrite check compares files, not path text: an existing target is matched by device and inode, a new one by its real folder and its name ignoring letter case. Links, folder aliases such as /var and /private/var, and other letter case are all refused. - The check also covers the default caption path, so exporting transcript.srt to srt no longer rewrites its own input. - A trailing -o with no path fails before transcribing. - One constant names transcript.json for the engines, the import and the check. * fix(cli): refuse caption links to the transcript before it exists - A caption path that is a link is followed to where the write would land, so a link to the transcript.json the run is about to create is refused before transcribing. - A test pins the folder letter-case check on a case-insensitive disk, and says which branch ran. * fix(cli): check the caption file against the transcript right before writing it - Right before the caption write, by when the transcript exists, a destination that is the same file as the input or transcript.json is refused. The OS resolves every link, relative link and alias, so the hand-written link following is gone. - The run keeps the transcript and says the caption file could not be written and why. An export whose caption write fails now says so too, instead of crashing. - The check before transcribing stays as an early refusal for the common cases. * fix(cli): compare caption paths by name when the disk reports no inode - Some network shares report inode 0 for every file; such a pair is compared by folder and name instead of being called the same file. The check before transcribing and the one at write time now share one comparison. - The link-through-a-file tests accept ENOENT as well as ENOTDIR, the code Windows reports. * fix(cli): resolve both caption paths fully when the disk reports inode 0 - When either file reports inode 0 and both exist, compare their fully resolved real paths, so a link to the media or the transcript is still refused. The folder and name compare stays for a path that does not exist yet. - Tests zero the inode on every path, on the caption path only, or on the protected file only. * test(cli): say plainly why the caption-write test accepts two error codes
1 parent 2c082b3 commit 908f439

7 files changed

Lines changed: 509 additions & 39 deletions

File tree

‎docs/packages/cli.mdx‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -268,8 +268,9 @@ npx hyperframes transcribe video.mp4 --model medium.en --language en
268268
npx hyperframes transcribe subtitles.srt
269269
npx hyperframes transcribe openai-response.json
270270

271-
# Export a caption sidecar
271+
# Export a caption sidecar, from a transcript or straight from the media
272272
npx hyperframes transcribe transcript.json --to srt
273+
npx hyperframes transcribe video.mp4 --to vtt
273274
```
274275

275276
| Flag | Description |
@@ -278,7 +279,7 @@ npx hyperframes transcribe transcript.json --to srt
278279
| `--engine, -e` | ASR engine: `auto` (default — Parakeet if installed and the language is one of its 25, else whisper), `parakeet` (fails if Parakeet is missing, broken, or lacks the `--language`), or `whisper` |
279280
| `--model, -m` | Whisper model (default `small.en`): `tiny.en`, `base.en`, `small.en`, `medium.en`, `large-v3` |
280281
| `--language, -l` | Language code (`en`, `es`, `ja`, …). Whisper transcribes as this language; Parakeet, used when it covers it, detects the language itself. |
281-
| `--to` | Export a sidecar instead: `srt` or `vtt` |
282+
| `--to` | Write an `srt` or `vtt` sidecar: from a transcript file it exports instead of importing; from audio or video it is written beside `transcript.json`, with cues for languages without spaces grouped, which exporting that `transcript.json` later may split differently |
282283
| `--output, -o` | Where the exported SRT/VTT goes |
283284
| `--preserve-cues` | Keep each transcript entry as its own caption cue, skipping word-level grouping |
284285
| `--optional` | Skip and exit 0 when whisper-cpp is unavailable, instead of failing. For pipelines that can carry on without captions. A broken Parakeet install is a real failure: it exits 1 even when whisper-cpp is missing. |

‎packages/cli/src/commands/init.ts‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ import {
4646
import { fetchRemoteTemplate } from "../templates/remote.js";
4747
import { trackInitTemplate } from "../telemetry/events.js";
4848
import { DEFAULT_MODEL, hasFFmpeg } from "../whisper/manager.js";
49+
import { TRANSCRIPT_FILE } from "../whisper/transcriptFile.js";
4950
import { initialModelForLanguage } from "../whisper/transcribe.js";
5051
import { findFFmpeg, findFFprobe, getFFmpegInstallHint } from "../browser/ffmpeg.js";
5152
import { VERSION } from "../version.js";
@@ -938,7 +939,7 @@ export default defineCommand({
938939
failCommand();
939940
}
940941
trackInitTemplate(templateId, { tailwind });
941-
const transcriptFile = resolve(destDir, "transcript.json");
942+
const transcriptFile = resolve(destDir, TRANSCRIPT_FILE);
942943
if (existsSync(transcriptFile)) {
943944
await patchTranscript(destDir, transcriptFile);
944945
}
@@ -1175,7 +1176,7 @@ export default defineCommand({
11751176
trackInitTemplate(templateId, { tailwind });
11761177

11771178
// 4b. Patch captions with transcript if available
1178-
const transcriptFile = resolve(destDir, "transcript.json");
1179+
const transcriptFile = resolve(destDir, TRANSCRIPT_FILE);
11791180
if (existsSync(transcriptFile)) {
11801181
await patchTranscript(destDir, transcriptFile);
11811182
}

0 commit comments

Comments
 (0)