transcribe-cpp 0.3.1 → 0.4.1

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 CHANGED
@@ -12,6 +12,13 @@ A matching prebuilt native package is selected automatically for your
12
12
  platform (`@transcribe-cpp/<platform>`); there is nothing to compile and no
13
13
  environment variables to set.
14
14
 
15
+ On Windows, the prebuilt libraries are built with the Visual C++ 2022
16
+ toolset and require the
17
+ [Microsoft Visual C++ 2015–2022 Redistributable (x64)](https://aka.ms/vs/17/release/vc_redist.x64.exe)
18
+ version 14.40 or newer. Older runtimes (for example the 2021-era 14.29
19
+ redistributable) crash with a native access violation inside `std::mutex`
20
+ during backend initialization.
21
+
15
22
  Upgrading from 0.1? See the
16
23
  [0.2 migration guide](https://github.com/handy-computer/transcribe.cpp/blob/main/docs/migrating-to-0.2.md),
17
24
  including the replacement of `gpuDevice` with exact device objects.
@@ -109,10 +116,73 @@ const stream = await session.stream({ family: { kind: "moonshine" } });
109
116
  model.accepts({ kind: "whisper" }); // does this model take that extension?
110
117
  ```
111
118
 
119
+ ### Diarization (DIARIZE role)
120
+
121
+ `model.roles` lists what a model serves (`"asr"`, `"diarize"`, `"langid"`,
122
+ `"vad"`; Sortformer is diarize-only). Calls for a role the model lacks throw
123
+ `UnsupportedRole`.
124
+
125
+ ```ts
126
+ const { sampleRate, maxSpeakers } = model.diarizeInfo;
127
+ using diarizer = model.createDiarizeSession();
128
+ const turns = await diarizer.run(pcm, {
129
+ family: { kind: "sortformer_diarize", preset: "very_high_latency" },
130
+ });
131
+ for (const t of turns) console.log(t.speakerId, t.t0Ms, t.t1Ms);
132
+ ```
133
+
134
+ `run` accepts a `signal`; cancelling throws `Aborted` (with no partial result).
135
+ `diarizer.timings` reports the last run. Diarize runs wait on the same
136
+ model-wide lock as other compute calls (see below).
137
+
138
+ ### Language ID (LANGID role)
139
+
140
+ A `"langid"` model (VoxLingua107 ECAPA-TDNN) ranks its own label codes; match
141
+ `result.code` against an ASR model's `capabilities.languages` yourself.
142
+ Every allowed label is returned, ranked by `p`. Omitting `allowed` scores every
143
+ label, `[]` throws `InvalidArgument`, clips under `model.langidInfo.minAudioMs`
144
+ throw `InputTooShort`, and input longer than `maxAudioMs` is scored on its first `maxAudioMs`.
145
+
146
+ ```ts
147
+ using lid = model.createLangIdSession();
148
+ const result = await lid.run(pcm, { allowed: ["en", "de", "fr"] });
149
+ console.log(result.code, result.candidates[0].p, result.allowedMass);
150
+ ```
151
+
152
+ ### Voice activity detection (VAD role)
153
+
154
+ A `"vad"` model (Silero VAD) scores `model.vadInfo.frameSamples`-sample frames
155
+ (512 = 32 ms at 16 kHz) with a speech probability. `run` scores a whole clip
156
+ and segments it with Silero's `get_speech_timestamps` rules (options such as
157
+ `threshold`, `minSilenceMs` and `maxSpeechMs`; samples are 16 kHz indices):
158
+
159
+ ```ts
160
+ using vad = model.createVadSession();
161
+ const { segments, probs } = await vad.run(pcm, { threshold: 0.5 });
162
+ for (const s of segments) console.log(s.startSample, s.endSample);
163
+ ```
164
+
165
+ For live audio, `streamFeed(chunk)` returns the probabilities of the frames
166
+ each chunk completes (`firstFrame` is the index of `probs[0]`), `streamFlush()`
167
+ scores the zero-padded remainder and ends the stream, and `streamReset()` drops
168
+ it. The next feed after either starts at frame 0, as does the next feed after an
169
+ abort or processing error.
170
+
171
+ ```ts
172
+ for await (const chunk of mic) {
173
+ const { firstFrame, probs } = await vad.streamFeed(chunk);
174
+ probs.forEach((p, i) => console.log(firstFrame + i, p));
175
+ }
176
+ const tail = await vad.streamFlush();
177
+ ```
178
+
179
+ A VAD stream is session state, not a stream lease: VAD calls raise `Busy` only
180
+ while an ASR stream on the same model holds the lease.
181
+
112
182
  ### Resource management
113
183
 
114
- `TranscribeModel`, `Session`, and `Stream` all implement `Symbol.dispose`, so
115
- `using` works (TypeScript 5.2+ / Node 22+):
184
+ `TranscribeModel`, `Session`, `DiarizeSession`, `LangIdSession`, `VadSession`, and `Stream` all implement
185
+ `Symbol.dispose`, so `using` works (TypeScript 5.2+ / Node 22+):
116
186
 
117
187
  ```ts
118
188
  using model = await TranscribeModel.load("model.gguf");
@@ -123,13 +193,26 @@ using session = model.createSession();
123
193
  Disposing a model disposes its sessions; disposing a stream resets it (releasing
124
194
  the model lease). Disposal is idempotent and order-independent.
125
195
 
196
+ ## Startup and UI responsiveness
197
+
198
+ Initializing compute backends can take seconds (on Metal it compiles the GPU
199
+ shader library). `TranscribeModel.load()` does this on a worker thread, so the
200
+ event loop keeps running. To pay the cost up front, call `await initialize()`
201
+ at startup; `backendState()` reports its progress.
202
+
203
+ Use `getAvailableBackendsAsync()` / `backendAvailableAsync()` in UI processes.
204
+ The sync variants initialize backends on the calling thread if needed, and
205
+ throw `BackendInitializing` while `initialize()` is running. A failed backend
206
+ initialization is permanent for the process; later calls rethrow its
207
+ `BackendError`.
208
+
126
209
  ## Backend selection
127
210
 
128
211
  ```ts
129
- import { getAvailableBackends, backendAvailable } from "transcribe-cpp";
212
+ import { getAvailableBackendsAsync, backendAvailableAsync } from "transcribe-cpp";
130
213
 
131
- const devices = getAvailableBackends();
132
- backendAvailable("rocm"); // boolean — never throws
214
+ const devices = await getAvailableBackendsAsync();
215
+ await backendAvailableAsync("rocm"); // boolean
133
216
 
134
217
  // Policy selection: first matching ROCm device.
135
218
  const automatic = await TranscribeModel.load("model.gguf", { backend: "rocm" });
@@ -143,6 +226,13 @@ const exact = await TranscribeModel.load("model.gguf", { device: cpu });
143
226
  loader/driver degrades silently to CPU; an explicit backend that cannot be
144
227
  satisfied raises a `BackendError`.
145
228
 
229
+ Where the device can use host memory (CPU, Metal on Apple silicon), weights are
230
+ memory-mapped from the model file and served from the page cache, which the OS
231
+ can reclaim, instead of being copied into process memory. Don't truncate or
232
+ rewrite a model file in place while it is loaded; write a new file and rename
233
+ it over the old one. `{ noMmap: true }` (or `TRANSCRIBE_NO_MMAP=1`) copies the
234
+ weights instead.
235
+
146
236
  ## Thread-safety
147
237
 
148
238
  Your JavaScript runs on one thread, but `run`/`feed`/`finalize` dispatch the
@@ -150,14 +240,14 @@ native compute to a **libuv worker thread** (via koffi's async calls), so the
150
240
  event loop stays responsive while inference runs.
151
241
 
152
242
  The C library allows **one compute in flight per model** — a `run`, a `runBatch`,
153
- or an *active stream* — across all of its sessions. The binding enforces this:
154
- every compute call serializes through an internal model-wide mutex, and an active
155
- stream holds a model-wide lease for its whole lifetime. While a stream is active
156
- (after `stream()`, before `finalize()`/`reset()`), a `run`/`runBatch`/`stream` on
157
- any session of that model is refused with a `Busy` error rather than allowed to
158
- race. So to parallelize, load one model per worker; to share a model, finalize or
159
- reset the stream first. A single `Session` is single-use-at-a-time — don't call
160
- `run`/`feed` on the same session concurrently.
243
+ a diarize `run`, or an *active stream* — across all of its sessions. The binding
244
+ enforces this: every compute call serializes through an internal model-wide
245
+ mutex, and an active stream holds a model-wide lease for its whole lifetime.
246
+ While a stream is active (after `stream()`, before `finalize()`/`reset()`), a
247
+ `run`/`runBatch`/`stream` on any session of that model is refused with a `Busy`
248
+ error rather than allowed to race. So to parallelize, load one model per worker;
249
+ to share a model, finalize or reset the stream first. A single `Session` is
250
+ single-use-at-a-time — don't call `run`/`feed` on the same session concurrently.
161
251
 
162
252
  Hand-offs are ordered, not racy: `finalize()`/`reset()`/`dispose()` release the
163
253
  lease only after the native teardown runs on the shared queue, so the slot is
@@ -166,20 +256,24 @@ is correctly serialized — `stream.reset(); const next = await session.stream()
166
256
  works without awaiting the (void) `reset()`. The reverse order — beginning before
167
257
  the teardown — is refused with `Busy`, by design.
168
258
 
259
+ A `feed()` rejected up front (e.g. NaN samples) leaves the stream `"active"` and
260
+ the lease held; a failure inside the model makes it `"failed"` and frees the lease.
261
+
169
262
  Because the compute is genuinely on another thread, **do not touch a session
170
263
  while a call against it is in flight** — it is single-threaded in the C library:
171
264
 
172
- - Reading a stream's `text`/`snapshot`/`state`/`revision`/`lastStatus`, or a
173
- session's `limits`/`wasAborted`, during an un-awaited
174
- `feed`/`finalize`/`run`/`runBatch` **throws**.
265
+ - Reading a stream's `text`/`snapshot`/`state`/`revision`/`lastStatus`, a
266
+ session's `limits`/`wasAborted`, or a `DiarizeSession`'s `timings`, during an
267
+ un-awaited `feed`/`finalize`/`run`/`runBatch` **throws**.
175
268
  - `reset()` and `dispose()` are safe to call any time: the native teardown is
176
269
  deferred behind any in-flight call, so it never frees a session mid-compute.
177
270
  - Disposing a `Session` or `TranscribeModel` while a stream is still active
178
271
  releases the lease and invalidates the stream — its later calls throw rather
179
272
  than touch the freed handle.
180
- - The **input PCM is borrowed, not copied**: `run`/`runBatch`/`feed` hand the
181
- buffer to native code that reads it on the worker thread, so do not mutate it
182
- (e.g. reuse a scratch/capture buffer) until the returned promise resolves.
273
+ - The **input PCM is borrowed, not copied**: `run`/`runBatch`/`feed` (and
274
+ `DiarizeSession.run`) hand the buffer to native code that reads it on the
275
+ worker thread, so do not mutate it (e.g. reuse a scratch/capture buffer)
276
+ until the returned promise resolves.
183
277
  Pass a fresh buffer per call, or `await` before overwriting.
184
278
 
185
279
  The normal pattern is safe — `await` first, then read:
@@ -284,4 +378,4 @@ to your `build.rs` as `DEP_TRANSCRIBE_CPP_RUNTIME_DIR`.
284
378
  ## License
285
379
 
286
380
  MIT. Bundled native packages include third-party license texts (ggml, miniz,
287
- and any bundled backend runtimes).
381
+ Silero VAD, and any bundled backend runtimes).
@@ -1,4 +1,4 @@
1
- export declare const PUBLIC_HEADER_HASH = "57b1af43650f195d";
1
+ export declare const PUBLIC_HEADER_HASH = "f99ad4169374b8f3";
2
2
  export declare const TRANSCRIBE_OK = 0;
3
3
  export declare const TRANSCRIBE_ERR_INVALID_ARG = 1;
4
4
  export declare const TRANSCRIBE_ERR_NOT_IMPLEMENTED = 2;
@@ -19,6 +19,8 @@ export declare const TRANSCRIBE_ERR_UNSUPPORTED_ITN = 16;
19
19
  export declare const TRANSCRIBE_ERR_INPUT_TOO_LONG = 17;
20
20
  export declare const TRANSCRIBE_ERR_OUTPUT_TRUNCATED = 18;
21
21
  export declare const TRANSCRIBE_ERR_OUTPUT_REPETITION = 19;
22
+ export declare const TRANSCRIBE_ERR_UNSUPPORTED_ROLE = 20;
23
+ export declare const TRANSCRIBE_ERR_INPUT_TOO_SHORT = 21;
22
24
  export declare const TRANSCRIBE_ABI_MODEL_LOAD_PARAMS = 0;
23
25
  export declare const TRANSCRIBE_ABI_SESSION_PARAMS = 1;
24
26
  export declare const TRANSCRIBE_ABI_RUN_PARAMS = 2;
@@ -35,6 +37,19 @@ export declare const TRANSCRIBE_ABI_EXT = 12;
35
37
  export declare const TRANSCRIBE_ABI_DEVICE_INFO = 13;
36
38
  export declare const TRANSCRIBE_ABI_SPEAKER_SEGMENT = 14;
37
39
  export declare const TRANSCRIBE_ABI_BACKEND_INIT_PARAMS = 15;
40
+ export declare const TRANSCRIBE_ABI_DIARIZE_INFO = 16;
41
+ export declare const TRANSCRIBE_ABI_DIARIZE_SESSION_PARAMS = 17;
42
+ export declare const TRANSCRIBE_ABI_DIARIZE_PARAMS = 18;
43
+ export declare const TRANSCRIBE_ABI_LANGID_INFO = 19;
44
+ export declare const TRANSCRIBE_ABI_LANGID_SESSION_PARAMS = 20;
45
+ export declare const TRANSCRIBE_ABI_LANGID_PARAMS = 21;
46
+ export declare const TRANSCRIBE_ABI_LANGID_RESULT = 22;
47
+ export declare const TRANSCRIBE_ABI_LANGID_CANDIDATE = 23;
48
+ export declare const TRANSCRIBE_ABI_VAD_INFO = 24;
49
+ export declare const TRANSCRIBE_ABI_VAD_SESSION_PARAMS = 25;
50
+ export declare const TRANSCRIBE_ABI_VAD_PARAMS = 26;
51
+ export declare const TRANSCRIBE_ABI_VAD_RESULT = 27;
52
+ export declare const TRANSCRIBE_ABI_VAD_SEGMENT = 28;
38
53
  export declare const TRANSCRIBE_LOG_LEVEL_NONE = 0;
39
54
  export declare const TRANSCRIBE_LOG_LEVEL_INFO = 1;
40
55
  export declare const TRANSCRIBE_LOG_LEVEL_WARN = 2;
@@ -63,6 +78,7 @@ export declare const TRANSCRIBE_DIARIZE_MODE_OFF = 1;
63
78
  export declare const TRANSCRIBE_DIARIZE_MODE_ON = 2;
64
79
  export declare const TRANSCRIBE_EXT_SLOT_RUN = 0;
65
80
  export declare const TRANSCRIBE_EXT_SLOT_STREAM = 1;
81
+ export declare const TRANSCRIBE_EXT_SLOT_DIARIZE_RUN = 2;
66
82
  export declare const TRANSCRIBE_BACKEND_AUTO = 0;
67
83
  export declare const TRANSCRIBE_BACKEND_CPU = 1;
68
84
  export declare const TRANSCRIBE_BACKEND_METAL = 2;
@@ -74,6 +90,10 @@ export declare const TRANSCRIBE_DEVICE_TYPE_CPU = 0;
74
90
  export declare const TRANSCRIBE_DEVICE_TYPE_GPU = 1;
75
91
  export declare const TRANSCRIBE_DEVICE_TYPE_IGPU = 2;
76
92
  export declare const TRANSCRIBE_DEVICE_TYPE_ACCEL = 3;
93
+ export declare const TRANSCRIBE_ROLE_ASR = 1;
94
+ export declare const TRANSCRIBE_ROLE_DIARIZE = 2;
95
+ export declare const TRANSCRIBE_ROLE_LANGID = 4;
96
+ export declare const TRANSCRIBE_ROLE_VAD = 8;
77
97
  export declare const TRANSCRIBE_FEATURE_INITIAL_PROMPT = 0;
78
98
  export declare const TRANSCRIBE_FEATURE_TEMPERATURE_FALLBACK = 1;
79
99
  export declare const TRANSCRIBE_FEATURE_LONG_FORM = 2;
@@ -108,7 +128,7 @@ export declare const TRANSCRIBE_BACKEND_MASK_VULKAN = 4;
108
128
  export declare const TRANSCRIBE_EXT_KIND_MOONSHINE_STREAMING_STREAM = 1414746957;
109
129
  export declare const TRANSCRIBE_EXT_KIND_PARAKEET_BUFFERED_STREAM = 1396853584;
110
130
  export declare const TRANSCRIBE_EXT_KIND_PARAKEET_STREAM = 1414744912;
111
- export declare const TRANSCRIBE_EXT_KIND_SORTFORMER_STREAM = 1414743635;
131
+ export declare const TRANSCRIBE_EXT_KIND_SORTFORMER_DIARIZE = 1380206163;
112
132
  export declare const TRANSCRIBE_EXT_KIND_VOXTRAL_REALTIME_STREAM = 1414746710;
113
133
  export declare const TRANSCRIBE_EXT_KIND_WHISPER_RUN = 1314015319;
114
134
  export interface StructLayout {
@@ -10,7 +10,7 @@
10
10
  // Stable digest of the ABI surface (structs, enums, macros, layout,
11
11
  // prototypes), computed by the Python oracle and pinned here so a header
12
12
  // ABI change turns this binding's drift check red for conscious review.
13
- export const PUBLIC_HEADER_HASH = "57b1af43650f195d";
13
+ export const PUBLIC_HEADER_HASH = "f99ad4169374b8f3";
14
14
  // === enum constants ===
15
15
  export const TRANSCRIBE_OK = 0;
16
16
  export const TRANSCRIBE_ERR_INVALID_ARG = 1;
@@ -32,6 +32,8 @@ export const TRANSCRIBE_ERR_UNSUPPORTED_ITN = 16;
32
32
  export const TRANSCRIBE_ERR_INPUT_TOO_LONG = 17;
33
33
  export const TRANSCRIBE_ERR_OUTPUT_TRUNCATED = 18;
34
34
  export const TRANSCRIBE_ERR_OUTPUT_REPETITION = 19;
35
+ export const TRANSCRIBE_ERR_UNSUPPORTED_ROLE = 20;
36
+ export const TRANSCRIBE_ERR_INPUT_TOO_SHORT = 21;
35
37
  export const TRANSCRIBE_ABI_MODEL_LOAD_PARAMS = 0;
36
38
  export const TRANSCRIBE_ABI_SESSION_PARAMS = 1;
37
39
  export const TRANSCRIBE_ABI_RUN_PARAMS = 2;
@@ -48,6 +50,19 @@ export const TRANSCRIBE_ABI_EXT = 12;
48
50
  export const TRANSCRIBE_ABI_DEVICE_INFO = 13;
49
51
  export const TRANSCRIBE_ABI_SPEAKER_SEGMENT = 14;
50
52
  export const TRANSCRIBE_ABI_BACKEND_INIT_PARAMS = 15;
53
+ export const TRANSCRIBE_ABI_DIARIZE_INFO = 16;
54
+ export const TRANSCRIBE_ABI_DIARIZE_SESSION_PARAMS = 17;
55
+ export const TRANSCRIBE_ABI_DIARIZE_PARAMS = 18;
56
+ export const TRANSCRIBE_ABI_LANGID_INFO = 19;
57
+ export const TRANSCRIBE_ABI_LANGID_SESSION_PARAMS = 20;
58
+ export const TRANSCRIBE_ABI_LANGID_PARAMS = 21;
59
+ export const TRANSCRIBE_ABI_LANGID_RESULT = 22;
60
+ export const TRANSCRIBE_ABI_LANGID_CANDIDATE = 23;
61
+ export const TRANSCRIBE_ABI_VAD_INFO = 24;
62
+ export const TRANSCRIBE_ABI_VAD_SESSION_PARAMS = 25;
63
+ export const TRANSCRIBE_ABI_VAD_PARAMS = 26;
64
+ export const TRANSCRIBE_ABI_VAD_RESULT = 27;
65
+ export const TRANSCRIBE_ABI_VAD_SEGMENT = 28;
51
66
  export const TRANSCRIBE_LOG_LEVEL_NONE = 0;
52
67
  export const TRANSCRIBE_LOG_LEVEL_INFO = 1;
53
68
  export const TRANSCRIBE_LOG_LEVEL_WARN = 2;
@@ -76,6 +91,7 @@ export const TRANSCRIBE_DIARIZE_MODE_OFF = 1;
76
91
  export const TRANSCRIBE_DIARIZE_MODE_ON = 2;
77
92
  export const TRANSCRIBE_EXT_SLOT_RUN = 0;
78
93
  export const TRANSCRIBE_EXT_SLOT_STREAM = 1;
94
+ export const TRANSCRIBE_EXT_SLOT_DIARIZE_RUN = 2;
79
95
  export const TRANSCRIBE_BACKEND_AUTO = 0;
80
96
  export const TRANSCRIBE_BACKEND_CPU = 1;
81
97
  export const TRANSCRIBE_BACKEND_METAL = 2;
@@ -87,6 +103,10 @@ export const TRANSCRIBE_DEVICE_TYPE_CPU = 0;
87
103
  export const TRANSCRIBE_DEVICE_TYPE_GPU = 1;
88
104
  export const TRANSCRIBE_DEVICE_TYPE_IGPU = 2;
89
105
  export const TRANSCRIBE_DEVICE_TYPE_ACCEL = 3;
106
+ export const TRANSCRIBE_ROLE_ASR = 1;
107
+ export const TRANSCRIBE_ROLE_DIARIZE = 2;
108
+ export const TRANSCRIBE_ROLE_LANGID = 4;
109
+ export const TRANSCRIBE_ROLE_VAD = 8;
90
110
  export const TRANSCRIBE_FEATURE_INITIAL_PROMPT = 0;
91
111
  export const TRANSCRIBE_FEATURE_TEMPERATURE_FALLBACK = 1;
92
112
  export const TRANSCRIBE_FEATURE_LONG_FORM = 2;
@@ -122,14 +142,14 @@ export const TRANSCRIBE_BACKEND_MASK_VULKAN = 4;
122
142
  export const TRANSCRIBE_EXT_KIND_MOONSHINE_STREAMING_STREAM = 1414746957;
123
143
  export const TRANSCRIBE_EXT_KIND_PARAKEET_BUFFERED_STREAM = 1396853584;
124
144
  export const TRANSCRIBE_EXT_KIND_PARAKEET_STREAM = 1414744912;
125
- export const TRANSCRIBE_EXT_KIND_SORTFORMER_STREAM = 1414743635;
145
+ export const TRANSCRIBE_EXT_KIND_SORTFORMER_DIARIZE = 1380206163;
126
146
  export const TRANSCRIBE_EXT_KIND_VOXTRAL_REALTIME_STREAM = 1414746710;
127
147
  export const TRANSCRIBE_EXT_KIND_WHISPER_RUN = 1314015319;
128
148
  export const STRUCT_LAYOUT = {
129
149
  'transcribe_ext': { size: 16, align: 8, offsets: { 'size': 0, 'kind': 8 } },
130
150
  'transcribe_backend_init_params': { size: 24, align: 8, offsets: { 'struct_size': 0, 'artifact_dir': 8, 'allowed_backends': 16 } },
131
151
  'transcribe_device_info': { size: 64, align: 8, offsets: { 'struct_size': 0, 'name': 8, 'description': 16, 'kind': 24, 'device_id': 32, 'memory_total': 40, 'memory_free': 48, 'device_type': 56 } },
132
- 'transcribe_model_load_params': { size: 24, align: 8, offsets: { 'struct_size': 0, 'backend': 8, 'device': 16 } },
152
+ 'transcribe_model_load_params': { size: 32, align: 8, offsets: { 'struct_size': 0, 'backend': 8, 'device': 16, 'no_mmap': 24 } },
133
153
  'transcribe_session_params': { size: 24, align: 8, offsets: { 'struct_size': 0, 'n_threads': 8, 'kv_type': 12, 'n_ctx': 16 } },
134
154
  'transcribe_run_params': { size: 104, align: 8, offsets: { 'struct_size': 0, 'task': 8, 'timestamps': 12, 'pnc': 16, 'itn': 20, 'diarize': 24, 'language': 32, 'target_language': 40, 'keep_special_tags': 48, 'family': 56, 'spec_k_drafts': 64, 'vocabulary': 72, 'n_vocabulary': 80, 'prompt': 88, 'prefix': 96 } },
135
155
  'transcribe_capabilities': { size: 56, align: 8, offsets: { 'struct_size': 0, 'native_sample_rate': 8, 'n_languages': 12, 'languages': 16, 'max_timestamp_kind': 24, 'supports_language_detect': 28, 'supports_translate': 29, 'supports_streaming': 30, 'supports_spec_decode': 31, 'max_audio_ms': 32, 'n_translate_target_languages': 40, 'translate_target_languages': 48 } },
@@ -142,10 +162,23 @@ export const STRUCT_LAYOUT = {
142
162
  'transcribe_word': { size: 48, align: 8, offsets: { 'struct_size': 0, 't0_ms': 8, 't1_ms': 16, 'seg_index': 24, 'first_token': 28, 'n_tokens': 32, 'text': 40 } },
143
163
  'transcribe_token': { size: 48, align: 8, offsets: { 'struct_size': 0, 'id': 8, 'p': 12, 't0_ms': 16, 't1_ms': 24, 'seg_index': 32, 'word_index': 36, 'text': 40 } },
144
164
  'transcribe_speaker_segment': { size: 32, align: 8, offsets: { 'struct_size': 0, 't0_ms': 8, 't1_ms': 16, 'speaker_id': 24, 'p': 28 } },
165
+ 'transcribe_diarize_info': { size: 16, align: 8, offsets: { 'struct_size': 0, 'sample_rate': 8, 'max_speakers': 12 } },
166
+ 'transcribe_diarize_session_params': { size: 16, align: 8, offsets: { 'struct_size': 0, 'n_threads': 8 } },
167
+ 'transcribe_diarize_params': { size: 16, align: 8, offsets: { 'struct_size': 0, 'family': 8 } },
168
+ 'transcribe_langid_info': { size: 24, align: 8, offsets: { 'struct_size': 0, 'sample_rate': 8, 'n_labels': 12, 'min_audio_ms': 16, 'max_audio_ms': 20 } },
169
+ 'transcribe_langid_session_params': { size: 16, align: 8, offsets: { 'struct_size': 0, 'n_threads': 8 } },
170
+ 'transcribe_langid_params': { size: 24, align: 8, offsets: { 'struct_size': 0, 'allowed': 8, 'n_allowed': 16 } },
171
+ 'transcribe_langid_result': { size: 16, align: 8, offsets: { 'struct_size': 0, 'n_candidates': 8, 'allowed_mass': 12 } },
172
+ 'transcribe_langid_candidate': { size: 40, align: 8, offsets: { 'struct_size': 0, 'index': 8, 'code': 16, 'name': 24, 'p': 32, 'logit': 36 } },
145
173
  'transcribe_moonshine_streaming_stream_ext': { size: 24, align: 8, offsets: { 'ext': 0, 'min_decode_interval_ms': 16 } },
146
174
  'transcribe_parakeet_stream_ext': { size: 24, align: 8, offsets: { 'ext': 0, 'att_context_right': 16 } },
147
175
  'transcribe_parakeet_buffered_stream_ext': { size: 32, align: 8, offsets: { 'ext': 0, 'left_ms': 16, 'chunk_ms': 20, 'right_ms': 24 } },
148
- 'transcribe_sortformer_stream_ext': { size: 24, align: 8, offsets: { 'ext': 0, 'preset': 16 } },
176
+ 'transcribe_sortformer_diarize_ext': { size: 24, align: 8, offsets: { 'ext': 0, 'preset': 16 } },
177
+ 'transcribe_vad_info': { size: 16, align: 8, offsets: { 'struct_size': 0, 'sample_rate': 8, 'frame_samples': 12 } },
178
+ 'transcribe_vad_session_params': { size: 16, align: 8, offsets: { 'struct_size': 0, 'n_threads': 8 } },
179
+ 'transcribe_vad_params': { size: 40, align: 8, offsets: { 'struct_size': 0, 'threshold': 8, 'neg_threshold': 16, 'min_speech_ms': 24, 'min_silence_ms': 28, 'speech_pad_ms': 32, 'max_speech_ms': 36 } },
180
+ 'transcribe_vad_result': { size: 32, align: 8, offsets: { 'struct_size': 0, 'n_probs': 8, 'first_frame': 16, 'n_segments': 24 } },
181
+ 'transcribe_vad_segment': { size: 24, align: 8, offsets: { 'struct_size': 0, 'start_sample': 8, 'end_sample': 16 } },
149
182
  'transcribe_voxtral_realtime_stream_ext': { size: 24, align: 8, offsets: { 'ext': 0, 'num_delay_tokens': 16, 'min_decode_interval_ms': 20 } },
150
183
  'transcribe_whisper_run_ext': { size: 80, align: 8, offsets: { 'ext': 0, 'initial_prompt': 16, 'prompt_tokens': 24, 'n_prompt_tokens': 32, 'prompt_condition': 40, 'condition_on_prev_tokens': 44, 'max_prev_context_tokens': 48, 'temperature': 52, 'temperature_inc': 56, 'compression_ratio_thold': 60, 'logprob_thold': 64, 'no_speech_thold': 68, 'seed': 72, 'max_initial_timestamp': 76 } },
151
184
  'transcribe_whisper_chunk_trace': { size: 48, align: 8, offsets: { 'struct_size': 0, 't0_ms': 8, 't1_ms': 16, 'temperature_used': 24, 'compression_ratio': 28, 'avg_logprob': 32, 'no_speech_prob': 36, 'no_speech_triggered': 40, 'n_fallbacks': 44 } },
@@ -167,6 +200,19 @@ export const ABI_STRUCT_IDS = {
167
200
  'transcribe_word': 7,
168
201
  'transcribe_token': 8,
169
202
  'transcribe_speaker_segment': 14,
203
+ 'transcribe_diarize_info': 16,
204
+ 'transcribe_diarize_session_params': 17,
205
+ 'transcribe_diarize_params': 18,
206
+ 'transcribe_langid_info': 19,
207
+ 'transcribe_langid_session_params': 20,
208
+ 'transcribe_langid_params': 21,
209
+ 'transcribe_langid_result': 22,
210
+ 'transcribe_langid_candidate': 23,
211
+ 'transcribe_vad_info': 24,
212
+ 'transcribe_vad_session_params': 25,
213
+ 'transcribe_vad_params': 26,
214
+ 'transcribe_vad_result': 27,
215
+ 'transcribe_vad_segment': 28,
170
216
  };
171
217
  // Build koffi struct types; returns a name -> koffi.IKoffiCType map.
172
218
  export function defineTypes(koffi) {
@@ -174,7 +220,7 @@ export function defineTypes(koffi) {
174
220
  T['transcribe_ext'] = koffi.struct({ size: 'uint64_t', kind: 'uint32_t' });
175
221
  T['transcribe_backend_init_params'] = koffi.struct({ struct_size: 'uint64_t', artifact_dir: 'char *', allowed_backends: 'uint32_t' });
176
222
  T['transcribe_device_info'] = koffi.struct({ struct_size: 'uint64_t', name: 'char *', description: 'char *', kind: 'char *', device_id: 'char *', memory_total: 'uint64_t', memory_free: 'uint64_t', device_type: 'int' });
177
- T['transcribe_model_load_params'] = koffi.struct({ struct_size: 'uint64_t', backend: 'int', device: 'void *' });
223
+ T['transcribe_model_load_params'] = koffi.struct({ struct_size: 'uint64_t', backend: 'int', device: 'void *', no_mmap: 'bool' });
178
224
  T['transcribe_session_params'] = koffi.struct({ struct_size: 'uint64_t', n_threads: 'int', kv_type: 'int', n_ctx: 'int32_t' });
179
225
  T['transcribe_run_params'] = koffi.struct({ struct_size: 'uint64_t', task: 'int', timestamps: 'int', pnc: 'int', itn: 'int', diarize: 'int', language: 'char *', target_language: 'char *', keep_special_tags: 'bool', family: 'void *', spec_k_drafts: 'int32_t', vocabulary: 'void *', n_vocabulary: 'int32_t', prompt: 'char *', prefix: 'char *' });
180
226
  T['transcribe_capabilities'] = koffi.struct({ struct_size: 'uint64_t', native_sample_rate: 'int32_t', n_languages: 'int', languages: 'void *', max_timestamp_kind: 'int', supports_language_detect: 'bool', supports_translate: 'bool', supports_streaming: 'bool', supports_spec_decode: 'bool', max_audio_ms: 'int64_t', n_translate_target_languages: 'int', translate_target_languages: 'void *' });
@@ -187,10 +233,23 @@ export function defineTypes(koffi) {
187
233
  T['transcribe_word'] = koffi.struct({ struct_size: 'uint64_t', t0_ms: 'int64_t', t1_ms: 'int64_t', seg_index: 'int', first_token: 'int', n_tokens: 'int', text: 'char *' });
188
234
  T['transcribe_token'] = koffi.struct({ struct_size: 'uint64_t', id: 'int', p: 'float', t0_ms: 'int64_t', t1_ms: 'int64_t', seg_index: 'int', word_index: 'int', text: 'char *' });
189
235
  T['transcribe_speaker_segment'] = koffi.struct({ struct_size: 'uint64_t', t0_ms: 'int64_t', t1_ms: 'int64_t', speaker_id: 'int32_t', p: 'float' });
236
+ T['transcribe_diarize_info'] = koffi.struct({ struct_size: 'uint64_t', sample_rate: 'int32_t', max_speakers: 'int32_t' });
237
+ T['transcribe_diarize_session_params'] = koffi.struct({ struct_size: 'uint64_t', n_threads: 'int32_t' });
238
+ T['transcribe_diarize_params'] = koffi.struct({ struct_size: 'uint64_t', family: 'void *' });
239
+ T['transcribe_langid_info'] = koffi.struct({ struct_size: 'uint64_t', sample_rate: 'int32_t', n_labels: 'int32_t', min_audio_ms: 'int32_t', max_audio_ms: 'int32_t' });
240
+ T['transcribe_langid_session_params'] = koffi.struct({ struct_size: 'uint64_t', n_threads: 'int32_t' });
241
+ T['transcribe_langid_params'] = koffi.struct({ struct_size: 'uint64_t', allowed: 'void *', n_allowed: 'int32_t' });
242
+ T['transcribe_langid_result'] = koffi.struct({ struct_size: 'uint64_t', n_candidates: 'int32_t', allowed_mass: 'float' });
243
+ T['transcribe_langid_candidate'] = koffi.struct({ struct_size: 'uint64_t', index: 'int32_t', code: 'char *', name: 'char *', p: 'float', logit: 'float' });
190
244
  T['transcribe_moonshine_streaming_stream_ext'] = koffi.struct({ ext: T['transcribe_ext'], min_decode_interval_ms: 'int32_t' });
191
245
  T['transcribe_parakeet_stream_ext'] = koffi.struct({ ext: T['transcribe_ext'], att_context_right: 'int32_t' });
192
246
  T['transcribe_parakeet_buffered_stream_ext'] = koffi.struct({ ext: T['transcribe_ext'], left_ms: 'int32_t', chunk_ms: 'int32_t', right_ms: 'int32_t' });
193
- T['transcribe_sortformer_stream_ext'] = koffi.struct({ ext: T['transcribe_ext'], preset: 'int' });
247
+ T['transcribe_sortformer_diarize_ext'] = koffi.struct({ ext: T['transcribe_ext'], preset: 'int' });
248
+ T['transcribe_vad_info'] = koffi.struct({ struct_size: 'uint64_t', sample_rate: 'int32_t', frame_samples: 'int32_t' });
249
+ T['transcribe_vad_session_params'] = koffi.struct({ struct_size: 'uint64_t', n_threads: 'int32_t' });
250
+ T['transcribe_vad_params'] = koffi.struct({ struct_size: 'uint64_t', threshold: 'double', neg_threshold: 'double', min_speech_ms: 'int32_t', min_silence_ms: 'int32_t', speech_pad_ms: 'int32_t', max_speech_ms: 'int32_t' });
251
+ T['transcribe_vad_result'] = koffi.struct({ struct_size: 'uint64_t', n_probs: 'int32_t', first_frame: 'int64_t', n_segments: 'int32_t' });
252
+ T['transcribe_vad_segment'] = koffi.struct({ struct_size: 'uint64_t', start_sample: 'int64_t', end_sample: 'int64_t' });
194
253
  T['transcribe_voxtral_realtime_stream_ext'] = koffi.struct({ ext: T['transcribe_ext'], num_delay_tokens: 'int32_t', min_decode_interval_ms: 'int32_t' });
195
254
  T['transcribe_whisper_run_ext'] = koffi.struct({ ext: T['transcribe_ext'], initial_prompt: 'char *', prompt_tokens: 'void *', n_prompt_tokens: 'size_t', prompt_condition: 'int', condition_on_prev_tokens: 'bool', max_prev_context_tokens: 'int32_t', temperature: 'float', temperature_inc: 'float', compression_ratio_thold: 'float', logprob_thold: 'float', no_speech_thold: 'float', seed: 'uint32_t', max_initial_timestamp: 'float' });
196
255
  T['transcribe_whisper_chunk_trace'] = koffi.struct({ struct_size: 'uint64_t', t0_ms: 'int64_t', t1_ms: 'int64_t', temperature_used: 'float', compression_ratio: 'float', avg_logprob: 'float', no_speech_prob: 'float', no_speech_triggered: 'bool', n_fallbacks: 'int32_t' });
@@ -224,6 +283,17 @@ export const FUNCTION_SIGNATURES = {
224
283
  'transcribe_device_get': { ret: 'transcribe_device_t', args: ['int'] },
225
284
  'transcribe_device_get_info': { ret: 'transcribe_status', args: ['transcribe_device_t', 'struct transcribe_device_info *'] },
226
285
  'transcribe_device_info_init': { ret: 'void', args: ['struct transcribe_device_info *'] },
286
+ 'transcribe_diarize_get_info': { ret: 'transcribe_status', args: ['const struct transcribe_model *', 'struct transcribe_diarize_info *'] },
287
+ 'transcribe_diarize_get_segment': { ret: 'transcribe_status', args: ['const struct transcribe_diarize_session *', 'int', 'struct transcribe_speaker_segment *'] },
288
+ 'transcribe_diarize_get_timings': { ret: 'transcribe_status', args: ['const struct transcribe_diarize_session *', 'struct transcribe_timings *'] },
289
+ 'transcribe_diarize_info_init': { ret: 'void', args: ['struct transcribe_diarize_info *'] },
290
+ 'transcribe_diarize_n_segments': { ret: 'int', args: ['const struct transcribe_diarize_session *'] },
291
+ 'transcribe_diarize_params_init': { ret: 'void', args: ['struct transcribe_diarize_params *'] },
292
+ 'transcribe_diarize_run': { ret: 'transcribe_status', args: ['struct transcribe_diarize_session *', 'const float *', 'int', 'const struct transcribe_diarize_params *'] },
293
+ 'transcribe_diarize_session_free': { ret: 'void', args: ['struct transcribe_diarize_session *'] },
294
+ 'transcribe_diarize_session_init': { ret: 'transcribe_status', args: ['struct transcribe_model *', 'const struct transcribe_diarize_session_params *', 'struct transcribe_diarize_session **'] },
295
+ 'transcribe_diarize_session_params_init': { ret: 'void', args: ['struct transcribe_diarize_session_params *'] },
296
+ 'transcribe_diarize_set_abort_callback': { ret: 'void', args: ['struct transcribe_diarize_session *', 'transcribe_abort_callback', 'void *'] },
227
297
  'transcribe_ext_check': { ret: 'transcribe_status', args: ['const struct transcribe_ext *', 'uint32_t', 'uint64_t'] },
228
298
  'transcribe_full_text': { ret: 'const char *', args: ['const struct transcribe_session *'] },
229
299
  'transcribe_get_model': { ret: 'const struct transcribe_model *', args: ['const struct transcribe_session *'] },
@@ -237,6 +307,22 @@ export const FUNCTION_SIGNATURES = {
237
307
  'transcribe_init_backends': { ret: 'transcribe_status', args: ['const char *'] },
238
308
  'transcribe_init_backends_default': { ret: 'transcribe_status', args: [] },
239
309
  'transcribe_init_backends_ex': { ret: 'transcribe_status', args: ['const struct transcribe_backend_init_params *'] },
310
+ 'transcribe_langid_candidate_init': { ret: 'void', args: ['struct transcribe_langid_candidate *'] },
311
+ 'transcribe_langid_get_candidate': { ret: 'transcribe_status', args: ['const struct transcribe_langid_session *', 'int', 'struct transcribe_langid_candidate *'] },
312
+ 'transcribe_langid_get_info': { ret: 'transcribe_status', args: ['const struct transcribe_model *', 'struct transcribe_langid_info *'] },
313
+ 'transcribe_langid_get_result': { ret: 'transcribe_status', args: ['const struct transcribe_langid_session *', 'struct transcribe_langid_result *'] },
314
+ 'transcribe_langid_get_timings': { ret: 'transcribe_status', args: ['const struct transcribe_langid_session *', 'struct transcribe_timings *'] },
315
+ 'transcribe_langid_info_init': { ret: 'void', args: ['struct transcribe_langid_info *'] },
316
+ 'transcribe_langid_label_code': { ret: 'const char *', args: ['const struct transcribe_model *', 'int32_t'] },
317
+ 'transcribe_langid_label_index': { ret: 'int32_t', args: ['const struct transcribe_model *', 'const char *'] },
318
+ 'transcribe_langid_label_name': { ret: 'const char *', args: ['const struct transcribe_model *', 'int32_t'] },
319
+ 'transcribe_langid_params_init': { ret: 'void', args: ['struct transcribe_langid_params *'] },
320
+ 'transcribe_langid_result_init': { ret: 'void', args: ['struct transcribe_langid_result *'] },
321
+ 'transcribe_langid_run': { ret: 'transcribe_status', args: ['struct transcribe_langid_session *', 'const float *', 'int', 'const struct transcribe_langid_params *'] },
322
+ 'transcribe_langid_session_free': { ret: 'void', args: ['struct transcribe_langid_session *'] },
323
+ 'transcribe_langid_session_init': { ret: 'transcribe_status', args: ['struct transcribe_model *', 'const struct transcribe_langid_session_params *', 'struct transcribe_langid_session **'] },
324
+ 'transcribe_langid_session_params_init': { ret: 'void', args: ['struct transcribe_langid_session_params *'] },
325
+ 'transcribe_langid_set_abort_callback': { ret: 'void', args: ['struct transcribe_langid_session *', 'transcribe_abort_callback', 'void *'] },
240
326
  'transcribe_log_set': { ret: 'void', args: ['transcribe_log_callback', 'void *'] },
241
327
  'transcribe_model_accepts_ext_kind': { ret: '_Bool', args: ['const struct transcribe_model *', 'transcribe_ext_slot', 'uint32_t'] },
242
328
  'transcribe_model_arch_string': { ret: 'const char *', args: ['const struct transcribe_model *'] },
@@ -247,6 +333,7 @@ export const FUNCTION_SIGNATURES = {
247
333
  'transcribe_model_load_file': { ret: 'transcribe_status', args: ['const char *', 'const struct transcribe_model_load_params *', 'struct transcribe_model **'] },
248
334
  'transcribe_model_load_params_init': { ret: 'void', args: ['struct transcribe_model_load_params *'] },
249
335
  'transcribe_model_meta_val_str': { ret: 'const char *', args: ['const struct transcribe_model *', 'const char *'] },
336
+ 'transcribe_model_roles': { ret: 'uint32_t', args: ['const struct transcribe_model *'] },
250
337
  'transcribe_model_supports': { ret: '_Bool', args: ['const struct transcribe_model *', 'transcribe_feature'] },
251
338
  'transcribe_model_variant_string': { ret: 'const char *', args: ['const struct transcribe_model *'] },
252
339
  'transcribe_moonshine_streaming_stream_ext_init': { ret: 'void', args: ['struct transcribe_moonshine_streaming_stream_ext *'] },
@@ -271,7 +358,7 @@ export const FUNCTION_SIGNATURES = {
271
358
  'transcribe_session_limits_init': { ret: 'void', args: ['struct transcribe_session_limits *'] },
272
359
  'transcribe_session_params_init': { ret: 'void', args: ['struct transcribe_session_params *'] },
273
360
  'transcribe_set_abort_callback': { ret: 'void', args: ['struct transcribe_session *', 'transcribe_abort_callback', 'void *'] },
274
- 'transcribe_sortformer_stream_ext_init': { ret: 'void', args: ['struct transcribe_sortformer_stream_ext *'] },
361
+ 'transcribe_sortformer_diarize_ext_init': { ret: 'void', args: ['struct transcribe_sortformer_diarize_ext *'] },
275
362
  'transcribe_speaker_segment_init': { ret: 'void', args: ['struct transcribe_speaker_segment *'] },
276
363
  'transcribe_status_string': { ret: 'const char *', args: ['int'] },
277
364
  'transcribe_stream_begin': { ret: 'transcribe_status', args: ['struct transcribe_session *', 'const struct transcribe_run_params *', 'const struct transcribe_stream_params *'] },
@@ -291,6 +378,23 @@ export const FUNCTION_SIGNATURES = {
291
378
  'transcribe_timings_init': { ret: 'void', args: ['struct transcribe_timings *'] },
292
379
  'transcribe_token_init': { ret: 'void', args: ['struct transcribe_token *'] },
293
380
  'transcribe_tokenize': { ret: 'int', args: ['const struct transcribe_model *', 'const char *', 'int32_t *', 'size_t'] },
381
+ 'transcribe_vad_get_info': { ret: 'transcribe_status', args: ['const struct transcribe_model *', 'struct transcribe_vad_info *'] },
382
+ 'transcribe_vad_get_result': { ret: 'transcribe_status', args: ['const struct transcribe_vad_session *', 'struct transcribe_vad_result *'] },
383
+ 'transcribe_vad_get_segment': { ret: 'transcribe_status', args: ['const struct transcribe_vad_session *', 'int', 'struct transcribe_vad_segment *'] },
384
+ 'transcribe_vad_get_timings': { ret: 'transcribe_status', args: ['const struct transcribe_vad_session *', 'struct transcribe_timings *'] },
385
+ 'transcribe_vad_info_init': { ret: 'void', args: ['struct transcribe_vad_info *'] },
386
+ 'transcribe_vad_params_init': { ret: 'void', args: ['struct transcribe_vad_params *'] },
387
+ 'transcribe_vad_probs': { ret: 'const float *', args: ['const struct transcribe_vad_session *'] },
388
+ 'transcribe_vad_result_init': { ret: 'void', args: ['struct transcribe_vad_result *'] },
389
+ 'transcribe_vad_run': { ret: 'transcribe_status', args: ['struct transcribe_vad_session *', 'const float *', 'int', 'const struct transcribe_vad_params *'] },
390
+ 'transcribe_vad_segment_init': { ret: 'void', args: ['struct transcribe_vad_segment *'] },
391
+ 'transcribe_vad_session_free': { ret: 'void', args: ['struct transcribe_vad_session *'] },
392
+ 'transcribe_vad_session_init': { ret: 'transcribe_status', args: ['struct transcribe_model *', 'const struct transcribe_vad_session_params *', 'struct transcribe_vad_session **'] },
393
+ 'transcribe_vad_session_params_init': { ret: 'void', args: ['struct transcribe_vad_session_params *'] },
394
+ 'transcribe_vad_set_abort_callback': { ret: 'void', args: ['struct transcribe_vad_session *', 'transcribe_abort_callback', 'void *'] },
395
+ 'transcribe_vad_stream_feed': { ret: 'transcribe_status', args: ['struct transcribe_vad_session *', 'const float *', 'int'] },
396
+ 'transcribe_vad_stream_flush': { ret: 'transcribe_status', args: ['struct transcribe_vad_session *'] },
397
+ 'transcribe_vad_stream_reset': { ret: 'void', args: ['struct transcribe_vad_session *'] },
294
398
  'transcribe_version': { ret: 'const char *', args: [] },
295
399
  'transcribe_version_commit': { ret: 'const char *', args: [] },
296
400
  'transcribe_voxtral_realtime_stream_ext_init': { ret: 'void', args: ['struct transcribe_voxtral_realtime_stream_ext *'] },
package/dist/errors.d.ts CHANGED
@@ -35,8 +35,20 @@ export declare class AbiError extends TranscribeError {
35
35
  }
36
36
  export declare class InputTooLong extends TranscribeError {
37
37
  }
38
+ /** Raised when the audio is shorter than the role's minimum (e.g. language ID's minAudioMs). */
39
+ export declare class InputTooShort extends TranscribeError {
40
+ }
38
41
  export declare class VersionMismatch extends TranscribeError {
39
42
  }
43
+ /**
44
+ * Raised by a synchronous backend query while `initialize()` is still running
45
+ * (waiting could deadlock). Binding-side error, so `status` is 0.
46
+ */
47
+ export declare class BackendInitializing extends TranscribeError {
48
+ }
49
+ /** Raised when the model does not serve the role (ASR, diarize, langid, vad) the call needs. */
50
+ export declare class UnsupportedRole extends TranscribeError {
51
+ }
40
52
  /** Raised when a run is cancelled; carries any partial transcript in `partialResult`. */
41
53
  export declare class Aborted extends TranscribeError {
42
54
  }
package/dist/errors.js CHANGED
@@ -39,8 +39,20 @@ export class AbiError extends TranscribeError {
39
39
  }
40
40
  export class InputTooLong extends TranscribeError {
41
41
  }
42
+ /** Raised when the audio is shorter than the role's minimum (e.g. language ID's minAudioMs). */
43
+ export class InputTooShort extends TranscribeError {
44
+ }
42
45
  export class VersionMismatch extends TranscribeError {
43
46
  }
47
+ /**
48
+ * Raised by a synchronous backend query while `initialize()` is still running
49
+ * (waiting could deadlock). Binding-side error, so `status` is 0.
50
+ */
51
+ export class BackendInitializing extends TranscribeError {
52
+ }
53
+ /** Raised when the model does not serve the role (ASR, diarize, langid, vad) the call needs. */
54
+ export class UnsupportedRole extends TranscribeError {
55
+ }
44
56
  /** Raised when a run is cancelled; carries any partial transcript in `partialResult`. */
45
57
  export class Aborted extends TranscribeError {
46
58
  }
@@ -74,6 +86,8 @@ const STATUS_TO_EXC = {
74
86
  [g.TRANSCRIBE_ERR_INPUT_TOO_LONG]: InputTooLong,
75
87
  [g.TRANSCRIBE_ERR_OUTPUT_TRUNCATED]: OutputTruncated,
76
88
  [g.TRANSCRIBE_ERR_OUTPUT_REPETITION]: OutputRepetition,
89
+ [g.TRANSCRIBE_ERR_UNSUPPORTED_ROLE]: UnsupportedRole,
90
+ [g.TRANSCRIBE_ERR_INPUT_TOO_SHORT]: InputTooShort,
77
91
  };
78
92
  /** Build (do not throw) the mapped exception for a status. */
79
93
  export function exceptionForStatus(status, statusString, context = "") {