qwen-asr 0.1.0 → 0.2.0-alpha.2
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 +28 -4
- package/bin/qwen-asr.js +6 -22
- package/index.d.ts +8 -0
- package/index.js +60 -0
- package/package.json +9 -3
- package/prebuilds/darwin-arm64/qwen_asr +0 -0
- package/prebuilds/darwin-x64/qwen_asr +0 -0
- package/prebuilds/linux-arm64/LICENSE-OpenBLAS +29 -0
- package/prebuilds/linux-arm64/qwen_asr +0 -0
- package/prebuilds/linux-x64/qwen_asr +0 -0
package/README.md
CHANGED
|
@@ -9,8 +9,15 @@ inference engine for Qwen3-ASR (0.6B / 1.7B) speech-to-text.
|
|
|
9
9
|
npm install -g qwen-asr
|
|
10
10
|
```
|
|
11
11
|
|
|
12
|
-
Supported
|
|
13
|
-
|
|
12
|
+
Supported platforms:
|
|
13
|
+
|
|
14
|
+
- Linux x86-64 with AVX2/FMA (x86-64-v3, Haswell or newer), glibc >= 2.28.
|
|
15
|
+
- Linux arm64 with ARMv8.2 (Cortex-A55/A76 or newer, e.g. Raspberry Pi 5,
|
|
16
|
+
Neoverse servers, Apple Silicon under Asahi Linux), glibc >= 2.28.
|
|
17
|
+
Raspberry Pi 3/4 are not supported.
|
|
18
|
+
- On Linux, OpenBLAS is statically linked; no other runtime dependencies.
|
|
19
|
+
- macOS 13.3+ on Apple Silicon or Intel (every Intel Mac that runs macOS 13
|
|
20
|
+
has the AVX2/FMA the binary needs), using the system Accelerate framework.
|
|
14
21
|
|
|
15
22
|
## Usage
|
|
16
23
|
|
|
@@ -27,7 +34,24 @@ qwen-asr -h
|
|
|
27
34
|
See the [repository README](https://github.com/nexustar/qwen-asr#readme) for
|
|
28
35
|
all options (segmented mode, streaming, language forcing, ...).
|
|
29
36
|
|
|
37
|
+
## From Node
|
|
38
|
+
|
|
39
|
+
Programs that run the binary themselves (rather than through the `qwen-asr`
|
|
40
|
+
launcher) can get its path:
|
|
41
|
+
|
|
42
|
+
```js
|
|
43
|
+
const { binaryPath } = require('qwen-asr');
|
|
44
|
+
|
|
45
|
+
const bin = binaryPath(); // e.g. .../prebuilds/darwin-arm64/qwen_asr
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
`binaryPath()` picks the arm64 binary for x64 Node under Rosetta, and throws
|
|
49
|
+
an Error with `code` `QWEN_ASR_UNSUPPORTED_PLATFORM` (no binary for this
|
|
50
|
+
OS / CPU architecture) or `QWEN_ASR_UNSUPPORTED_CPU` (CPU below the build
|
|
51
|
+
baseline) when none can run here. Add the package to `optionalDependencies`
|
|
52
|
+
so installs on other platforms still succeed.
|
|
53
|
+
|
|
30
54
|
## License
|
|
31
55
|
|
|
32
|
-
MIT. The
|
|
33
|
-
`prebuilds/linux
|
|
56
|
+
MIT. The Linux binaries statically link OpenBLAS (BSD-3-Clause, see
|
|
57
|
+
`prebuilds/linux-*/LICENSE-OpenBLAS`).
|
package/bin/qwen-asr.js
CHANGED
|
@@ -2,33 +2,17 @@
|
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
4
|
const { spawnSync } = require('child_process');
|
|
5
|
-
const
|
|
6
|
-
const path = require('path');
|
|
5
|
+
const { binaryPath } = require('..');
|
|
7
6
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
console.error(`qwen-asr:
|
|
7
|
+
let bin;
|
|
8
|
+
try {
|
|
9
|
+
bin = binaryPath();
|
|
10
|
+
} catch (e) {
|
|
11
|
+
console.error(`qwen-asr: ${e.message}.`);
|
|
13
12
|
console.error('Build from source: https://github.com/nexustar/qwen-asr');
|
|
14
13
|
process.exit(1);
|
|
15
14
|
}
|
|
16
15
|
|
|
17
|
-
// Fail clearly instead of SIGILL without x86-64-v3
|
|
18
|
-
if (key === 'linux-x64') {
|
|
19
|
-
let have = null;
|
|
20
|
-
try {
|
|
21
|
-
const m = /^flags\s*:(.*)$/m.exec(fs.readFileSync('/proc/cpuinfo', 'utf8'));
|
|
22
|
-
if (m) have = new Set(m[1].trim().split(/\s+/));
|
|
23
|
-
} catch (e) {}
|
|
24
|
-
const missing = have ? ['avx2', 'fma', 'f16c', 'bmi2'].filter(f => !have.has(f)) : [];
|
|
25
|
-
if (missing.length) {
|
|
26
|
-
console.error(`qwen-asr: this CPU lacks ${missing.join(', ')} (x86-64-v3 required).`);
|
|
27
|
-
console.error('Build from source: https://github.com/nexustar/qwen-asr');
|
|
28
|
-
process.exit(1);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
16
|
const r = spawnSync(bin, process.argv.slice(2), { stdio: 'inherit', argv0: 'qwen-asr' });
|
|
33
17
|
if (r.error) {
|
|
34
18
|
console.error(`qwen-asr: ${r.error.message}`);
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Absolute path of the prebuilt qwen_asr binary for this machine.
|
|
3
|
+
*
|
|
4
|
+
* Throws an Error with `code` QWEN_ASR_UNSUPPORTED_PLATFORM (no binary for
|
|
5
|
+
* this OS / CPU architecture) or QWEN_ASR_UNSUPPORTED_CPU (the CPU is below
|
|
6
|
+
* the build baseline) when none can run here.
|
|
7
|
+
*/
|
|
8
|
+
export function binaryPath(): string;
|
package/index.js
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// Locates the prebuilt qwen_asr binary for this machine. Used by the
|
|
4
|
+
// qwen-asr launcher, and by programs that spawn the binary themselves.
|
|
5
|
+
|
|
6
|
+
const { execFileSync } = require('child_process');
|
|
7
|
+
const fs = require('fs');
|
|
8
|
+
const path = require('path');
|
|
9
|
+
|
|
10
|
+
// Below the build baseline the binary dies with SIGILL, so check first
|
|
11
|
+
// (arm64: LSE atomics as a proxy for ARMv8.2)
|
|
12
|
+
const REQUIRED = {
|
|
13
|
+
'linux-x64': { field: 'flags', features: ['avx2', 'fma', 'f16c', 'bmi2'], level: 'x86-64-v3' },
|
|
14
|
+
'linux-arm64': { field: 'Features', features: ['atomics'], level: 'ARMv8.2' },
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
function platformKey() {
|
|
18
|
+
const key = `${process.platform}-${process.arch}`;
|
|
19
|
+
// x64 Node under Rosetta: use the native arm64 binary
|
|
20
|
+
if (key === 'darwin-x64') {
|
|
21
|
+
try {
|
|
22
|
+
const out = execFileSync('/usr/sbin/sysctl', ['-in', 'sysctl.proc_translated'], { encoding: 'utf8' });
|
|
23
|
+
if (out.trim() === '1') return 'darwin-arm64';
|
|
24
|
+
} catch (e) {}
|
|
25
|
+
}
|
|
26
|
+
return key;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function unsupported(code, message) {
|
|
30
|
+
const err = new Error(message);
|
|
31
|
+
err.code = code;
|
|
32
|
+
return err;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// Absolute path of the binary. Throws an Error with code
|
|
36
|
+
// QWEN_ASR_UNSUPPORTED_PLATFORM or QWEN_ASR_UNSUPPORTED_CPU when none can
|
|
37
|
+
// run here.
|
|
38
|
+
function binaryPath() {
|
|
39
|
+
const key = platformKey();
|
|
40
|
+
const bin = path.join(__dirname, 'prebuilds', key, 'qwen_asr');
|
|
41
|
+
if (!fs.existsSync(bin)) {
|
|
42
|
+
throw unsupported('QWEN_ASR_UNSUPPORTED_PLATFORM', `no prebuilt binary for ${key}`);
|
|
43
|
+
}
|
|
44
|
+
const required = REQUIRED[key];
|
|
45
|
+
if (required) {
|
|
46
|
+
let have = null;
|
|
47
|
+
try {
|
|
48
|
+
const re = new RegExp(`^${required.field}\\s*:(.*)$`, 'm');
|
|
49
|
+
const m = re.exec(fs.readFileSync('/proc/cpuinfo', 'utf8'));
|
|
50
|
+
if (m) have = new Set(m[1].trim().split(/\s+/));
|
|
51
|
+
} catch (e) {}
|
|
52
|
+
const missing = have ? required.features.filter(f => !have.has(f)) : [];
|
|
53
|
+
if (missing.length) {
|
|
54
|
+
throw unsupported('QWEN_ASR_UNSUPPORTED_CPU', `this CPU lacks ${missing.join(', ')} (${required.level} required)`);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return bin;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
exports.binaryPath = binaryPath;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "qwen-asr",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0-alpha.2",
|
|
4
4
|
"description": "Qwen3-ASR speech-to-text in pure C (prebuilt CLI binary)",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -15,19 +15,25 @@
|
|
|
15
15
|
"qwen3-asr",
|
|
16
16
|
"transcription"
|
|
17
17
|
],
|
|
18
|
+
"main": "index.js",
|
|
19
|
+
"types": "index.d.ts",
|
|
18
20
|
"bin": {
|
|
19
21
|
"qwen-asr": "bin/qwen-asr.js"
|
|
20
22
|
},
|
|
21
23
|
"files": [
|
|
24
|
+
"index.js",
|
|
25
|
+
"index.d.ts",
|
|
22
26
|
"bin",
|
|
23
27
|
"prebuilds",
|
|
24
28
|
"LICENSE"
|
|
25
29
|
],
|
|
26
30
|
"os": [
|
|
27
|
-
"linux"
|
|
31
|
+
"linux",
|
|
32
|
+
"darwin"
|
|
28
33
|
],
|
|
29
34
|
"cpu": [
|
|
30
|
-
"x64"
|
|
35
|
+
"x64",
|
|
36
|
+
"arm64"
|
|
31
37
|
],
|
|
32
38
|
"engines": {
|
|
33
39
|
"node": ">=16"
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
Copyright (c) 2011-2014, The OpenBLAS Project
|
|
2
|
+
All rights reserved.
|
|
3
|
+
|
|
4
|
+
Redistribution and use in source and binary forms, with or without
|
|
5
|
+
modification, are permitted provided that the following conditions are
|
|
6
|
+
met:
|
|
7
|
+
|
|
8
|
+
1. Redistributions of source code must retain the above copyright
|
|
9
|
+
notice, this list of conditions and the following disclaimer.
|
|
10
|
+
|
|
11
|
+
2. Redistributions in binary form must reproduce the above copyright
|
|
12
|
+
notice, this list of conditions and the following disclaimer in
|
|
13
|
+
the documentation and/or other materials provided with the
|
|
14
|
+
distribution.
|
|
15
|
+
3. Neither the name of the OpenBLAS project nor the names of
|
|
16
|
+
its contributors may be used to endorse or promote products
|
|
17
|
+
derived from this software without specific prior written
|
|
18
|
+
permission.
|
|
19
|
+
|
|
20
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
21
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
22
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
23
|
+
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
|
24
|
+
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
25
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
26
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
27
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
28
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
|
|
29
|
+
USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
Binary file
|
|
Binary file
|