(inputPath: string, dir: string, json: boolean)
| 151 | } |
| 152 | |
| 153 | async function importTranscript(inputPath: string, dir: string, json: boolean): Promise<void> { |
| 154 | const { loadTranscript, patchCaptionHtml } = await import("../whisper/normalize.js"); |
| 155 | const { words, format } = loadTranscript(inputPath); |
| 156 | |
| 157 | if (words.length === 0) exitNoWords(json); |
| 158 | |
| 159 | const outPath = join(dir, "transcript.json"); |
| 160 | writeFileSync(outPath, JSON.stringify(words, null, 2)); |
| 161 | patchCaptionHtml(dir, words); |
| 162 | |
| 163 | if (json) { |
| 164 | console.log( |
| 165 | JSON.stringify({ ok: true, format, wordCount: words.length, transcriptPath: outPath }), |
| 166 | ); |
| 167 | } else { |
| 168 | console.log( |
| 169 | `${c.success("◇")} Imported ${c.accent(String(words.length))} words from ${c.accent(format)} format → ${c.accent("transcript.json")}`, |
| 170 | ); |
| 171 | } |
| 172 | } |
| 173 | |
| 174 | // --------------------------------------------------------------------------- |
| 175 | // Export transcript sidecars |
no test coverage detected