transcribe-cpp 0.3.0 → 0.4.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 +100 -20
- package/dist/_generated.d.ts +30 -2
- package/dist/_generated.js +123 -5
- package/dist/errors.d.ts +12 -0
- package/dist/errors.js +14 -0
- package/dist/ffi.js +144 -2
- package/dist/index.d.ts +96 -3
- package/dist/index.js +626 -206
- package/dist/native.d.ts +40 -7
- package/dist/native.js +155 -23
- package/dist/types.d.ts +114 -6
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -109,10 +109,73 @@ const stream = await session.stream({ family: { kind: "moonshine" } });
|
|
|
109
109
|
model.accepts({ kind: "whisper" }); // does this model take that extension?
|
|
110
110
|
```
|
|
111
111
|
|
|
112
|
+
### Diarization (DIARIZE role)
|
|
113
|
+
|
|
114
|
+
`model.roles` lists what a model serves (`"asr"`, `"diarize"`, `"langid"`,
|
|
115
|
+
`"vad"`; Sortformer is diarize-only). Calls for a role the model lacks throw
|
|
116
|
+
`UnsupportedRole`.
|
|
117
|
+
|
|
118
|
+
```ts
|
|
119
|
+
const { sampleRate, maxSpeakers } = model.diarizeInfo;
|
|
120
|
+
using diarizer = model.createDiarizeSession();
|
|
121
|
+
const turns = await diarizer.run(pcm, {
|
|
122
|
+
family: { kind: "sortformer_diarize", preset: "very_high_latency" },
|
|
123
|
+
});
|
|
124
|
+
for (const t of turns) console.log(t.speakerId, t.t0Ms, t.t1Ms);
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
`run` accepts a `signal`; cancelling throws `Aborted` (with no partial result).
|
|
128
|
+
`diarizer.timings` reports the last run. Diarize runs wait on the same
|
|
129
|
+
model-wide lock as other compute calls (see below).
|
|
130
|
+
|
|
131
|
+
### Language ID (LANGID role)
|
|
132
|
+
|
|
133
|
+
A `"langid"` model (VoxLingua107 ECAPA-TDNN) ranks its own label codes; match
|
|
134
|
+
`result.code` against an ASR model's `capabilities.languages` yourself.
|
|
135
|
+
Every allowed label is returned, ranked by `p`. Omitting `allowed` scores every
|
|
136
|
+
label, `[]` throws `InvalidArgument`, clips under `model.langidInfo.minAudioMs`
|
|
137
|
+
throw `InputTooShort`, and input longer than `maxAudioMs` is scored on its first `maxAudioMs`.
|
|
138
|
+
|
|
139
|
+
```ts
|
|
140
|
+
using lid = model.createLangIdSession();
|
|
141
|
+
const result = await lid.run(pcm, { allowed: ["en", "de", "fr"] });
|
|
142
|
+
console.log(result.code, result.candidates[0].p, result.allowedMass);
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
### Voice activity detection (VAD role)
|
|
146
|
+
|
|
147
|
+
A `"vad"` model (Silero VAD) scores `model.vadInfo.frameSamples`-sample frames
|
|
148
|
+
(512 = 32 ms at 16 kHz) with a speech probability. `run` scores a whole clip
|
|
149
|
+
and segments it with Silero's `get_speech_timestamps` rules (options such as
|
|
150
|
+
`threshold`, `minSilenceMs` and `maxSpeechMs`; samples are 16 kHz indices):
|
|
151
|
+
|
|
152
|
+
```ts
|
|
153
|
+
using vad = model.createVadSession();
|
|
154
|
+
const { segments, probs } = await vad.run(pcm, { threshold: 0.5 });
|
|
155
|
+
for (const s of segments) console.log(s.startSample, s.endSample);
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
For live audio, `streamFeed(chunk)` returns the probabilities of the frames
|
|
159
|
+
each chunk completes (`firstFrame` is the index of `probs[0]`), `streamFlush()`
|
|
160
|
+
scores the zero-padded remainder and ends the stream, and `streamReset()` drops
|
|
161
|
+
it. The next feed after either starts at frame 0, as does the next feed after an
|
|
162
|
+
abort or processing error.
|
|
163
|
+
|
|
164
|
+
```ts
|
|
165
|
+
for await (const chunk of mic) {
|
|
166
|
+
const { firstFrame, probs } = await vad.streamFeed(chunk);
|
|
167
|
+
probs.forEach((p, i) => console.log(firstFrame + i, p));
|
|
168
|
+
}
|
|
169
|
+
const tail = await vad.streamFlush();
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
A VAD stream is session state, not a stream lease: VAD calls raise `Busy` only
|
|
173
|
+
while an ASR stream on the same model holds the lease.
|
|
174
|
+
|
|
112
175
|
### Resource management
|
|
113
176
|
|
|
114
|
-
`TranscribeModel`, `Session`, and `Stream` all implement
|
|
115
|
-
`using` works (TypeScript 5.2+ / Node 22+):
|
|
177
|
+
`TranscribeModel`, `Session`, `DiarizeSession`, `LangIdSession`, `VadSession`, and `Stream` all implement
|
|
178
|
+
`Symbol.dispose`, so `using` works (TypeScript 5.2+ / Node 22+):
|
|
116
179
|
|
|
117
180
|
```ts
|
|
118
181
|
using model = await TranscribeModel.load("model.gguf");
|
|
@@ -123,13 +186,26 @@ using session = model.createSession();
|
|
|
123
186
|
Disposing a model disposes its sessions; disposing a stream resets it (releasing
|
|
124
187
|
the model lease). Disposal is idempotent and order-independent.
|
|
125
188
|
|
|
189
|
+
## Startup and UI responsiveness
|
|
190
|
+
|
|
191
|
+
Initializing compute backends can take seconds (on Metal it compiles the GPU
|
|
192
|
+
shader library). `TranscribeModel.load()` does this on a worker thread, so the
|
|
193
|
+
event loop keeps running. To pay the cost up front, call `await initialize()`
|
|
194
|
+
at startup; `backendState()` reports its progress.
|
|
195
|
+
|
|
196
|
+
Use `getAvailableBackendsAsync()` / `backendAvailableAsync()` in UI processes.
|
|
197
|
+
The sync variants initialize backends on the calling thread if needed, and
|
|
198
|
+
throw `BackendInitializing` while `initialize()` is running. A failed backend
|
|
199
|
+
initialization is permanent for the process; later calls rethrow its
|
|
200
|
+
`BackendError`.
|
|
201
|
+
|
|
126
202
|
## Backend selection
|
|
127
203
|
|
|
128
204
|
```ts
|
|
129
|
-
import {
|
|
205
|
+
import { getAvailableBackendsAsync, backendAvailableAsync } from "transcribe-cpp";
|
|
130
206
|
|
|
131
|
-
const devices =
|
|
132
|
-
|
|
207
|
+
const devices = await getAvailableBackendsAsync();
|
|
208
|
+
await backendAvailableAsync("rocm"); // boolean
|
|
133
209
|
|
|
134
210
|
// Policy selection: first matching ROCm device.
|
|
135
211
|
const automatic = await TranscribeModel.load("model.gguf", { backend: "rocm" });
|
|
@@ -150,14 +226,14 @@ native compute to a **libuv worker thread** (via koffi's async calls), so the
|
|
|
150
226
|
event loop stays responsive while inference runs.
|
|
151
227
|
|
|
152
228
|
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
|
|
154
|
-
every compute call serializes through an internal model-wide
|
|
155
|
-
stream holds a model-wide lease for its whole lifetime.
|
|
156
|
-
(after `stream()`, before `finalize()`/`reset()`), a
|
|
157
|
-
any session of that model is refused with a `Busy`
|
|
158
|
-
race. So to parallelize, load one model per worker;
|
|
159
|
-
reset the stream first. A single `Session` is
|
|
160
|
-
`run`/`feed` on the same session concurrently.
|
|
229
|
+
a diarize `run`, or an *active stream* — across all of its sessions. The binding
|
|
230
|
+
enforces this: every compute call serializes through an internal model-wide
|
|
231
|
+
mutex, and an active stream holds a model-wide lease for its whole lifetime.
|
|
232
|
+
While a stream is active (after `stream()`, before `finalize()`/`reset()`), a
|
|
233
|
+
`run`/`runBatch`/`stream` on any session of that model is refused with a `Busy`
|
|
234
|
+
error rather than allowed to race. So to parallelize, load one model per worker;
|
|
235
|
+
to share a model, finalize or reset the stream first. A single `Session` is
|
|
236
|
+
single-use-at-a-time — don't call `run`/`feed` on the same session concurrently.
|
|
161
237
|
|
|
162
238
|
Hand-offs are ordered, not racy: `finalize()`/`reset()`/`dispose()` release the
|
|
163
239
|
lease only after the native teardown runs on the shared queue, so the slot is
|
|
@@ -166,20 +242,24 @@ is correctly serialized — `stream.reset(); const next = await session.stream()
|
|
|
166
242
|
works without awaiting the (void) `reset()`. The reverse order — beginning before
|
|
167
243
|
the teardown — is refused with `Busy`, by design.
|
|
168
244
|
|
|
245
|
+
A `feed()` rejected up front (e.g. NaN samples) leaves the stream `"active"` and
|
|
246
|
+
the lease held; a failure inside the model makes it `"failed"` and frees the lease.
|
|
247
|
+
|
|
169
248
|
Because the compute is genuinely on another thread, **do not touch a session
|
|
170
249
|
while a call against it is in flight** — it is single-threaded in the C library:
|
|
171
250
|
|
|
172
|
-
- Reading a stream's `text`/`snapshot`/`state`/`revision`/`lastStatus`,
|
|
173
|
-
session's `limits`/`wasAborted`, during an
|
|
174
|
-
`feed`/`finalize`/`run`/`runBatch` **throws**.
|
|
251
|
+
- Reading a stream's `text`/`snapshot`/`state`/`revision`/`lastStatus`, a
|
|
252
|
+
session's `limits`/`wasAborted`, or a `DiarizeSession`'s `timings`, during an
|
|
253
|
+
un-awaited `feed`/`finalize`/`run`/`runBatch` **throws**.
|
|
175
254
|
- `reset()` and `dispose()` are safe to call any time: the native teardown is
|
|
176
255
|
deferred behind any in-flight call, so it never frees a session mid-compute.
|
|
177
256
|
- Disposing a `Session` or `TranscribeModel` while a stream is still active
|
|
178
257
|
releases the lease and invalidates the stream — its later calls throw rather
|
|
179
258
|
than touch the freed handle.
|
|
180
|
-
- The **input PCM is borrowed, not copied**: `run`/`runBatch`/`feed`
|
|
181
|
-
buffer to native code that reads it on the
|
|
182
|
-
(e.g. reuse a scratch/capture buffer)
|
|
259
|
+
- The **input PCM is borrowed, not copied**: `run`/`runBatch`/`feed` (and
|
|
260
|
+
`DiarizeSession.run`) hand the buffer to native code that reads it on the
|
|
261
|
+
worker thread, so do not mutate it (e.g. reuse a scratch/capture buffer)
|
|
262
|
+
until the returned promise resolves.
|
|
183
263
|
Pass a fresh buffer per call, or `await` before overwriting.
|
|
184
264
|
|
|
185
265
|
The normal pattern is safe — `await` first, then read:
|
|
@@ -284,4 +364,4 @@ to your `build.rs` as `DEP_TRANSCRIBE_CPP_RUNTIME_DIR`.
|
|
|
284
364
|
## License
|
|
285
365
|
|
|
286
366
|
MIT. Bundled native packages include third-party license texts (ggml, miniz,
|
|
287
|
-
and any bundled backend runtimes).
|
|
367
|
+
Silero VAD, and any bundled backend runtimes).
|
package/dist/_generated.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const PUBLIC_HEADER_HASH = "
|
|
1
|
+
export declare const PUBLIC_HEADER_HASH = "98540564cd329b85";
|
|
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;
|
|
@@ -34,6 +36,20 @@ export declare const TRANSCRIBE_ABI_SESSION_LIMITS = 11;
|
|
|
34
36
|
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;
|
|
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;
|
|
37
53
|
export declare const TRANSCRIBE_LOG_LEVEL_NONE = 0;
|
|
38
54
|
export declare const TRANSCRIBE_LOG_LEVEL_INFO = 1;
|
|
39
55
|
export declare const TRANSCRIBE_LOG_LEVEL_WARN = 2;
|
|
@@ -62,6 +78,7 @@ export declare const TRANSCRIBE_DIARIZE_MODE_OFF = 1;
|
|
|
62
78
|
export declare const TRANSCRIBE_DIARIZE_MODE_ON = 2;
|
|
63
79
|
export declare const TRANSCRIBE_EXT_SLOT_RUN = 0;
|
|
64
80
|
export declare const TRANSCRIBE_EXT_SLOT_STREAM = 1;
|
|
81
|
+
export declare const TRANSCRIBE_EXT_SLOT_DIARIZE_RUN = 2;
|
|
65
82
|
export declare const TRANSCRIBE_BACKEND_AUTO = 0;
|
|
66
83
|
export declare const TRANSCRIBE_BACKEND_CPU = 1;
|
|
67
84
|
export declare const TRANSCRIBE_BACKEND_METAL = 2;
|
|
@@ -73,6 +90,10 @@ export declare const TRANSCRIBE_DEVICE_TYPE_CPU = 0;
|
|
|
73
90
|
export declare const TRANSCRIBE_DEVICE_TYPE_GPU = 1;
|
|
74
91
|
export declare const TRANSCRIBE_DEVICE_TYPE_IGPU = 2;
|
|
75
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;
|
|
76
97
|
export declare const TRANSCRIBE_FEATURE_INITIAL_PROMPT = 0;
|
|
77
98
|
export declare const TRANSCRIBE_FEATURE_TEMPERATURE_FALLBACK = 1;
|
|
78
99
|
export declare const TRANSCRIBE_FEATURE_LONG_FORM = 2;
|
|
@@ -97,10 +118,17 @@ export declare const TRANSCRIBE_SORTFORMER_PRESET_HIGH_LATENCY = 2;
|
|
|
97
118
|
export declare const TRANSCRIBE_SORTFORMER_PRESET_LOW_LATENCY = 3;
|
|
98
119
|
export declare const TRANSCRIBE_WHISPER_PROMPT_FIRST_SEGMENT = 0;
|
|
99
120
|
export declare const TRANSCRIBE_WHISPER_PROMPT_ALL_SEGMENTS = 1;
|
|
121
|
+
export declare const TRANSCRIBE_BACKEND_MASK_ALL = 4294967295;
|
|
122
|
+
export declare const TRANSCRIBE_BACKEND_MASK_CPU = 1;
|
|
123
|
+
export declare const TRANSCRIBE_BACKEND_MASK_CUDA = 8;
|
|
124
|
+
export declare const TRANSCRIBE_BACKEND_MASK_METAL = 2;
|
|
125
|
+
export declare const TRANSCRIBE_BACKEND_MASK_OTHER = 2147483648;
|
|
126
|
+
export declare const TRANSCRIBE_BACKEND_MASK_ROCM = 16;
|
|
127
|
+
export declare const TRANSCRIBE_BACKEND_MASK_VULKAN = 4;
|
|
100
128
|
export declare const TRANSCRIBE_EXT_KIND_MOONSHINE_STREAMING_STREAM = 1414746957;
|
|
101
129
|
export declare const TRANSCRIBE_EXT_KIND_PARAKEET_BUFFERED_STREAM = 1396853584;
|
|
102
130
|
export declare const TRANSCRIBE_EXT_KIND_PARAKEET_STREAM = 1414744912;
|
|
103
|
-
export declare const
|
|
131
|
+
export declare const TRANSCRIBE_EXT_KIND_SORTFORMER_DIARIZE = 1380206163;
|
|
104
132
|
export declare const TRANSCRIBE_EXT_KIND_VOXTRAL_REALTIME_STREAM = 1414746710;
|
|
105
133
|
export declare const TRANSCRIBE_EXT_KIND_WHISPER_RUN = 1314015319;
|
|
106
134
|
export interface StructLayout {
|
package/dist/_generated.js
CHANGED
|
@@ -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 = "
|
|
13
|
+
export const PUBLIC_HEADER_HASH = "98540564cd329b85";
|
|
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;
|
|
@@ -47,6 +49,20 @@ export const TRANSCRIBE_ABI_SESSION_LIMITS = 11;
|
|
|
47
49
|
export const TRANSCRIBE_ABI_EXT = 12;
|
|
48
50
|
export const TRANSCRIBE_ABI_DEVICE_INFO = 13;
|
|
49
51
|
export const TRANSCRIBE_ABI_SPEAKER_SEGMENT = 14;
|
|
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;
|
|
50
66
|
export const TRANSCRIBE_LOG_LEVEL_NONE = 0;
|
|
51
67
|
export const TRANSCRIBE_LOG_LEVEL_INFO = 1;
|
|
52
68
|
export const TRANSCRIBE_LOG_LEVEL_WARN = 2;
|
|
@@ -75,6 +91,7 @@ export const TRANSCRIBE_DIARIZE_MODE_OFF = 1;
|
|
|
75
91
|
export const TRANSCRIBE_DIARIZE_MODE_ON = 2;
|
|
76
92
|
export const TRANSCRIBE_EXT_SLOT_RUN = 0;
|
|
77
93
|
export const TRANSCRIBE_EXT_SLOT_STREAM = 1;
|
|
94
|
+
export const TRANSCRIBE_EXT_SLOT_DIARIZE_RUN = 2;
|
|
78
95
|
export const TRANSCRIBE_BACKEND_AUTO = 0;
|
|
79
96
|
export const TRANSCRIBE_BACKEND_CPU = 1;
|
|
80
97
|
export const TRANSCRIBE_BACKEND_METAL = 2;
|
|
@@ -86,6 +103,10 @@ export const TRANSCRIBE_DEVICE_TYPE_CPU = 0;
|
|
|
86
103
|
export const TRANSCRIBE_DEVICE_TYPE_GPU = 1;
|
|
87
104
|
export const TRANSCRIBE_DEVICE_TYPE_IGPU = 2;
|
|
88
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;
|
|
89
110
|
export const TRANSCRIBE_FEATURE_INITIAL_PROMPT = 0;
|
|
90
111
|
export const TRANSCRIBE_FEATURE_TEMPERATURE_FALLBACK = 1;
|
|
91
112
|
export const TRANSCRIBE_FEATURE_LONG_FORM = 2;
|
|
@@ -111,14 +132,22 @@ export const TRANSCRIBE_SORTFORMER_PRESET_LOW_LATENCY = 3;
|
|
|
111
132
|
export const TRANSCRIBE_WHISPER_PROMPT_FIRST_SEGMENT = 0;
|
|
112
133
|
export const TRANSCRIBE_WHISPER_PROMPT_ALL_SEGMENTS = 1;
|
|
113
134
|
// === macro constants (integer object-like macros) ===
|
|
135
|
+
export const TRANSCRIBE_BACKEND_MASK_ALL = 4294967295;
|
|
136
|
+
export const TRANSCRIBE_BACKEND_MASK_CPU = 1;
|
|
137
|
+
export const TRANSCRIBE_BACKEND_MASK_CUDA = 8;
|
|
138
|
+
export const TRANSCRIBE_BACKEND_MASK_METAL = 2;
|
|
139
|
+
export const TRANSCRIBE_BACKEND_MASK_OTHER = 2147483648;
|
|
140
|
+
export const TRANSCRIBE_BACKEND_MASK_ROCM = 16;
|
|
141
|
+
export const TRANSCRIBE_BACKEND_MASK_VULKAN = 4;
|
|
114
142
|
export const TRANSCRIBE_EXT_KIND_MOONSHINE_STREAMING_STREAM = 1414746957;
|
|
115
143
|
export const TRANSCRIBE_EXT_KIND_PARAKEET_BUFFERED_STREAM = 1396853584;
|
|
116
144
|
export const TRANSCRIBE_EXT_KIND_PARAKEET_STREAM = 1414744912;
|
|
117
|
-
export const
|
|
145
|
+
export const TRANSCRIBE_EXT_KIND_SORTFORMER_DIARIZE = 1380206163;
|
|
118
146
|
export const TRANSCRIBE_EXT_KIND_VOXTRAL_REALTIME_STREAM = 1414746710;
|
|
119
147
|
export const TRANSCRIBE_EXT_KIND_WHISPER_RUN = 1314015319;
|
|
120
148
|
export const STRUCT_LAYOUT = {
|
|
121
149
|
'transcribe_ext': { size: 16, align: 8, offsets: { 'size': 0, 'kind': 8 } },
|
|
150
|
+
'transcribe_backend_init_params': { size: 24, align: 8, offsets: { 'struct_size': 0, 'artifact_dir': 8, 'allowed_backends': 16 } },
|
|
122
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 } },
|
|
123
152
|
'transcribe_model_load_params': { size: 24, align: 8, offsets: { 'struct_size': 0, 'backend': 8, 'device': 16 } },
|
|
124
153
|
'transcribe_session_params': { size: 24, align: 8, offsets: { 'struct_size': 0, 'n_threads': 8, 'kv_type': 12, 'n_ctx': 16 } },
|
|
@@ -133,16 +162,30 @@ export const STRUCT_LAYOUT = {
|
|
|
133
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 } },
|
|
134
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 } },
|
|
135
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 } },
|
|
136
173
|
'transcribe_moonshine_streaming_stream_ext': { size: 24, align: 8, offsets: { 'ext': 0, 'min_decode_interval_ms': 16 } },
|
|
137
174
|
'transcribe_parakeet_stream_ext': { size: 24, align: 8, offsets: { 'ext': 0, 'att_context_right': 16 } },
|
|
138
175
|
'transcribe_parakeet_buffered_stream_ext': { size: 32, align: 8, offsets: { 'ext': 0, 'left_ms': 16, 'chunk_ms': 20, 'right_ms': 24 } },
|
|
139
|
-
'
|
|
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 } },
|
|
140
182
|
'transcribe_voxtral_realtime_stream_ext': { size: 24, align: 8, offsets: { 'ext': 0, 'num_delay_tokens': 16, 'min_decode_interval_ms': 20 } },
|
|
141
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 } },
|
|
142
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 } },
|
|
143
185
|
};
|
|
144
186
|
export const ABI_STRUCT_IDS = {
|
|
145
187
|
'transcribe_ext': 12,
|
|
188
|
+
'transcribe_backend_init_params': 15,
|
|
146
189
|
'transcribe_device_info': 13,
|
|
147
190
|
'transcribe_model_load_params': 0,
|
|
148
191
|
'transcribe_session_params': 1,
|
|
@@ -157,11 +200,25 @@ export const ABI_STRUCT_IDS = {
|
|
|
157
200
|
'transcribe_word': 7,
|
|
158
201
|
'transcribe_token': 8,
|
|
159
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,
|
|
160
216
|
};
|
|
161
217
|
// Build koffi struct types; returns a name -> koffi.IKoffiCType map.
|
|
162
218
|
export function defineTypes(koffi) {
|
|
163
219
|
const T = {};
|
|
164
220
|
T['transcribe_ext'] = koffi.struct({ size: 'uint64_t', kind: 'uint32_t' });
|
|
221
|
+
T['transcribe_backend_init_params'] = koffi.struct({ struct_size: 'uint64_t', artifact_dir: 'char *', allowed_backends: 'uint32_t' });
|
|
165
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' });
|
|
166
223
|
T['transcribe_model_load_params'] = koffi.struct({ struct_size: 'uint64_t', backend: 'int', device: 'void *' });
|
|
167
224
|
T['transcribe_session_params'] = koffi.struct({ struct_size: 'uint64_t', n_threads: 'int', kv_type: 'int', n_ctx: 'int32_t' });
|
|
@@ -176,10 +233,23 @@ export function defineTypes(koffi) {
|
|
|
176
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 *' });
|
|
177
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 *' });
|
|
178
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' });
|
|
179
244
|
T['transcribe_moonshine_streaming_stream_ext'] = koffi.struct({ ext: T['transcribe_ext'], min_decode_interval_ms: 'int32_t' });
|
|
180
245
|
T['transcribe_parakeet_stream_ext'] = koffi.struct({ ext: T['transcribe_ext'], att_context_right: 'int32_t' });
|
|
181
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' });
|
|
182
|
-
T['
|
|
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' });
|
|
183
253
|
T['transcribe_voxtral_realtime_stream_ext'] = koffi.struct({ ext: T['transcribe_ext'], num_delay_tokens: 'int32_t', min_decode_interval_ms: 'int32_t' });
|
|
184
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' });
|
|
185
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' });
|
|
@@ -188,7 +258,9 @@ export function defineTypes(koffi) {
|
|
|
188
258
|
export const FUNCTION_SIGNATURES = {
|
|
189
259
|
'transcribe_abi_struct_align': { ret: 'size_t', args: ['transcribe_abi_struct'] },
|
|
190
260
|
'transcribe_abi_struct_size': { ret: 'size_t', args: ['transcribe_abi_struct'] },
|
|
261
|
+
'transcribe_allowed_backends': { ret: 'uint32_t', args: [] },
|
|
191
262
|
'transcribe_backend_available': { ret: '_Bool', args: ['transcribe_backend_request'] },
|
|
263
|
+
'transcribe_backend_init_params_init': { ret: 'void', args: ['struct transcribe_backend_init_params *'] },
|
|
192
264
|
'transcribe_batch_detected_language': { ret: 'const char *', args: ['const struct transcribe_session *', 'int'] },
|
|
193
265
|
'transcribe_batch_full_text': { ret: 'const char *', args: ['const struct transcribe_session *', 'int'] },
|
|
194
266
|
'transcribe_batch_get_segment': { ret: 'transcribe_status', args: ['const struct transcribe_session *', 'int', 'int', 'struct transcribe_segment *'] },
|
|
@@ -211,6 +283,17 @@ export const FUNCTION_SIGNATURES = {
|
|
|
211
283
|
'transcribe_device_get': { ret: 'transcribe_device_t', args: ['int'] },
|
|
212
284
|
'transcribe_device_get_info': { ret: 'transcribe_status', args: ['transcribe_device_t', 'struct transcribe_device_info *'] },
|
|
213
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 *'] },
|
|
214
297
|
'transcribe_ext_check': { ret: 'transcribe_status', args: ['const struct transcribe_ext *', 'uint32_t', 'uint64_t'] },
|
|
215
298
|
'transcribe_full_text': { ret: 'const char *', args: ['const struct transcribe_session *'] },
|
|
216
299
|
'transcribe_get_model': { ret: 'const struct transcribe_model *', args: ['const struct transcribe_session *'] },
|
|
@@ -223,6 +306,23 @@ export const FUNCTION_SIGNATURES = {
|
|
|
223
306
|
'transcribe_get_word': { ret: 'transcribe_status', args: ['const struct transcribe_session *', 'int', 'struct transcribe_word *'] },
|
|
224
307
|
'transcribe_init_backends': { ret: 'transcribe_status', args: ['const char *'] },
|
|
225
308
|
'transcribe_init_backends_default': { ret: 'transcribe_status', args: [] },
|
|
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 *'] },
|
|
226
326
|
'transcribe_log_set': { ret: 'void', args: ['transcribe_log_callback', 'void *'] },
|
|
227
327
|
'transcribe_model_accepts_ext_kind': { ret: '_Bool', args: ['const struct transcribe_model *', 'transcribe_ext_slot', 'uint32_t'] },
|
|
228
328
|
'transcribe_model_arch_string': { ret: 'const char *', args: ['const struct transcribe_model *'] },
|
|
@@ -233,6 +333,7 @@ export const FUNCTION_SIGNATURES = {
|
|
|
233
333
|
'transcribe_model_load_file': { ret: 'transcribe_status', args: ['const char *', 'const struct transcribe_model_load_params *', 'struct transcribe_model **'] },
|
|
234
334
|
'transcribe_model_load_params_init': { ret: 'void', args: ['struct transcribe_model_load_params *'] },
|
|
235
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 *'] },
|
|
236
337
|
'transcribe_model_supports': { ret: '_Bool', args: ['const struct transcribe_model *', 'transcribe_feature'] },
|
|
237
338
|
'transcribe_model_variant_string': { ret: 'const char *', args: ['const struct transcribe_model *'] },
|
|
238
339
|
'transcribe_moonshine_streaming_stream_ext_init': { ret: 'void', args: ['struct transcribe_moonshine_streaming_stream_ext *'] },
|
|
@@ -257,7 +358,7 @@ export const FUNCTION_SIGNATURES = {
|
|
|
257
358
|
'transcribe_session_limits_init': { ret: 'void', args: ['struct transcribe_session_limits *'] },
|
|
258
359
|
'transcribe_session_params_init': { ret: 'void', args: ['struct transcribe_session_params *'] },
|
|
259
360
|
'transcribe_set_abort_callback': { ret: 'void', args: ['struct transcribe_session *', 'transcribe_abort_callback', 'void *'] },
|
|
260
|
-
'
|
|
361
|
+
'transcribe_sortformer_diarize_ext_init': { ret: 'void', args: ['struct transcribe_sortformer_diarize_ext *'] },
|
|
261
362
|
'transcribe_speaker_segment_init': { ret: 'void', args: ['struct transcribe_speaker_segment *'] },
|
|
262
363
|
'transcribe_status_string': { ret: 'const char *', args: ['int'] },
|
|
263
364
|
'transcribe_stream_begin': { ret: 'transcribe_status', args: ['struct transcribe_session *', 'const struct transcribe_run_params *', 'const struct transcribe_stream_params *'] },
|
|
@@ -277,6 +378,23 @@ export const FUNCTION_SIGNATURES = {
|
|
|
277
378
|
'transcribe_timings_init': { ret: 'void', args: ['struct transcribe_timings *'] },
|
|
278
379
|
'transcribe_token_init': { ret: 'void', args: ['struct transcribe_token *'] },
|
|
279
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 *'] },
|
|
280
398
|
'transcribe_version': { ret: 'const char *', args: [] },
|
|
281
399
|
'transcribe_version_commit': { ret: 'const char *', args: [] },
|
|
282
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 = "") {
|