({ args })
| 79 | }, |
| 80 | }, |
| 81 | async run({ args }) { |
| 82 | const inputPath = resolve(args.input); |
| 83 | if (!existsSync(inputPath)) { |
| 84 | const message = `File not found: ${args.input}`; |
| 85 | trackCommandFailure("transcribe", message); |
| 86 | console.error(c.error(message)); |
| 87 | process.exit(1); |
| 88 | } |
| 89 | |
| 90 | // Default to the directory containing the input file so transcript.json |
| 91 | // lands next to narration.wav regardless of where the command is run from. |
| 92 | // Explicit --dir overrides this (e.g. for import mode targeting a project dir). |
| 93 | const dir = resolve(args.dir ?? dirname(inputPath)); |
| 94 | const ext = extname(inputPath).toLowerCase(); |
| 95 | |
| 96 | // ── Import mode: convert existing transcript ────────────────────────── |
| 97 | const isImport = ext === ".json" || ext === ".srt" || ext === ".vtt"; |
| 98 | const to = parseExportFormat(args.to, args.json); |
| 99 | |
| 100 | if (to) { |
| 101 | if (!isImport) { |
| 102 | failWith( |
| 103 | "--to can only export from transcript files (.json, .srt, .vtt). Run transcribe first.", |
| 104 | args.json, |
| 105 | ); |
| 106 | } |
| 107 | return exportTranscript(inputPath, dir, to, args.output, args.json, args["preserve-cues"]); |
| 108 | } |
| 109 | |
| 110 | if (isImport) { |
| 111 | return importTranscript(inputPath, dir, args.json); |
| 112 | } |
| 113 | |
| 114 | // ── Transcribe mode: run whisper ───────────────────────────────────── |
| 115 | return transcribeAudio(inputPath, dir, { |
| 116 | model: args.model, |
| 117 | language: args.language, |
| 118 | json: args.json, |
| 119 | optional: args.optional, |
| 120 | }); |
| 121 | }, |
| 122 | }); |
| 123 | |
| 124 | function failWith(message: string, json: boolean): never { |
nothing calls this directly
no test coverage detected