reelforge2 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,291 @@
1
+ # reelforge
2
+
3
+ > CLI for [ReelForge Studio](https://github.com/puke3615/ReelForge) — every REST API exposed as a command, with `--help` available at every level.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm install -g reelforge
9
+ ```
10
+
11
+ Or use directly without install:
12
+
13
+ ```bash
14
+ npx reelforge <command>
15
+ ```
16
+
17
+ After install, two binaries are on your `PATH` — `reelforge` and the short alias `rf`. Both behave identically; the docs use `rf` from here on.
18
+
19
+ ```bash
20
+ rf --version # same as `reelforge --version`
21
+ ```
22
+
23
+ ## Quick start
24
+
25
+ The CLI ships pointing at the hosted instance (`https://reelforge.timor419.com`). Log in once, then call:
26
+
27
+ ```bash
28
+ npm install -g reelforge
29
+ rf login # opens browser; headless? rf login <api_key>
30
+ rf whoami # balance + api_keys
31
+ rf create "为什么我们还没找到外星文明?" # auto-saves to ./<title>-<id>.mp4 in cwd
32
+ ```
33
+
34
+ That's the whole story — no server to run.
35
+
36
+ ### Output behavior
37
+
38
+ | invocation | result |
39
+ |---|---|
40
+ | `rf create "..."` | Saves to `./<sanitized-title>-<task_id_short>.mp4`, prints the path |
41
+ | `rf create "..." -o ./videos/space.mp4` | Saves to that exact path (must include filename, not just a directory) |
42
+ | `rf create "..." --no-download` | Skips local save, prints JSON result with `video_url` |
43
+ | `rf create "..." \| jq .video_url` | When stdout is piped, download is skipped automatically |
44
+
45
+ ### Self-hosting
46
+
47
+ If you want to run your own ReelForge Studio (own RelayX key, your own pricing) clone the upstream repo, `pnpm dev`, then point the CLI at it:
48
+
49
+ ```bash
50
+ rf --server http://localhost:8501 health
51
+ # or persist:
52
+ export REELFORGE_SERVER=http://localhost:8501
53
+ # or via `rf login <key> --server http://localhost:8501`
54
+ ```
55
+
56
+ ## Global options
57
+
58
+ | flag | description |
59
+ |---|---|
60
+ | `-s, --server <url>` | ReelForge server URL (overrides `$REELFORGE_SERVER`; default `https://reelforge.timor419.com`) |
61
+ | `-k, --api-key <key>` | API key (overrides `$REELFORGE_API_KEY` and `reelforge login` saved key) |
62
+ | `--json` | Output raw JSON instead of pretty text — pipe-friendly |
63
+ | `--quiet` | Suppress informational messages on stderr |
64
+ | `-v, --version` | Show CLI version |
65
+ | `-h, --help` | Show help (works on every sub-command) |
66
+
67
+ ## Command map
68
+
69
+ Run `rf <command> --help` for full details on any of these.
70
+
71
+ ### Core capabilities
72
+
73
+ | command | what it does |
74
+ |---|---|
75
+ | `llm chat -p <text>` | Send one prompt to the configured LLM (RelayX gateway by default) |
76
+ | `llm presets` | List built-in RelayX model presets |
77
+ | `tts edge -t <text> -o out.mp3` | Local Edge TTS synthesis (free) |
78
+ | `tts relayx -t <text> -o out.mp3` | RelayX TTS (vox/index-tts-2, 149 built-in voices) |
79
+ | `tts voices [--locale zh]` | List supported Edge TTS voices |
80
+ | `images generate -p <prompt> -m rx-image-flux` | Image generation via RelayX (rx-image-z / rx-image-flux / rx-image-qwen) |
81
+
82
+ ### Content / audio / subtitle atomics
83
+
84
+ | command | what it does |
85
+ |---|---|
86
+ | `content scene-plan -t <topic>` | Single LLM call: title + master script + per-scene image prompts (replaces the old narration / split / image-prompts / title trio) |
87
+ | `content scene-plan --script <text-or-@file>` | Same, but the user supplies the script verbatim — LLM only segments and writes image prompts |
88
+ | `audio transcribe -f <file>` / `--url <url>` | RelayX paraformer-v2 ASR with word + segment timestamps |
89
+ | `subtitles split -t <text-or-@file>` | Deterministic tiered-punctuation subtitle line splitter (pure function, zero billing) |
90
+
91
+ ### Composition
92
+
93
+ | command | what it does |
94
+ |---|---|
95
+ | `templates list [--size 1080x1920] [--type image]` | List HTML frame templates |
96
+ | `templates preview <keyOrPath> [-o out.png]` | Render a preview from a preset key **or your own local .html file** |
97
+ | `templates show <key> [-o file.html]` | Print or save the source HTML of any preset — copy it as a starting point for a custom template |
98
+ | `frames render -t <keyOrPath> --title ... --text ...` | Render a single composed frame to PNG. `-t` accepts a preset key **or a local .html path** |
99
+ | `compositions concat <v1> <v2> -o out.mp4` | FFmpeg concat (+ optional BGM) |
100
+ | `compositions bgm -i video.mp4 --bgm bgm.mp3 -o out.mp4` | Add background music |
101
+ | `compositions image-to-video -i img.png -a aud.mp3 -o out.mp4` | Build video from image + audio |
102
+ | `compositions overlay -v video.mp4 --overlay overlay.png -o out.mp4` | Overlay PNG on video |
103
+
104
+ ### End-to-end pipelines
105
+
106
+ All `pipelines *` commands submit an **async task** and (by default) poll until it finishes with a live progress indicator on stderr. Use `--no-wait` to return immediately with a `task_id`, then `rf tasks wait <id>` later.
107
+
108
+ The standard pipeline is **audio-first**: scene-plan → one-shot TTS → ASR alignment → per-scene image generation → per-subtitle-line frame rendering → ffmpeg mux. One continuous master audio track; image cuts at scene boundaries; subtitle cuts at line boundaries.
109
+
110
+ | command | what it does |
111
+ |---|---|
112
+ | `pipelines standard -t <topic>` (or `--script <text>`) | Audio-first pipeline; `-d/--duration` and `-p/--pace` are the two main knobs |
113
+
114
+ #### Composition knobs
115
+
116
+ Three independent axes — mix and match as you like:
117
+
118
+ | flag | values | default | what changes |
119
+ |---|---|---|---|
120
+ | `--motion` | `off` / `lite` / `max` | `lite` | per-scene zoompan + crossfade intensity |
121
+ | `--layout` | `full` / `blur-bg` / `letterbox` | `full` | how the image sits in the canvas |
122
+ | `--subtitle-style` | `plate` / `stroke` / `cinema` | `plate` | subtitle look |
123
+
124
+ **Layout presets**:
125
+ - `full` — image fills the whole 1080×1920 canvas. Generates a 1080×1920 image. High-impact; best for human portraits, landscapes, 9:16-native content.
126
+ - `blur-bg` — image at 1080×1080 centered, top/bottom is a gaussian-blurred copy of the **same image** moving in sync with the foreground. Generates a 1080×1080 image (cheaper + no wasted pixels). Best for charts, screenshots, non-9:16 source content (小红书 / 抖音 style).
127
+ - `letterbox` — image at 1080×1080 centered, top/bottom is a solid matte (CSS color). Generates a 1080×1080 image. Cinematic / calm. Customize the matte with `--layout-matte-color "#1a1a1a"` (default `black`).
128
+
129
+ Examples:
130
+ ```bash
131
+ rf create "财经日报" --layout blur-bg # 小红书 / 抖音
132
+ rf create "纪录片片段" --layout letterbox --motion max # 电影感
133
+ rf create "..." --layout letterbox --layout-matte-color "#1a1a1a" # 柔和黑
134
+ ```
135
+
136
+ ### Resources
137
+
138
+ | command | what it does |
139
+ |---|---|
140
+ | `bgm list / upload <file> / delete <name>` | Manage background music |
141
+ | `files list / upload <file> / download <path> / delete <path>` | Manage user assets |
142
+
143
+ ### System
144
+
145
+ | command | what it does |
146
+ |---|---|
147
+ | `config get` | Read server config (keys masked) |
148
+ | `config set <key> <value>` | Update a dotted-path setting (e.g. `llm.api_key sk-xxx`) |
149
+ | `config patch <file>` | Apply a JSON-merge patch |
150
+ | `tasks list [--status running]` | List recent tasks |
151
+ | `tasks get <id>` / `tasks wait <id>` / `tasks cancel <id>` | Task lifecycle |
152
+ | `history list / get <id> / delete <id>` | Browse / delete completed runs |
153
+ | `health` | Server health + capability check |
154
+
155
+ ### Heavy brand customization (custom overlay templates)
156
+
157
+ `--motion` / `--layout` / `--subtitle-*` / `--brand-*` cover the common cases. For full visual identity ownership (custom path bar, accent decorations, light theme, footer block, etc.) pass a custom overlay HTML via `--frame-template <local.html | preset_key>`:
158
+
159
+ ```bash
160
+ rf templates show 1080x1920/default.html -o ./my-brand.html
161
+ # ...edit my-brand.html (change colors, add structure, etc.)...
162
+ rf create "我的视频" --frame-template ./my-brand.html
163
+ ```
164
+
165
+ **Contract for custom HTML**:
166
+
167
+ - Canvas is **1080×1920** (pipeline-fixed; don't declare a different size in `<meta>`).
168
+ - Background must be **transparent** — the AI image is composited by ffmpeg OUTSIDE the HTML layer.
169
+ - **`{{image}}` no longer exists.** Using `<img src="{{image}}">` is a hard error at submit time. Image is composited by ffmpeg.
170
+ - The pipeline injects these placeholders for you:
171
+
172
+ | Placeholder | What it is |
173
+ |---|---|
174
+ | `{{title}}` `{{text}}` | per-frame content |
175
+ | `{{index}}` `{{total}}` | "scene N of M" — `{{total}}` is the LLM-decided scene count, don't hardcode |
176
+ | `{{layout}}` | `"full"` / `"blur-bg"` / `"letterbox"` — react via `body[data-layout="..."]` CSS to put title/subtitle in the matte zones when layout ≠ full |
177
+ | `{{subtitle_style}}` `{{subtitle_color}}` `{{subtitle_background}}` | subtitle preset + overrides |
178
+ | `{{brand_position}}` `{{brand_handle}}` `{{brand_slogan}}` `{{brand_logo}}` `{{brand_color}}` | brand-chrome inputs (use or ignore as you like) |
179
+
180
+ Inline HTML is hard-capped at 2 MB. The audio + motion + character-ref + scene-plan stages all keep working identically — only the overlay layer is yours.
181
+
182
+ **Publishing to short-video platforms (Douyin / TikTok / WeChat Channels)** — the default template renders to the full 1080×1920 canvas, but those apps overlay UI on top/bottom/right and cover-crop ~96-180px on each side on taller phones. ReelForge does NOT bake platform-specific padding into the default template. For reference safe-zone numbers + a copy-pasteable CSS diff: `rf templates safezone [douyin|tiktok|wechat]`.
183
+
184
+ ## Examples
185
+
186
+ ```bash
187
+ # 1. One-click out a video (45s default, AI writes the script)
188
+ rf create "为什么我们还没找到外星文明?"
189
+
190
+ # 2. Longer video with a slower visual rhythm
191
+ rf create "深夜便利店的灯光" -d 90 -p slow
192
+
193
+ # 3. Your own script — no narration-splitting on your side, the pipeline handles it
194
+ rf create --script @./my-script.txt
195
+ rf create --script "雨水缓缓滑落在玻璃窗上,像是无声的泪珠。"
196
+
197
+ # 4. Pick a built-in visual style preset
198
+ rf create "美食教程" --style photorealistic
199
+
200
+ # 5. Pipeline form with explicit output path
201
+ rf pipelines standard \
202
+ --script @./script.txt \
203
+ --frame-template 1080x1920/image_default.html \
204
+ -p normal -o smoke.mp4
205
+
206
+ # 6. Inspect existing tasks & redownload a finished video
207
+ rf tasks list --limit 5
208
+ rf history get <task-id> --download recovered.mp4
209
+
210
+ # 7. Atomics for stand-alone use
211
+ rf content scene-plan -t "雨天的玻璃窗" -d 45 --json | jq .scenes
212
+ rf audio transcribe -f narration.mp3 --json | jq '.words[:5]'
213
+ rf subtitles split -t @./narration.txt --min 10 --hard-max 24
214
+
215
+ # 8. JSON pipe for automation
216
+ rf llm presets --json | jq '.[].defaultModel'
217
+
218
+ # 9. Configure & test LLM (self-hosted)
219
+ rf config set llm.api_key rx-xxxxx # RelayX key (or your own provider key)
220
+ rf config set llm.base_url https://relayx.timor419.com/v1
221
+ rf config set llm.model deepseek-v4-flash # bare id; the provider/model form (e.g. openai/gpt-5-nano) often returns 'no permission'
222
+ rf llm chat -p 'one-sentence summary of antifragile'
223
+
224
+ # 10. Use your own HTML template (no PR/release needed)
225
+ # Any --frame-template that points to a local .html file is read and sent
226
+ # inline. Declare size inside the file via
227
+ # <meta name="template:width" content="1080">
228
+ # <meta name="template:height" content="1920">
229
+ # or pass --frame-template-size 1080x1920.
230
+ rf templates show 1080x1920/image_default.html -o my-brand.html # copy a preset
231
+ # ...edit my-brand.html to suit your style...
232
+ rf templates preview ./my-brand.html --title "Hello" -o preview.png
233
+ rf frames render -t ./my-brand.html --values '{"author":"Alice"}' -o frame.png
234
+ rf pipelines standard -t "宠物" --frame-template ./my-brand.html -o final.mp4
235
+ ```
236
+
237
+ ### Custom HTML templates
238
+
239
+ Easiest way to start: grab a preset as a reference.
240
+
241
+ ```bash
242
+ rf templates list # see all keys
243
+ rf templates show 1080x1920/static_default.html # print to stdout
244
+ rf templates show 1080x1920/image_default.html -o my-brand.html # save and edit
245
+ ```
246
+
247
+ `{{title}}`, `{{text}}`, `{{image}}`, `{{index}}`, `{{total}}` are reserved built-ins auto-injected by the pipeline; everything else uses the `{{name:type=default}}` DSL (`type` ∈ `text|number|color|bool`). Pass extras through `--values '{"author":"Alice"}'` (or `template_params` on the pipeline API).
248
+
249
+ - `{{index}}` — current scene number, 1-based
250
+ - `{{total}}` — scene count the LLM actually produced (use this for "scene N of M" badges; don't hardcode in `template_params`, the scene count is decided at runtime)
251
+
252
+ #### Template type — does the pipeline generate an AI image per scene?
253
+
254
+ When you ship an inline template through `rf create` / `rf pipelines standard`, ReelForge needs to know whether each scene should kick off RelayX image generation. Resolution priority (high → low):
255
+
256
+ 1. Explicit flag — `--frame-template-type image|static|asset` (or `frame_template_type` in the API body).
257
+ 2. Inside the HTML — `<meta name="template:type" content="image">` (or `static` / `asset`).
258
+ 3. **Default: `image`** — best practice for zero-config users. If your template doesn't reference scene imagery (pure-text card, etc.), declare `static` explicitly to skip image generation and its cost.
259
+
260
+ The placeholder `{{image}}` no longer doubles as a type signal — declare type explicitly.
261
+
262
+ Limits and safety:
263
+
264
+ - Max 2 MB per inline HTML.
265
+ - The render sandbox blocks `file://`, loopback / private / link-local IPs, CGNAT range, cloud-metadata, and `*.local` / `*.internal` hostnames. So your template can only reference public `https`/`http` resources or `data:` URIs.
266
+ - If the CLI is talking to a hosted server, local-path `--image` won't reach the server; either upload to `rf files upload` first or use an HTTPS URL / data: URI.
267
+
268
+ #### API field reference
269
+
270
+ | endpoint | inline HTML field | size field | type field |
271
+ |---|---|---|---|
272
+ | `POST /api/v1/frames/render` | `template_html` | `size` | — (n/a, no image generation) |
273
+ | `POST /api/v1/templates/preview` | `template_html` | `size` | — |
274
+ | `POST /api/v1/pipelines/standard` | `frame_template_inline` | `frame_template_size` | `frame_template_type` |
275
+
276
+ The pipeline endpoint uses the `frame_template_*` prefix because it already has a `frame_template` field (preset key). The single-frame endpoints use the shorter `template_html` because they don't.
277
+
278
+ ## Tip — getting unstuck
279
+
280
+ Every level has `--help`:
281
+
282
+ ```bash
283
+ rf --help # top-level overview
284
+ rf pipelines --help # list of pipelines
285
+ rf pipelines standard --help # full option reference
286
+ rf tts edge --help # one specific command
287
+ ```
288
+
289
+ ## License
290
+
291
+ Apache-2.0
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env node
2
+ // Thin shim so `reelforge2` (alias `rf2`) is invokable globally. The actual
3
+ // implementation is bundled to dist/ by `npm run build`.
4
+ import("../dist/index.js").catch((err) => {
5
+ // eslint-disable-next-line no-console
6
+ console.error(err?.stack || err);
7
+ process.exit(1);
8
+ });
package/dist/client.js ADDED
@@ -0,0 +1,130 @@
1
+ /**
2
+ * HTTP client for the ReelForge Studio REST API.
3
+ *
4
+ * Resolution:
5
+ * server = --server flag > $REELFORGE_SERVER > ~/.reelforge2/config.json > https://reelforge.timor419.com
6
+ * api_key = setApiKey() (from --api-key flag) > $REELFORGE_API_KEY > ~/.reelforge2/config.json > none
7
+ *
8
+ * Auth: if an api_key is resolved, requests automatically get
9
+ * `Authorization: Bearer <api_key>` (unless the caller pre-sets one).
10
+ */
11
+ import { readFileSync } from "node:fs";
12
+ import path from "node:path";
13
+ import os from "node:os";
14
+ const DEFAULT_SERVER = "https://reelforge2.timor419.com";
15
+ function loadConfigSync() {
16
+ try {
17
+ const p = path.join(os.homedir(), ".reelforge2", "config.json");
18
+ const raw = readFileSync(p, "utf-8");
19
+ const parsed = JSON.parse(raw);
20
+ return typeof parsed === "object" && parsed ? parsed : {};
21
+ }
22
+ catch {
23
+ return {};
24
+ }
25
+ }
26
+ const fileConfig = loadConfigSync();
27
+ let overrideServer = null;
28
+ let overrideApiKey = null;
29
+ export function setServer(url) {
30
+ overrideServer = url.replace(/\/$/, "");
31
+ }
32
+ export function getServer() {
33
+ if (overrideServer)
34
+ return overrideServer;
35
+ const env = process.env.REELFORGE_SERVER;
36
+ if (env)
37
+ return env.replace(/\/$/, "");
38
+ if (fileConfig.server)
39
+ return fileConfig.server.replace(/\/$/, "");
40
+ return DEFAULT_SERVER;
41
+ }
42
+ export function setApiKey(key) {
43
+ overrideApiKey = key;
44
+ }
45
+ export function getApiKey() {
46
+ if (overrideApiKey)
47
+ return overrideApiKey;
48
+ if (process.env.REELFORGE_API_KEY)
49
+ return process.env.REELFORGE_API_KEY;
50
+ if (fileConfig.api_key)
51
+ return fileConfig.api_key;
52
+ return null;
53
+ }
54
+ export class ApiCallError extends Error {
55
+ status;
56
+ code;
57
+ details;
58
+ constructor(err) {
59
+ super(err.message);
60
+ this.status = err.status;
61
+ this.code = err.code;
62
+ this.details = err.details;
63
+ }
64
+ }
65
+ async function request(path, init = {}) {
66
+ const url = `${getServer()}${path.startsWith("/") ? path : `/${path}`}`;
67
+ const headers = new Headers(init.headers);
68
+ const key = getApiKey();
69
+ if (key && !headers.has("Authorization") && !headers.has("authorization")) {
70
+ headers.set("Authorization", `Bearer ${key}`);
71
+ }
72
+ let res;
73
+ try {
74
+ res = await fetch(url, { ...init, headers });
75
+ }
76
+ catch (err) {
77
+ const msg = err instanceof Error ? err.message : String(err);
78
+ throw new ApiCallError({
79
+ status: 0,
80
+ message: `Network error contacting ${url}: ${msg}`,
81
+ });
82
+ }
83
+ const text = await res.text();
84
+ let json = null;
85
+ try {
86
+ json = text ? JSON.parse(text) : null;
87
+ }
88
+ catch {
89
+ if (!res.ok) {
90
+ throw new ApiCallError({ status: res.status, message: text.slice(0, 500) });
91
+ }
92
+ return text;
93
+ }
94
+ if (!res.ok) {
95
+ const err = json?.error;
96
+ throw new ApiCallError({
97
+ status: res.status,
98
+ code: err?.code,
99
+ message: err?.message || `HTTP ${res.status}`,
100
+ details: err?.details,
101
+ });
102
+ }
103
+ return json;
104
+ }
105
+ export function get(path) {
106
+ return request(path);
107
+ }
108
+ export function post(path, body) {
109
+ return request(path, {
110
+ method: "POST",
111
+ headers: { "Content-Type": "application/json" },
112
+ body: JSON.stringify(body),
113
+ });
114
+ }
115
+ export function patch(path, body) {
116
+ return request(path, {
117
+ method: "PATCH",
118
+ headers: { "Content-Type": "application/json" },
119
+ body: JSON.stringify(body),
120
+ });
121
+ }
122
+ export function del(path) {
123
+ return request(path, { method: "DELETE" });
124
+ }
125
+ export async function uploadMultipart(path, fields) {
126
+ const form = new FormData();
127
+ for (const [k, v] of Object.entries(fields))
128
+ form.append(k, v);
129
+ return request(path, { method: "POST", body: form });
130
+ }
@@ -0,0 +1,73 @@
1
+ import fs from "node:fs/promises";
2
+ import path from "node:path";
3
+ import { uploadMultipart, post } from "../client.js";
4
+ import { print } from "../utils/output.js";
5
+ export function registerAudio(program) {
6
+ const audio = program
7
+ .command("audio")
8
+ .description("Audio atomics — transcription / forced alignment")
9
+ .helpOption("-h, --help", "show help");
10
+ audio
11
+ .command("transcribe")
12
+ .description("Transcribe an audio file to text + word-level timestamps (RelayX paraformer-v2)")
13
+ .helpOption("-h, --help", "show help")
14
+ .option("-f, --file <path>", "local audio file (mp3/wav/m4a). Use this OR --url.")
15
+ .option("-u, --url <url>", "remote audio URL — server downloads and transcribes.")
16
+ .option("-l, --language <code>", "language hint (e.g. zh, en). Optional — paraformer-v2 auto-detects.")
17
+ .option("-m, --model <id>", "override ASR model id (default alibaba/paraformer-v2)")
18
+ .option("-o, --output <file>", "write the full JSON response to this file as well as stdout")
19
+ .addHelpText("after", [
20
+ "",
21
+ "Examples:",
22
+ " rf audio transcribe -f ./narration.mp3",
23
+ " rf audio transcribe --url https://example.com/clip.mp3 --language zh",
24
+ " rf audio transcribe -f ./voice.wav --json | jq '.words[:5]'",
25
+ ].join("\n"))
26
+ .action(async (opts) => {
27
+ if (!opts.file && !opts.url) {
28
+ throw new Error("either --file or --url is required");
29
+ }
30
+ if (opts.file && opts.url) {
31
+ throw new Error("--file and --url are mutually exclusive");
32
+ }
33
+ let r;
34
+ if (opts.file) {
35
+ const buf = await fs.readFile(opts.file);
36
+ const filename = path.basename(opts.file);
37
+ const ext = path.extname(filename).toLowerCase();
38
+ const mime = ext === ".wav" ? "audio/wav" :
39
+ ext === ".m4a" ? "audio/mp4" :
40
+ ext === ".flac" ? "audio/flac" :
41
+ ext === ".ogg" ? "audio/ogg" :
42
+ "audio/mpeg";
43
+ const fileBlob = new File([new Uint8Array(buf)], filename, { type: mime });
44
+ const fields = { file: fileBlob };
45
+ if (opts.language)
46
+ fields.language = opts.language;
47
+ if (opts.model)
48
+ fields.model = opts.model;
49
+ r = await uploadMultipart("/api/v1/audio/transcribe", fields);
50
+ }
51
+ else {
52
+ const body = { audio_url: opts.url };
53
+ if (opts.language)
54
+ body.language = opts.language;
55
+ if (opts.model)
56
+ body.model = opts.model;
57
+ r = await post("/api/v1/audio/transcribe", body);
58
+ }
59
+ if (opts.output) {
60
+ await fs.writeFile(opts.output, JSON.stringify(r, null, 2), "utf-8");
61
+ }
62
+ print({
63
+ model: r.model,
64
+ language: r.language,
65
+ duration: r.duration,
66
+ text: r.text,
67
+ n_segments: r.segments.length,
68
+ n_words: r.words.length,
69
+ segments: r.segments,
70
+ words: r.words,
71
+ });
72
+ });
73
+ }