parakeet.ts 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +286 -0
- package/dist/alignment.d.ts +36 -0
- package/dist/alignment.d.ts.map +1 -0
- package/dist/alignment.js +202 -0
- package/dist/alignment.js.map +1 -0
- package/dist/audio.d.ts +59 -0
- package/dist/audio.d.ts.map +1 -0
- package/dist/audio.js +324 -0
- package/dist/audio.js.map +1 -0
- package/dist/backend.d.ts +61 -0
- package/dist/backend.d.ts.map +1 -0
- package/dist/backend.js +14 -0
- package/dist/backend.js.map +1 -0
- package/dist/decode.d.ts +38 -0
- package/dist/decode.d.ts.map +1 -0
- package/dist/decode.js +124 -0
- package/dist/decode.js.map +1 -0
- package/dist/hub.d.ts +18 -0
- package/dist/hub.d.ts.map +1 -0
- package/dist/hub.js +86 -0
- package/dist/hub.js.map +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +19 -0
- package/dist/index.js.map +1 -0
- package/dist/load.d.ts +51 -0
- package/dist/load.d.ts.map +1 -0
- package/dist/load.js +34 -0
- package/dist/load.js.map +1 -0
- package/dist/mlx/attention.d.ts +61 -0
- package/dist/mlx/attention.d.ts.map +1 -0
- package/dist/mlx/attention.js +330 -0
- package/dist/mlx/attention.js.map +1 -0
- package/dist/mlx/audio.d.ts +46 -0
- package/dist/mlx/audio.d.ts.map +1 -0
- package/dist/mlx/audio.js +309 -0
- package/dist/mlx/audio.js.map +1 -0
- package/dist/mlx/backend.d.ts +22 -0
- package/dist/mlx/backend.d.ts.map +1 -0
- package/dist/mlx/backend.js +67 -0
- package/dist/mlx/backend.js.map +1 -0
- package/dist/mlx/cache.d.ts +23 -0
- package/dist/mlx/cache.d.ts.map +1 -0
- package/dist/mlx/cache.js +98 -0
- package/dist/mlx/cache.js.map +1 -0
- package/dist/mlx/cli.d.ts +12 -0
- package/dist/mlx/cli.d.ts.map +1 -0
- package/dist/mlx/cli.js +145 -0
- package/dist/mlx/cli.js.map +1 -0
- package/dist/mlx/conformer.d.ts +81 -0
- package/dist/mlx/conformer.d.ts.map +1 -0
- package/dist/mlx/conformer.js +315 -0
- package/dist/mlx/conformer.js.map +1 -0
- package/dist/mlx/index.d.ts +6 -0
- package/dist/mlx/index.d.ts.map +1 -0
- package/dist/mlx/index.js +9 -0
- package/dist/mlx/index.js.map +1 -0
- package/dist/mlx/load.d.ts +27 -0
- package/dist/mlx/load.d.ts.map +1 -0
- package/dist/mlx/load.js +161 -0
- package/dist/mlx/load.js.map +1 -0
- package/dist/mlx/nn.d.ts +121 -0
- package/dist/mlx/nn.d.ts.map +1 -0
- package/dist/mlx/nn.js +511 -0
- package/dist/mlx/nn.js.map +1 -0
- package/dist/mlx/rnnt.d.ts +59 -0
- package/dist/mlx/rnnt.d.ts.map +1 -0
- package/dist/mlx/rnnt.js +233 -0
- package/dist/mlx/rnnt.js.map +1 -0
- package/dist/mlx/server.d.ts +34 -0
- package/dist/mlx/server.d.ts.map +1 -0
- package/dist/mlx/server.js +115 -0
- package/dist/mlx/server.js.map +1 -0
- package/dist/mlx/utils.d.ts +19 -0
- package/dist/mlx/utils.d.ts.map +1 -0
- package/dist/mlx/utils.js +103 -0
- package/dist/mlx/utils.js.map +1 -0
- package/dist/model.d.ts +112 -0
- package/dist/model.d.ts.map +1 -0
- package/dist/model.js +196 -0
- package/dist/model.js.map +1 -0
- package/dist/onnx/backend.d.ts +55 -0
- package/dist/onnx/backend.d.ts.map +1 -0
- package/dist/onnx/backend.js +111 -0
- package/dist/onnx/backend.js.map +1 -0
- package/dist/onnx/index.d.ts +7 -0
- package/dist/onnx/index.d.ts.map +1 -0
- package/dist/onnx/index.js +6 -0
- package/dist/onnx/index.js.map +1 -0
- package/dist/onnx/parakeet.d.ts +44 -0
- package/dist/onnx/parakeet.d.ts.map +1 -0
- package/dist/onnx/parakeet.js +135 -0
- package/dist/onnx/parakeet.js.map +1 -0
- package/dist/tokenizer.d.ts +6 -0
- package/dist/tokenizer.d.ts.map +1 -0
- package/dist/tokenizer.js +8 -0
- package/dist/tokenizer.js.map +1 -0
- package/package.json +85 -0
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { ExecutionProvider } from './backend.js';
|
|
2
|
+
import { ParakeetModel } from '../model.js';
|
|
3
|
+
export interface OnnxModelOptions {
|
|
4
|
+
executionProvider?: ExecutionProvider;
|
|
5
|
+
/**
|
|
6
|
+
* Execution provider for the autoregressive decode step. Defaults to the same
|
|
7
|
+
* as `executionProvider`; 'cpu' is a reasonable alternative since the step is
|
|
8
|
+
* small and CPU avoids per-step device round trips.
|
|
9
|
+
*/
|
|
10
|
+
decoderExecutionProvider?: ExecutionProvider;
|
|
11
|
+
/**
|
|
12
|
+
* 'interpolated' (default) matches NVIDIA's reference preprocessor.
|
|
13
|
+
* 'floor' reproduces parakeet-mlx's filterbank, which collapses 13 of 128 mel
|
|
14
|
+
* bins to zero — see docs/cuda.md.
|
|
15
|
+
*/
|
|
16
|
+
filterbank?: 'floor' | 'interpolated';
|
|
17
|
+
logSeverityLevel?: number;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Load an ONNX Parakeet model from a directory of exported graphs.
|
|
21
|
+
*
|
|
22
|
+
* Expected contents:
|
|
23
|
+
* encoder-model.onnx (+ encoder-model.onnx.data for external weights)
|
|
24
|
+
* decoder_joint-model.onnx
|
|
25
|
+
* vocab.txt (or config.json with joint.vocabulary)
|
|
26
|
+
* config.json (optional; a full NeMo config supplies preprocessor settings)
|
|
27
|
+
*/
|
|
28
|
+
export declare function fromLocal(dir: string, options?: OnnxModelOptions): Promise<ParakeetModel>;
|
|
29
|
+
/** Default ONNX export on the Hub, matching the checkpoint the MLX path loads. */
|
|
30
|
+
export declare const DEFAULT_ONNX_REPO = "istupakov/parakeet-tdt-0.6b-v3-onnx";
|
|
31
|
+
export interface OnnxPretrainedOptions extends OnnxModelOptions {
|
|
32
|
+
/** Override the HF cache root. */
|
|
33
|
+
cacheDir?: string;
|
|
34
|
+
/** Called as each file downloads. */
|
|
35
|
+
onProgress?: (file: string, downloaded: number, total: number) => void;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Load an ONNX Parakeet model, downloading it from the HuggingFace Hub on first
|
|
39
|
+
* use and caching it under the standard HF cache directory.
|
|
40
|
+
*
|
|
41
|
+
* `hfIdOrPath` may also be a local directory, in which case it is used as-is.
|
|
42
|
+
*/
|
|
43
|
+
export declare function fromPretrained(hfIdOrPath?: string, options?: OnnxPretrainedOptions): Promise<ParakeetModel>;
|
|
44
|
+
//# sourceMappingURL=parakeet.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parakeet.d.ts","sourceRoot":"","sources":["../../src/onnx/parakeet.ts"],"names":[],"mappings":"AAQA,OAAO,EAAmC,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAClF,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAI5C,MAAM,WAAW,gBAAgB;IAC/B,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;IACtC;;;;OAIG;IACH,wBAAwB,CAAC,EAAE,iBAAiB,CAAC;IAC7C;;;;OAIG;IACH,UAAU,CAAC,EAAE,OAAO,GAAG,cAAc,CAAC;IACtC,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAqCD;;;;;;;;GAQG;AACH,wBAAsB,SAAS,CAC7B,GAAG,EAAE,MAAM,EACX,OAAO,GAAE,gBAAqB,GAC7B,OAAO,CAAC,aAAa,CAAC,CAkExB;AAED,kFAAkF;AAClF,eAAO,MAAM,iBAAiB,wCAAwC,CAAC;AAEvE,MAAM,WAAW,qBAAsB,SAAQ,gBAAgB;IAC7D,kCAAkC;IAClC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,qCAAqC;IACrC,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACxE;AAED;;;;;GAKG;AACH,wBAAsB,cAAc,CAClC,UAAU,GAAE,MAA0B,EACtC,OAAO,GAAE,qBAA0B,GAClC,OAAO,CAAC,aAAa,CAAC,CAoBxB"}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Loading ONNX-exported Parakeet models.
|
|
3
|
+
*
|
|
4
|
+
* The model class itself is backend-agnostic (`ParakeetModel`); this file only
|
|
5
|
+
* knows how to find the exported graphs and read the checkpoint metadata.
|
|
6
|
+
*/
|
|
7
|
+
import fs from 'node:fs';
|
|
8
|
+
import path from 'node:path';
|
|
9
|
+
import { OnnxBackend } from './backend.js';
|
|
10
|
+
import { ParakeetModel } from '../model.js';
|
|
11
|
+
import { makePreprocessArgs } from '../audio.js';
|
|
12
|
+
import { downloadRepoFiles } from '../hub.js';
|
|
13
|
+
const DEFAULTS = {
|
|
14
|
+
sampleRate: 16000,
|
|
15
|
+
normalize: 'per_feature',
|
|
16
|
+
windowSize: 0.025,
|
|
17
|
+
windowStride: 0.01,
|
|
18
|
+
window: 'hann',
|
|
19
|
+
features: 128,
|
|
20
|
+
nFft: 512,
|
|
21
|
+
dither: 0,
|
|
22
|
+
preemph: 0.97,
|
|
23
|
+
magPower: 2.0,
|
|
24
|
+
subsamplingFactor: 8,
|
|
25
|
+
durations: [0, 1, 2, 3, 4],
|
|
26
|
+
maxSymbols: 10,
|
|
27
|
+
};
|
|
28
|
+
function readVocabulary(dir, config) {
|
|
29
|
+
const vocabPath = path.join(dir, 'vocab.txt');
|
|
30
|
+
if (fs.existsSync(vocabPath)) {
|
|
31
|
+
// lines are "<token> <id>"; the final entry is the blank symbol, which we
|
|
32
|
+
// drop so that `vocabulary.length` equals the blank id
|
|
33
|
+
const lines = fs.readFileSync(vocabPath, 'utf8').split('\n').filter(l => l.length > 0);
|
|
34
|
+
const tokens = lines.map(l => {
|
|
35
|
+
const sp = l.lastIndexOf(' ');
|
|
36
|
+
return sp === -1 ? l : l.slice(0, sp);
|
|
37
|
+
});
|
|
38
|
+
return tokens.slice(0, -1);
|
|
39
|
+
}
|
|
40
|
+
const joint = config['joint'];
|
|
41
|
+
if (joint?.['vocabulary'])
|
|
42
|
+
return joint['vocabulary'];
|
|
43
|
+
throw new Error(`No vocabulary found: expected vocab.txt in ${dir} or joint.vocabulary in config.json`);
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Load an ONNX Parakeet model from a directory of exported graphs.
|
|
47
|
+
*
|
|
48
|
+
* Expected contents:
|
|
49
|
+
* encoder-model.onnx (+ encoder-model.onnx.data for external weights)
|
|
50
|
+
* decoder_joint-model.onnx
|
|
51
|
+
* vocab.txt (or config.json with joint.vocabulary)
|
|
52
|
+
* config.json (optional; a full NeMo config supplies preprocessor settings)
|
|
53
|
+
*/
|
|
54
|
+
export async function fromLocal(dir, options = {}) {
|
|
55
|
+
const pick = (...names) => {
|
|
56
|
+
for (const n of names) {
|
|
57
|
+
const p = path.join(dir, n);
|
|
58
|
+
if (fs.existsSync(p))
|
|
59
|
+
return p;
|
|
60
|
+
}
|
|
61
|
+
throw new Error(`None of ${names.join(', ')} found in ${dir}`);
|
|
62
|
+
};
|
|
63
|
+
const encoderPath = pick('encoder-model.onnx', 'encoder.onnx');
|
|
64
|
+
const decoderJointPath = pick('decoder_joint-model.onnx', 'decoder_joint.onnx');
|
|
65
|
+
const configPath = path.join(dir, 'config.json');
|
|
66
|
+
const config = fs.existsSync(configPath)
|
|
67
|
+
? JSON.parse(fs.readFileSync(configPath, 'utf8'))
|
|
68
|
+
: {};
|
|
69
|
+
const pre = config['preprocessor'] ?? {};
|
|
70
|
+
const preprocessor = makePreprocessArgs({
|
|
71
|
+
sampleRate: pre['sample_rate'] ?? DEFAULTS.sampleRate,
|
|
72
|
+
normalize: pre['normalize'] ?? DEFAULTS.normalize,
|
|
73
|
+
windowSize: pre['window_size'] ?? DEFAULTS.windowSize,
|
|
74
|
+
windowStride: pre['window_stride'] ?? DEFAULTS.windowStride,
|
|
75
|
+
window: pre['window'] ?? DEFAULTS.window,
|
|
76
|
+
features: pre['features']
|
|
77
|
+
?? config['features_size']
|
|
78
|
+
?? DEFAULTS.features,
|
|
79
|
+
nFft: pre['n_fft'] ?? DEFAULTS.nFft,
|
|
80
|
+
dither: pre['dither'] ?? DEFAULTS.dither,
|
|
81
|
+
padTo: pre['pad_to'] ?? 0,
|
|
82
|
+
padValue: pre['pad_value'] ?? 0,
|
|
83
|
+
preemph: pre['preemph'] !== undefined ? pre['preemph'] : DEFAULTS.preemph,
|
|
84
|
+
magPower: pre['mag_power'] ?? DEFAULTS.magPower,
|
|
85
|
+
filterbank: options.filterbank ?? 'interpolated',
|
|
86
|
+
});
|
|
87
|
+
const vocabulary = readVocabulary(dir, config);
|
|
88
|
+
const modelDefaults = config['model_defaults'] ?? {};
|
|
89
|
+
const decoding = config['decoding'] ?? {};
|
|
90
|
+
const modelType = config['model_type'] ?? decoding['model_type'] ?? 'tdt';
|
|
91
|
+
const durations = modelDefaults['tdt_durations']
|
|
92
|
+
?? (modelType.includes('tdt') ? DEFAULTS.durations : null);
|
|
93
|
+
const greedy = decoding['greedy'];
|
|
94
|
+
const maxSymbols = greedy?.['max_symbols'] != null
|
|
95
|
+
? Number(greedy['max_symbols'])
|
|
96
|
+
: DEFAULTS.maxSymbols;
|
|
97
|
+
const subsamplingFactor = config['subsampling_factor']
|
|
98
|
+
?? config['encoder']?.['subsampling_factor']
|
|
99
|
+
?? DEFAULTS.subsamplingFactor;
|
|
100
|
+
const backendOpts = {
|
|
101
|
+
encoderPath,
|
|
102
|
+
decoderJointPath,
|
|
103
|
+
executionProvider: options.executionProvider,
|
|
104
|
+
decoderExecutionProvider: options.decoderExecutionProvider,
|
|
105
|
+
logSeverityLevel: options.logSeverityLevel,
|
|
106
|
+
};
|
|
107
|
+
const backend = await OnnxBackend.create(backendOpts);
|
|
108
|
+
backend.blankId = vocabulary.length;
|
|
109
|
+
return new ParakeetModel({
|
|
110
|
+
backend, preprocessor, vocabulary, durations, maxSymbols, subsamplingFactor,
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
/** Default ONNX export on the Hub, matching the checkpoint the MLX path loads. */
|
|
114
|
+
export const DEFAULT_ONNX_REPO = 'istupakov/parakeet-tdt-0.6b-v3-onnx';
|
|
115
|
+
/**
|
|
116
|
+
* Load an ONNX Parakeet model, downloading it from the HuggingFace Hub on first
|
|
117
|
+
* use and caching it under the standard HF cache directory.
|
|
118
|
+
*
|
|
119
|
+
* `hfIdOrPath` may also be a local directory, in which case it is used as-is.
|
|
120
|
+
*/
|
|
121
|
+
export async function fromPretrained(hfIdOrPath = DEFAULT_ONNX_REPO, options = {}) {
|
|
122
|
+
if (fs.existsSync(hfIdOrPath) && fs.statSync(hfIdOrPath).isDirectory()) {
|
|
123
|
+
return fromLocal(hfIdOrPath, options);
|
|
124
|
+
}
|
|
125
|
+
const dir = await downloadRepoFiles(hfIdOrPath, [
|
|
126
|
+
{ name: 'encoder-model.onnx' },
|
|
127
|
+
// external weights: required for this export, absent for self-contained ones
|
|
128
|
+
{ name: 'encoder-model.onnx.data', optional: true },
|
|
129
|
+
{ name: 'decoder_joint-model.onnx' },
|
|
130
|
+
{ name: 'vocab.txt' },
|
|
131
|
+
{ name: 'config.json', optional: true },
|
|
132
|
+
], options.cacheDir, options.onProgress);
|
|
133
|
+
return fromLocal(dir, options);
|
|
134
|
+
}
|
|
135
|
+
//# sourceMappingURL=parakeet.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parakeet.js","sourceRoot":"","sources":["../../src/onnx/parakeet.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,WAAW,EAAyC,MAAM,cAAc,CAAC;AAClF,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C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AE,CAAC,UAAU,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC;QACvE,OAAO,SAAS,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;IACxC,CAAC;IAED,MAAM,GAAG,GAAG,MAAM,iBAAiB,CACjC,UAAU,EACV;QACE,EAAE,IAAI,EAAE,oBAAoB,EAAE;QAC9B,6EAA6E;QAC7E,EAAE,IAAI,EAAE,yBAAyB,EAAE,QAAQ,EAAE,IAAI,EAAE;QACnD,EAAE,IAAI,EAAE,0BAA0B,EAAE;QACpC,EAAE,IAAI,EAAE,WAAW,EAAE;QACrB,EAAE,IAAI,EAAE,aAAa,EAAE,QAAQ,EAAE,IAAI,EAAE;KACxC,EACD,OAAO,CAAC,QAAQ,EAChB,OAAO,CAAC,UAAU,CACnB,CAAC;IAEF,OAAO,SAAS,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;AACjC,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Decode a list of token IDs to a string using the vocabulary.
|
|
3
|
+
* The vocabulary uses '▁' as a word-boundary prefix (SentencePiece convention).
|
|
4
|
+
*/
|
|
5
|
+
export declare function decode(tokens: number[], vocabulary: string[]): string;
|
|
6
|
+
//# sourceMappingURL=tokenizer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tokenizer.d.ts","sourceRoot":"","sources":["../src/tokenizer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,wBAAgB,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,UAAU,EAAE,MAAM,EAAE,GAAG,MAAM,CAErE"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Decode a list of token IDs to a string using the vocabulary.
|
|
3
|
+
* The vocabulary uses '▁' as a word-boundary prefix (SentencePiece convention).
|
|
4
|
+
*/
|
|
5
|
+
export function decode(tokens, vocabulary) {
|
|
6
|
+
return tokens.map(id => vocabulary[id].replace(/▁/g, ' ')).join('');
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=tokenizer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tokenizer.js","sourceRoot":"","sources":["../src/tokenizer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,UAAU,MAAM,CAAC,MAAgB,EAAE,UAAoB;IAC3D,OAAO,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AACtE,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "parakeet.ts",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "TypeScript runtime for Nvidia Parakeet ASR models (community port, not affiliated with NVIDIA)",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"apple-silicon",
|
|
8
|
+
"asr",
|
|
9
|
+
"cuda",
|
|
10
|
+
"gpu",
|
|
11
|
+
"mlx",
|
|
12
|
+
"nvidia",
|
|
13
|
+
"onnx",
|
|
14
|
+
"onnxruntime",
|
|
15
|
+
"parakeet",
|
|
16
|
+
"speech-recognition",
|
|
17
|
+
"transcription",
|
|
18
|
+
"whisper-alternative"
|
|
19
|
+
],
|
|
20
|
+
"type": "module",
|
|
21
|
+
"main": "dist/index.js",
|
|
22
|
+
"types": "dist/index.d.ts",
|
|
23
|
+
"bin": {
|
|
24
|
+
"parakeet": "./dist/mlx/cli.js"
|
|
25
|
+
},
|
|
26
|
+
"files": [
|
|
27
|
+
"dist",
|
|
28
|
+
"README.md",
|
|
29
|
+
"LICENSE"
|
|
30
|
+
],
|
|
31
|
+
"exports": {
|
|
32
|
+
".": {
|
|
33
|
+
"import": "./dist/index.js",
|
|
34
|
+
"types": "./dist/index.d.ts"
|
|
35
|
+
},
|
|
36
|
+
"./mlx": {
|
|
37
|
+
"import": "./dist/mlx/index.js",
|
|
38
|
+
"types": "./dist/mlx/index.d.ts"
|
|
39
|
+
},
|
|
40
|
+
"./mlx/server": {
|
|
41
|
+
"import": "./dist/mlx/server.js",
|
|
42
|
+
"types": "./dist/mlx/server.d.ts"
|
|
43
|
+
},
|
|
44
|
+
"./onnx": {
|
|
45
|
+
"import": "./dist/onnx/index.js",
|
|
46
|
+
"types": "./dist/onnx/index.d.ts"
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
"scripts": {
|
|
50
|
+
"build": "tsc && chmod +x dist/mlx/cli.js",
|
|
51
|
+
"dev": "tsc --watch",
|
|
52
|
+
"prepublishOnly": "npm run build",
|
|
53
|
+
"test": "vitest run test/integration",
|
|
54
|
+
"test:mac": "PARAKEET_BACKEND=mlx vitest run test/integration",
|
|
55
|
+
"test:linux": "PARAKEET_BACKEND=onnx vitest run test/integration --no-file-parallelism"
|
|
56
|
+
},
|
|
57
|
+
"dependencies": {
|
|
58
|
+
"@mlx-node/core": "^0.0.7"
|
|
59
|
+
},
|
|
60
|
+
"peerDependencies": {
|
|
61
|
+
"hono": "^4"
|
|
62
|
+
},
|
|
63
|
+
"peerDependenciesMeta": {
|
|
64
|
+
"hono": {
|
|
65
|
+
"optional": true
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
"devDependencies": {
|
|
69
|
+
"@types/node": "^22.0.0",
|
|
70
|
+
"hono": "^4.12.18",
|
|
71
|
+
"typescript": "^5.5.0",
|
|
72
|
+
"vitest": "^4.1.5"
|
|
73
|
+
},
|
|
74
|
+
"engines": {
|
|
75
|
+
"node": ">=18.11.0"
|
|
76
|
+
},
|
|
77
|
+
"optionalDependencies": {
|
|
78
|
+
"onnxruntime-node": "^1.27.0"
|
|
79
|
+
},
|
|
80
|
+
"pnpm": {
|
|
81
|
+
"onlyBuiltDependencies": [
|
|
82
|
+
"onnxruntime-node"
|
|
83
|
+
]
|
|
84
|
+
}
|
|
85
|
+
}
|