transcribe-cpp 0.0.4 → 0.0.5
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 +41 -2
- package/dist/index.d.ts +13 -0
- package/dist/index.js +16 -0
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -200,6 +200,45 @@ N-API addon, so `cmake-js` does not apply) and installs into `prebuilds/<tuple>/
|
|
|
200
200
|
which the loader finds automatically. Requires `cmake` and a C/C++ toolchain.
|
|
201
201
|
You can also point `TRANSCRIBE_LIBRARY` at any `libtranscribe` you built.
|
|
202
202
|
|
|
203
|
+
## Packaging an app (Electron / Tauri)
|
|
204
|
+
|
|
205
|
+
The native code ships as a self-contained `@transcribe-cpp/<platform>` package
|
|
206
|
+
(the shared library plus its sibling ggml libs / backend modules, in one
|
|
207
|
+
directory). Because npm resolution is transitive, your app can locate that
|
|
208
|
+
directory at *build* time — there is nothing special to wire through.
|
|
209
|
+
`artifactDir()` returns it **without loading the library** (no dlopen), which is
|
|
210
|
+
exactly what a bundler/pack step needs:
|
|
211
|
+
|
|
212
|
+
```js
|
|
213
|
+
import { artifactDir } from "transcribe-cpp";
|
|
214
|
+
import * as fs from "node:fs";
|
|
215
|
+
|
|
216
|
+
const dir = artifactDir();
|
|
217
|
+
const lib =
|
|
218
|
+
process.platform === "win32" ? "transcribe.dll"
|
|
219
|
+
: process.platform === "darwin" ? "libtranscribe.dylib"
|
|
220
|
+
: "libtranscribe.so";
|
|
221
|
+
|
|
222
|
+
// HARD-FAIL if the artifact is missing/empty: better to break the build than
|
|
223
|
+
// ship a silently broken installer that crashes at first transcribe() call.
|
|
224
|
+
if (!fs.existsSync(`${dir}/${lib}`)) {
|
|
225
|
+
throw new Error(`native library not found in ${dir}; the platform package is not bundled`);
|
|
226
|
+
}
|
|
227
|
+
// copy `dir` into your app resources, or feed it to your bundler config…
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
The native files are real binaries, so they must not be packed into an asar
|
|
231
|
+
archive. With **electron-builder**, unpack the platform packages:
|
|
232
|
+
|
|
233
|
+
```jsonc
|
|
234
|
+
// package.json → "build"
|
|
235
|
+
{ "asarUnpack": ["node_modules/@transcribe-cpp/**"] }
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
For a **Tauri** app whose native bits come from the Rust crate instead, see that
|
|
239
|
+
crate's "Packaging a distributable" section — there the artifact dir is exposed
|
|
240
|
+
to your `build.rs` as `DEP_TRANSCRIBE_CPP_RUNTIME_DIR`.
|
|
241
|
+
|
|
203
242
|
## Waived requirements
|
|
204
243
|
|
|
205
244
|
- **Per-field ABI layout is not waived** (unlike Rust/Swift): TypeScript has no
|
|
@@ -211,5 +250,5 @@ You can also point `TRANSCRIBE_LIBRARY` at any `libtranscribe` you built.
|
|
|
211
250
|
|
|
212
251
|
## License
|
|
213
252
|
|
|
214
|
-
MIT. Bundled native packages include third-party license texts (ggml
|
|
215
|
-
bundled backend runtimes).
|
|
253
|
+
MIT. Bundled native packages include third-party license texts (ggml, miniz,
|
|
254
|
+
and any bundled backend runtimes).
|
package/dist/index.d.ts
CHANGED
|
@@ -17,6 +17,19 @@ export declare function version(): {
|
|
|
17
17
|
headerHash: string;
|
|
18
18
|
};
|
|
19
19
|
export declare function libraryPath(): string;
|
|
20
|
+
/**
|
|
21
|
+
* The directory holding the native library and its sibling ggml libs / backend
|
|
22
|
+
* modules — resolved WITHOUT loading the library (no dlopen, no ABI check, no
|
|
23
|
+
* backend init), unlike every other entry point here.
|
|
24
|
+
*
|
|
25
|
+
* This is the build/packaging hook: call it from a bundler config or pack step
|
|
26
|
+
* to copy the native artifacts into your installer (Electron `asarUnpack`, Tauri
|
|
27
|
+
* `resources`, etc.). Resolution follows the same order as the runtime loader
|
|
28
|
+
* (`TRANSCRIBE_LIBRARY` → the `@transcribe-cpp/<platform>` package → a local
|
|
29
|
+
* prebuild → the dev tree) and throws if nothing is found. For runtime use,
|
|
30
|
+
* `libraryPath()` returns the resolved library path of the *loaded* binding.
|
|
31
|
+
*/
|
|
32
|
+
export declare function artifactDir(): string;
|
|
20
33
|
export declare function getAvailableBackends(): BackendInfo[];
|
|
21
34
|
export declare function backendAvailable(backend: Backend): boolean;
|
|
22
35
|
export declare class Session {
|
package/dist/index.js
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
* backend discovery, log routing, and cooperative cancellation.
|
|
7
7
|
*/
|
|
8
8
|
import { native, setLogHandler } from "./native.js";
|
|
9
|
+
import { resolveLibrary } from "./loader.js";
|
|
9
10
|
import * as g from "./_generated.js";
|
|
10
11
|
import { Aborted, Busy, exceptionForStatus, InvalidArgument, ModelLoadError, NotImplementedByModel, OutputTruncated, TranscribeError, UnsupportedRequest, } from "./errors.js";
|
|
11
12
|
export * from "./types.js";
|
|
@@ -216,6 +217,21 @@ export function version() {
|
|
|
216
217
|
export function libraryPath() {
|
|
217
218
|
return native().libraryPath;
|
|
218
219
|
}
|
|
220
|
+
/**
|
|
221
|
+
* The directory holding the native library and its sibling ggml libs / backend
|
|
222
|
+
* modules — resolved WITHOUT loading the library (no dlopen, no ABI check, no
|
|
223
|
+
* backend init), unlike every other entry point here.
|
|
224
|
+
*
|
|
225
|
+
* This is the build/packaging hook: call it from a bundler config or pack step
|
|
226
|
+
* to copy the native artifacts into your installer (Electron `asarUnpack`, Tauri
|
|
227
|
+
* `resources`, etc.). Resolution follows the same order as the runtime loader
|
|
228
|
+
* (`TRANSCRIBE_LIBRARY` → the `@transcribe-cpp/<platform>` package → a local
|
|
229
|
+
* prebuild → the dev tree) and throws if nothing is found. For runtime use,
|
|
230
|
+
* `libraryPath()` returns the resolved library path of the *loaded* binding.
|
|
231
|
+
*/
|
|
232
|
+
export function artifactDir() {
|
|
233
|
+
return resolveLibrary().artifactDir;
|
|
234
|
+
}
|
|
219
235
|
const DEVICE_TYPE_NAMES = {
|
|
220
236
|
[g.TRANSCRIBE_DEVICE_TYPE_CPU]: "cpu",
|
|
221
237
|
[g.TRANSCRIBE_DEVICE_TYPE_GPU]: "gpu",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "transcribe-cpp",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.5",
|
|
4
4
|
"description": "TypeScript/Node.js bindings for transcribe.cpp — a C/C++ speech-to-text library built on ggml",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -51,11 +51,11 @@
|
|
|
51
51
|
"koffi": "^3.0.2"
|
|
52
52
|
},
|
|
53
53
|
"optionalDependencies": {
|
|
54
|
-
"@transcribe-cpp/darwin-arm64-metal": "0.0.
|
|
55
|
-
"@transcribe-cpp/darwin-x64-cpu": "0.0.
|
|
56
|
-
"@transcribe-cpp/linux-x64-cpu-vulkan": "0.0.
|
|
57
|
-
"@transcribe-cpp/linux-arm64-cpu-vulkan": "0.0.
|
|
58
|
-
"@transcribe-cpp/win32-x64-cpu-vulkan": "0.0.
|
|
54
|
+
"@transcribe-cpp/darwin-arm64-metal": "0.0.5",
|
|
55
|
+
"@transcribe-cpp/darwin-x64-cpu": "0.0.5",
|
|
56
|
+
"@transcribe-cpp/linux-x64-cpu-vulkan": "0.0.5",
|
|
57
|
+
"@transcribe-cpp/linux-arm64-cpu-vulkan": "0.0.5",
|
|
58
|
+
"@transcribe-cpp/win32-x64-cpu-vulkan": "0.0.5"
|
|
59
59
|
},
|
|
60
60
|
"devDependencies": {
|
|
61
61
|
"@types/node": "^22.0.0",
|