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/dist/ffi.js
CHANGED
|
@@ -62,6 +62,7 @@ export function bindLibrary(libraryPath) {
|
|
|
62
62
|
modelBackend: lib.func("transcribe_model_backend", "str", ["void *"]),
|
|
63
63
|
modelDevice: lib.func("transcribe_model_device", "void *", ["void *"]),
|
|
64
64
|
modelSupports: lib.func("transcribe_model_supports", "bool", ["void *", "int"]),
|
|
65
|
+
modelRoles: lib.func("transcribe_model_roles", "uint32", ["void *"]),
|
|
65
66
|
tokenize: lib.func("transcribe_tokenize", "int", ["void *", "str", "int32_t *", "size_t"]),
|
|
66
67
|
capabilitiesInit: lib.func("transcribe_capabilities_init", "void", [
|
|
67
68
|
outp(T.transcribe_capabilities),
|
|
@@ -151,8 +152,149 @@ export function bindLibrary(libraryPath) {
|
|
|
151
152
|
voxtralRealtimeStreamExtInit: lib.func("transcribe_voxtral_realtime_stream_ext_init", "void", [
|
|
152
153
|
outp(T.transcribe_voxtral_realtime_stream_ext),
|
|
153
154
|
]),
|
|
154
|
-
|
|
155
|
-
outp(T.
|
|
155
|
+
sortformerDiarizeExtInit: lib.func("transcribe_sortformer_diarize_ext_init", "void", [
|
|
156
|
+
outp(T.transcribe_sortformer_diarize_ext),
|
|
157
|
+
]),
|
|
158
|
+
// diarize role
|
|
159
|
+
diarizeInfoInit: lib.func("transcribe_diarize_info_init", "void", [
|
|
160
|
+
outp(T.transcribe_diarize_info),
|
|
161
|
+
]),
|
|
162
|
+
diarizeGetInfo: lib.func("transcribe_diarize_get_info", "int", [
|
|
163
|
+
"void *",
|
|
164
|
+
iop(T.transcribe_diarize_info),
|
|
165
|
+
]),
|
|
166
|
+
diarizeSessionParamsInit: lib.func("transcribe_diarize_session_params_init", "void", [
|
|
167
|
+
outp(T.transcribe_diarize_session_params),
|
|
168
|
+
]),
|
|
169
|
+
diarizeSessionInit: lib.func("transcribe_diarize_session_init", "int", [
|
|
170
|
+
"void *",
|
|
171
|
+
inp(T.transcribe_diarize_session_params),
|
|
172
|
+
handleOut,
|
|
173
|
+
]),
|
|
174
|
+
diarizeSessionFree: lib.func("transcribe_diarize_session_free", "void", ["void *"]),
|
|
175
|
+
diarizeSetAbortCallback: lib.func("transcribe_diarize_set_abort_callback", "void", [
|
|
176
|
+
"void *",
|
|
177
|
+
"void *",
|
|
178
|
+
"void *",
|
|
179
|
+
]),
|
|
180
|
+
diarizeParamsInit: lib.func("transcribe_diarize_params_init", "void", [
|
|
181
|
+
outp(T.transcribe_diarize_params),
|
|
182
|
+
]),
|
|
183
|
+
diarizeRun: lib.func("transcribe_diarize_run", "int", [
|
|
184
|
+
"void *",
|
|
185
|
+
inp("float"),
|
|
186
|
+
"int",
|
|
187
|
+
inp(T.transcribe_diarize_params),
|
|
188
|
+
]),
|
|
189
|
+
diarizeNSegments: lib.func("transcribe_diarize_n_segments", "int", ["void *"]),
|
|
190
|
+
diarizeGetSegment: lib.func("transcribe_diarize_get_segment", "int", [
|
|
191
|
+
"void *",
|
|
192
|
+
"int",
|
|
193
|
+
iop(T.transcribe_speaker_segment),
|
|
194
|
+
]),
|
|
195
|
+
diarizeGetTimings: lib.func("transcribe_diarize_get_timings", "int", [
|
|
196
|
+
"void *",
|
|
197
|
+
iop(T.transcribe_timings),
|
|
198
|
+
]),
|
|
199
|
+
// langid role
|
|
200
|
+
langidInfoInit: lib.func("transcribe_langid_info_init", "void", [
|
|
201
|
+
outp(T.transcribe_langid_info),
|
|
202
|
+
]),
|
|
203
|
+
langidGetInfo: lib.func("transcribe_langid_get_info", "int", [
|
|
204
|
+
"void *",
|
|
205
|
+
iop(T.transcribe_langid_info),
|
|
206
|
+
]),
|
|
207
|
+
langidLabelCode: lib.func("transcribe_langid_label_code", "const char *", ["void *", "int32_t"]),
|
|
208
|
+
langidLabelName: lib.func("transcribe_langid_label_name", "const char *", ["void *", "int32_t"]),
|
|
209
|
+
langidLabelIndex: lib.func("transcribe_langid_label_index", "int32_t", ["void *", "const char *"]),
|
|
210
|
+
langidSessionParamsInit: lib.func("transcribe_langid_session_params_init", "void", [
|
|
211
|
+
outp(T.transcribe_langid_session_params),
|
|
212
|
+
]),
|
|
213
|
+
langidSessionInit: lib.func("transcribe_langid_session_init", "int", [
|
|
214
|
+
"void *",
|
|
215
|
+
inp(T.transcribe_langid_session_params),
|
|
216
|
+
handleOut,
|
|
217
|
+
]),
|
|
218
|
+
langidSessionFree: lib.func("transcribe_langid_session_free", "void", ["void *"]),
|
|
219
|
+
langidSetAbortCallback: lib.func("transcribe_langid_set_abort_callback", "void", [
|
|
220
|
+
"void *",
|
|
221
|
+
"void *",
|
|
222
|
+
"void *",
|
|
223
|
+
]),
|
|
224
|
+
langidParamsInit: lib.func("transcribe_langid_params_init", "void", [
|
|
225
|
+
outp(T.transcribe_langid_params),
|
|
226
|
+
]),
|
|
227
|
+
langidRun: lib.func("transcribe_langid_run", "int", [
|
|
228
|
+
"void *",
|
|
229
|
+
inp("float"),
|
|
230
|
+
"int",
|
|
231
|
+
inp(T.transcribe_langid_params),
|
|
232
|
+
]),
|
|
233
|
+
langidResultInit: lib.func("transcribe_langid_result_init", "void", [
|
|
234
|
+
outp(T.transcribe_langid_result),
|
|
235
|
+
]),
|
|
236
|
+
langidGetResult: lib.func("transcribe_langid_get_result", "int", [
|
|
237
|
+
"void *",
|
|
238
|
+
iop(T.transcribe_langid_result),
|
|
239
|
+
]),
|
|
240
|
+
langidCandidateInit: lib.func("transcribe_langid_candidate_init", "void", [
|
|
241
|
+
outp(T.transcribe_langid_candidate),
|
|
242
|
+
]),
|
|
243
|
+
langidGetCandidate: lib.func("transcribe_langid_get_candidate", "int", [
|
|
244
|
+
"void *",
|
|
245
|
+
"int",
|
|
246
|
+
iop(T.transcribe_langid_candidate),
|
|
247
|
+
]),
|
|
248
|
+
langidGetTimings: lib.func("transcribe_langid_get_timings", "int", [
|
|
249
|
+
"void *",
|
|
250
|
+
iop(T.transcribe_timings),
|
|
251
|
+
]),
|
|
252
|
+
// vad role
|
|
253
|
+
vadInfoInit: lib.func("transcribe_vad_info_init", "void", [outp(T.transcribe_vad_info)]),
|
|
254
|
+
vadGetInfo: lib.func("transcribe_vad_get_info", "int", [
|
|
255
|
+
"void *",
|
|
256
|
+
iop(T.transcribe_vad_info),
|
|
257
|
+
]),
|
|
258
|
+
vadSessionParamsInit: lib.func("transcribe_vad_session_params_init", "void", [
|
|
259
|
+
outp(T.transcribe_vad_session_params),
|
|
260
|
+
]),
|
|
261
|
+
vadSessionInit: lib.func("transcribe_vad_session_init", "int", [
|
|
262
|
+
"void *",
|
|
263
|
+
inp(T.transcribe_vad_session_params),
|
|
264
|
+
handleOut,
|
|
265
|
+
]),
|
|
266
|
+
vadSessionFree: lib.func("transcribe_vad_session_free", "void", ["void *"]),
|
|
267
|
+
vadSetAbortCallback: lib.func("transcribe_vad_set_abort_callback", "void", [
|
|
268
|
+
"void *",
|
|
269
|
+
"void *",
|
|
270
|
+
"void *",
|
|
271
|
+
]),
|
|
272
|
+
vadParamsInit: lib.func("transcribe_vad_params_init", "void", [outp(T.transcribe_vad_params)]),
|
|
273
|
+
vadRun: lib.func("transcribe_vad_run", "int", [
|
|
274
|
+
"void *",
|
|
275
|
+
inp("float"),
|
|
276
|
+
"int",
|
|
277
|
+
inp(T.transcribe_vad_params),
|
|
278
|
+
]),
|
|
279
|
+
vadStreamFeed: lib.func("transcribe_vad_stream_feed", "int", ["void *", inp("float"), "int"]),
|
|
280
|
+
vadStreamFlush: lib.func("transcribe_vad_stream_flush", "int", ["void *"]),
|
|
281
|
+
vadStreamReset: lib.func("transcribe_vad_stream_reset", "void", ["void *"]),
|
|
282
|
+
vadResultInit: lib.func("transcribe_vad_result_init", "void", [outp(T.transcribe_vad_result)]),
|
|
283
|
+
vadGetResult: lib.func("transcribe_vad_get_result", "int", [
|
|
284
|
+
"void *",
|
|
285
|
+
iop(T.transcribe_vad_result),
|
|
286
|
+
]),
|
|
287
|
+
// Session-owned; decoded (copied) before the compute lock is released.
|
|
288
|
+
vadProbs: lib.func("transcribe_vad_probs", "void *", ["void *"]),
|
|
289
|
+
vadSegmentInit: lib.func("transcribe_vad_segment_init", "void", [outp(T.transcribe_vad_segment)]),
|
|
290
|
+
vadGetSegment: lib.func("transcribe_vad_get_segment", "int", [
|
|
291
|
+
"void *",
|
|
292
|
+
"int",
|
|
293
|
+
iop(T.transcribe_vad_segment),
|
|
294
|
+
]),
|
|
295
|
+
vadGetTimings: lib.func("transcribe_vad_get_timings", "int", [
|
|
296
|
+
"void *",
|
|
297
|
+
iop(T.transcribe_timings),
|
|
156
298
|
]),
|
|
157
299
|
// batch (offline)
|
|
158
300
|
runBatch: lib.func("transcribe_run_batch", "int", [
|
package/dist/index.d.ts
CHANGED
|
@@ -5,12 +5,12 @@
|
|
|
5
5
|
* batch, streaming with committed/tentative text, typed per-family extensions,
|
|
6
6
|
* backend discovery, log routing, and cooperative cancellation.
|
|
7
7
|
*/
|
|
8
|
-
import { setLogHandler, type LogHandler } from "./native.js";
|
|
8
|
+
import { backendState, initialize, setLogHandler, type BackendState, type LogHandler } from "./native.js";
|
|
9
9
|
import { TranscribeError } from "./errors.js";
|
|
10
|
-
import type { Backend, BackendInfo, BatchItem, Capabilities, FamilyExtension, Feature, ModelOptions, PcmLike, SessionLimits, SessionOptions, StreamOptions, StreamState, StreamText, StreamUpdate, Transcript, TranscribeOptions, TranscriptionResult } from "./types.js";
|
|
10
|
+
import type { Backend, BackendInfo, BatchItem, Capabilities, DiarizeInfo, DiarizeOptions, DiarizeSessionOptions, FamilyExtension, Feature, LangIdInfo, LangIdOptions, LangIdResult, LangIdSessionOptions, ModelOptions, PcmLike, Role, SpeakerSegment, SessionLimits, SessionOptions, StreamOptions, StreamState, StreamText, StreamUpdate, Timings, Transcript, TranscribeOptions, TranscriptionResult, VadFeedOptions, VadInfo, VadOptions, VadResult, VadSessionOptions } from "./types.js";
|
|
11
11
|
export * from "./types.js";
|
|
12
12
|
export * from "./errors.js";
|
|
13
|
-
export { setLogHandler, type LogHandler };
|
|
13
|
+
export { backendState, initialize, setLogHandler, type BackendState, type LogHandler };
|
|
14
14
|
export declare function version(): {
|
|
15
15
|
version: string;
|
|
16
16
|
commit: string;
|
|
@@ -30,8 +30,20 @@ export declare function libraryPath(): string;
|
|
|
30
30
|
* `libraryPath()` returns the resolved library path of the *loaded* binding.
|
|
31
31
|
*/
|
|
32
32
|
export declare function artifactDir(): string;
|
|
33
|
+
/**
|
|
34
|
+
* Every registered compute device. Initializes backends on the calling thread
|
|
35
|
+
* if needed; throws `BackendInitializing` while {@link initialize} runs.
|
|
36
|
+
*/
|
|
33
37
|
export declare function getAvailableBackends(): BackendInfo[];
|
|
38
|
+
/** {@link getAvailableBackends} without blocking the event loop. */
|
|
39
|
+
export declare function getAvailableBackendsAsync(): Promise<BackendInfo[]>;
|
|
40
|
+
/**
|
|
41
|
+
* Whether some registered device can satisfy `backend`. Same initialization
|
|
42
|
+
* behavior as {@link getAvailableBackends}.
|
|
43
|
+
*/
|
|
34
44
|
export declare function backendAvailable(backend: Backend): boolean;
|
|
45
|
+
/** {@link backendAvailable} without blocking the event loop. */
|
|
46
|
+
export declare function backendAvailableAsync(backend: Backend): Promise<boolean>;
|
|
35
47
|
export declare class Session {
|
|
36
48
|
#private;
|
|
37
49
|
get limits(): SessionLimits;
|
|
@@ -79,13 +91,94 @@ export declare class Stream {
|
|
|
79
91
|
reset(): void;
|
|
80
92
|
[Symbol.dispose](): void;
|
|
81
93
|
}
|
|
94
|
+
/** A DIARIZE-role session: who spoke when. Same compute rules as Session. */
|
|
95
|
+
export declare class DiarizeSession {
|
|
96
|
+
#private;
|
|
97
|
+
/**
|
|
98
|
+
* Diarize one recording; returns its speaker turns, grouped by speaker and
|
|
99
|
+
* time-ordered within a speaker (turns of different speakers may overlap).
|
|
100
|
+
* The input PCM is borrowed, not copied (see Session.run).
|
|
101
|
+
*/
|
|
102
|
+
run(pcm: PcmLike, opts?: DiarizeOptions): Promise<SpeakerSegment[]>;
|
|
103
|
+
/** load_ms plus the last run's mel / encode time. */
|
|
104
|
+
get timings(): Timings;
|
|
105
|
+
dispose(): void;
|
|
106
|
+
[Symbol.dispose](): void;
|
|
107
|
+
}
|
|
108
|
+
/** A LANGID-role session: which language is spoken. Same compute rules as Session. */
|
|
109
|
+
export declare class LangIdSession {
|
|
110
|
+
#private;
|
|
111
|
+
/**
|
|
112
|
+
* Identify the language of one clip; input longer than langidInfo.maxAudioMs
|
|
113
|
+
* is scored on its first maxAudioMs. The input PCM is borrowed, not copied
|
|
114
|
+
* (see Session.run).
|
|
115
|
+
*/
|
|
116
|
+
run(pcm: PcmLike, opts?: LangIdOptions): Promise<LangIdResult>;
|
|
117
|
+
/** load_ms plus the last run's mel / encode time. */
|
|
118
|
+
get timings(): Timings;
|
|
119
|
+
dispose(): void;
|
|
120
|
+
[Symbol.dispose](): void;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* A VAD-role session: where there is speech. Same compute rules as Session,
|
|
124
|
+
* except a VAD stream is session state and does not take the stream lease.
|
|
125
|
+
*/
|
|
126
|
+
export declare class VadSession {
|
|
127
|
+
#private;
|
|
128
|
+
/**
|
|
129
|
+
* Score one clip from a fresh state and segment it (resets any stream in
|
|
130
|
+
* progress). The input PCM is borrowed, not copied (see Session.run).
|
|
131
|
+
*/
|
|
132
|
+
run(pcm: PcmLike, opts?: VadOptions): Promise<VadResult>;
|
|
133
|
+
/**
|
|
134
|
+
* Append audio to the stream and score every frame it completes; returns
|
|
135
|
+
* those frames' probabilities (a partial frame waits for the next feed).
|
|
136
|
+
* The chunk is borrowed, not copied (see Stream.feed); an empty chunk scores
|
|
137
|
+
* nothing. An abort or processing error resets the stream (the next feed's
|
|
138
|
+
* firstFrame is 0); invalid input leaves it unchanged.
|
|
139
|
+
*/
|
|
140
|
+
streamFeed(pcm: PcmLike, opts?: VadFeedOptions): Promise<VadResult>;
|
|
141
|
+
/**
|
|
142
|
+
* End the stream: score the buffered partial frame (zero padded) and reset,
|
|
143
|
+
* so the next feed's firstFrame is 0. A processing error also resets it.
|
|
144
|
+
*/
|
|
145
|
+
streamFlush(opts?: VadFeedOptions): Promise<VadResult>;
|
|
146
|
+
/**
|
|
147
|
+
* Drop the stream without scoring (the next feed's firstFrame is 0); queued
|
|
148
|
+
* behind any in-flight call.
|
|
149
|
+
*/
|
|
150
|
+
streamReset(): Promise<void>;
|
|
151
|
+
/** load_ms plus the last call's encode / decode time. */
|
|
152
|
+
get timings(): Timings;
|
|
153
|
+
dispose(): void;
|
|
154
|
+
[Symbol.dispose](): void;
|
|
155
|
+
}
|
|
82
156
|
export declare class TranscribeModel {
|
|
83
157
|
#private;
|
|
84
158
|
private constructor();
|
|
159
|
+
/** Load a GGUF model. Awaits {@link initialize}, so it never blocks the event loop. */
|
|
85
160
|
static load(path: string, opts?: ModelOptions): Promise<TranscribeModel>;
|
|
86
161
|
createSession(opts?: SessionOptions): Session;
|
|
87
162
|
/** Convenience: one session, one run, disposed after. */
|
|
88
163
|
transcribe(pcm: PcmLike, opts?: TranscribeOptions): Promise<TranscriptionResult>;
|
|
164
|
+
/** The roles this model serves; ASR calls on a model without "asr" throw UnsupportedRole. */
|
|
165
|
+
get roles(): readonly Role[];
|
|
166
|
+
/** Static facts of a "diarize" model; UnsupportedRole otherwise. */
|
|
167
|
+
get diarizeInfo(): DiarizeInfo;
|
|
168
|
+
/** Open a DIARIZE-role session; UnsupportedRole on a model without "diarize". */
|
|
169
|
+
createDiarizeSession(opts?: DiarizeSessionOptions): DiarizeSession;
|
|
170
|
+
/** Static facts of a "langid" model; UnsupportedRole otherwise. */
|
|
171
|
+
get langidInfo(): LangIdInfo;
|
|
172
|
+
/** [code, name] per label index of a "langid" model; UnsupportedRole otherwise. */
|
|
173
|
+
get langidLabels(): Array<[string, string]>;
|
|
174
|
+
/** Label index of a code or alias ("he" and "iw" name the same label), or null. */
|
|
175
|
+
langidLabelIndex(code: string): number | null;
|
|
176
|
+
/** Open a LANGID-role session; UnsupportedRole on a model without "langid". */
|
|
177
|
+
createLangIdSession(opts?: LangIdSessionOptions): LangIdSession;
|
|
178
|
+
/** Static facts of a "vad" model; UnsupportedRole otherwise. */
|
|
179
|
+
get vadInfo(): VadInfo;
|
|
180
|
+
/** Open a VAD-role session; UnsupportedRole on a model without "vad". */
|
|
181
|
+
createVadSession(opts?: VadSessionOptions): VadSession;
|
|
89
182
|
get capabilities(): Capabilities;
|
|
90
183
|
supports(feature: Feature): boolean;
|
|
91
184
|
/** Whether this model accepts the given family extension on its slot. */
|