sherpa-onnx-node 1.0.7
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 +5 -0
- package/addon.js +25 -0
- package/package.json +52 -0
- package/sherpa-onnx.js +7 -0
- package/streaming-asr.js +42 -0
package/README.md
ADDED
package/addon.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
const os = require('os');
|
|
2
|
+
const platform_arch = `${os.platform()}-${os.arch()}`;
|
|
3
|
+
const possible_paths = [
|
|
4
|
+
'../build/Release/sherpa-onnx.node',
|
|
5
|
+
'../build/Debug/sherpa-onnx.node',
|
|
6
|
+
`./node_modules/sherpa-onnx-${platform_arch}/sherpa-onnx.node`,
|
|
7
|
+
];
|
|
8
|
+
|
|
9
|
+
let found = false;
|
|
10
|
+
for (const p of possible_paths) {
|
|
11
|
+
try {
|
|
12
|
+
console.log(p);
|
|
13
|
+
module.exports = require(p);
|
|
14
|
+
found = true;
|
|
15
|
+
break;
|
|
16
|
+
} catch (error) {
|
|
17
|
+
// do nothing; try the next option
|
|
18
|
+
;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
if (!found) {
|
|
23
|
+
throw new Error(
|
|
24
|
+
`Could not find sherpa-onnx. Tried\n\n ${possible_paths.join('\n ')}\n`)
|
|
25
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "sherpa-onnx-node",
|
|
3
|
+
"version": "1.0.7",
|
|
4
|
+
"description": "Speech-to-text and text-to-speech using Next-gen Kaldi without internet connection",
|
|
5
|
+
"main": "sherpa-onnx.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
8
|
+
},
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/csukuangfj/sherpa-onnx.git"
|
|
12
|
+
},
|
|
13
|
+
"keywords": [
|
|
14
|
+
"speech to text",
|
|
15
|
+
"text to speech",
|
|
16
|
+
"transcription",
|
|
17
|
+
"real-time speech recognition",
|
|
18
|
+
"without internet connection",
|
|
19
|
+
"embedded systems",
|
|
20
|
+
"open source",
|
|
21
|
+
"zipformer",
|
|
22
|
+
"asr",
|
|
23
|
+
"tts",
|
|
24
|
+
"stt",
|
|
25
|
+
"c++",
|
|
26
|
+
"onnxruntime",
|
|
27
|
+
"onnx",
|
|
28
|
+
"ai",
|
|
29
|
+
"next-gen kaldi",
|
|
30
|
+
"offline",
|
|
31
|
+
"privacy",
|
|
32
|
+
"open source",
|
|
33
|
+
"vad",
|
|
34
|
+
"speaker id",
|
|
35
|
+
"language id",
|
|
36
|
+
"node-addon-api",
|
|
37
|
+
"streaming speech recognition",
|
|
38
|
+
"speech",
|
|
39
|
+
"recognition"
|
|
40
|
+
],
|
|
41
|
+
"author": "The next-gen Kaldi team",
|
|
42
|
+
"license": "Apache-2.0",
|
|
43
|
+
"bugs": {
|
|
44
|
+
"url": "https://github.com/csukuangfj/sherpa-onnx/issues"
|
|
45
|
+
},
|
|
46
|
+
"homepage": "https://github.com/csukuangfj/sherpa-onnx#readme",
|
|
47
|
+
"optionalDependencies": {
|
|
48
|
+
"sherpa-onnx-darwin-arm64": "^1.0.7",
|
|
49
|
+
"sherpa-onnx-darwin-x64": "^1.0.7",
|
|
50
|
+
"sherpa-onnx-linux-x64": "^1.0.7"
|
|
51
|
+
}
|
|
52
|
+
}
|
package/sherpa-onnx.js
ADDED
package/streaming-asr.js
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
const addon = require('./addon.js');
|
|
2
|
+
console.log(addon)
|
|
3
|
+
|
|
4
|
+
class OnlineStream {
|
|
5
|
+
constructor(handle) {
|
|
6
|
+
this.handle = handle;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
// samples is a float32 array containing samples in the range [-1, 1]
|
|
10
|
+
acceptWaveform(samples, sampleRate) {
|
|
11
|
+
addon.acceptWaveformOnline(
|
|
12
|
+
this.handle, {samples: samples, sampleRate: sampleRate})
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
class OnlineRecognizer {
|
|
17
|
+
constructor(config) {
|
|
18
|
+
this.handle = addon.createOnlineRecognizer(config);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
createStream() {
|
|
22
|
+
const handle = addon.createOnlineStream(this.handle);
|
|
23
|
+
return new OnlineStream(handle);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
isReady(stream) {
|
|
27
|
+
return addon.isOnlineStreamReady(this.handle, stream.handle);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
decode(stream) {
|
|
31
|
+
addon.decodeOnlineStream(this.handle, stream.handle);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
getResult(stream) {
|
|
35
|
+
const jsonStr =
|
|
36
|
+
addon.getOnlineStreamResultAsJson(this.handle, stream.handle);
|
|
37
|
+
|
|
38
|
+
return JSON.parse(jsonStr);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
module.exports = {OnlineRecognizer}
|