sherpa-onnx
Advanced tools
Comparing version 1.10.17 to 1.10.19
{ | ||
"name": "sherpa-onnx", | ||
"version": "1.10.17", | ||
"version": "1.10.19", | ||
"description": "Speech-to-text and text-to-speech using Next-gen Kaldi without internet connection", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -872,3 +872,3 @@ function freeConfig(config, Module) { | ||
if (this.handle) { | ||
this.Module._DestroyOfflineStream(this.handle); | ||
this.Module._SherpaOnnxDestroyOfflineStream(this.handle); | ||
this.handle = null; | ||
@@ -886,3 +886,3 @@ } | ||
this.Module.HEAPF32.set(samples, pointer / samples.BYTES_PER_ELEMENT); | ||
this.Module._AcceptWaveformOffline( | ||
this.Module._SherpaOnnxAcceptWaveformOffline( | ||
this.handle, sampleRate, pointer, samples.length); | ||
@@ -897,3 +897,3 @@ this.Module._free(pointer); | ||
const config = initSherpaOnnxOfflineRecognizerConfig(configObj, Module); | ||
const handle = Module._CreateOfflineRecognizer(config.ptr); | ||
const handle = Module._SherpaOnnxCreateOfflineRecognizer(config.ptr); | ||
freeConfig(config, Module); | ||
@@ -906,3 +906,3 @@ | ||
free() { | ||
this.Module._DestroyOfflineRecognizer(this.handle); | ||
this.Module._SherpaOnnxDestroyOfflineRecognizer(this.handle); | ||
this.handle = 0 | ||
@@ -912,3 +912,3 @@ } | ||
createStream() { | ||
const handle = this.Module._CreateOfflineStream(this.handle); | ||
const handle = this.Module._SherpaOnnxCreateOfflineStream(this.handle); | ||
return new OfflineStream(handle, this.Module); | ||
@@ -918,10 +918,11 @@ } | ||
decode(stream) { | ||
this.Module._DecodeOfflineStream(this.handle, stream.handle); | ||
this.Module._SherpaOnnxDecodeOfflineStream(this.handle, stream.handle); | ||
} | ||
getResult(stream) { | ||
const r = this.Module._GetOfflineStreamResultAsJson(stream.handle); | ||
const r = | ||
this.Module._SherpaOnnxGetOfflineStreamResultAsJson(stream.handle); | ||
const jsonStr = this.Module.UTF8ToString(r); | ||
const ans = JSON.parse(jsonStr); | ||
this.Module._DestroyOfflineStreamResultJson(r); | ||
this.Module._SherpaOnnxDestroyOfflineStreamResultJson(r); | ||
@@ -942,3 +943,3 @@ return ans; | ||
if (this.handle) { | ||
this.Module._DestroyOnlineStream(this.handle); | ||
this.Module._SherpaOnnxDestroyOnlineStream(this.handle); | ||
this.handle = null; | ||
@@ -964,3 +965,3 @@ this.Module._free(this.pointer); | ||
this.Module.HEAPF32.set(samples, this.pointer / samples.BYTES_PER_ELEMENT); | ||
this.Module._AcceptWaveform( | ||
this.Module._SherpaOnnxOnlineStreamAcceptWaveform( | ||
this.handle, sampleRate, this.pointer, samples.length); | ||
@@ -970,3 +971,3 @@ } | ||
inputFinished() { | ||
this.Module._InputFinished(this.handle); | ||
this.Module._SherpaOnnxOnlineStreamInputFinished(this.handle); | ||
} | ||
@@ -979,3 +980,3 @@ }; | ||
const config = initSherpaOnnxOnlineRecognizerConfig(configObj, Module) | ||
const handle = Module._CreateOnlineRecognizer(config.ptr); | ||
const handle = Module._SherpaOnnxCreateOnlineRecognizer(config.ptr); | ||
@@ -989,3 +990,3 @@ freeConfig(config, Module); | ||
free() { | ||
this.Module._DestroyOnlineRecognizer(this.handle); | ||
this.Module._SherpaOnnxDestroyOnlineRecognizer(this.handle); | ||
this.handle = 0 | ||
@@ -995,3 +996,3 @@ } | ||
createStream() { | ||
const handle = this.Module._CreateOnlineStream(this.handle); | ||
const handle = this.Module._SherpaOnnxCreateOnlineStream(this.handle); | ||
return new OnlineStream(handle, this.Module); | ||
@@ -1001,23 +1002,25 @@ } | ||
isReady(stream) { | ||
return this.Module._IsOnlineStreamReady(this.handle, stream.handle) == 1; | ||
return this.Module._SherpaOnnxIsOnlineStreamReady( | ||
this.handle, stream.handle) == 1; | ||
} | ||
decode(stream) { | ||
this.Module._DecodeOnlineStream(this.handle, stream.handle); | ||
this.Module._SherpaOnnxDecodeOnlineStream(this.handle, stream.handle); | ||
} | ||
isEndpoint(stream) { | ||
return this.Module._IsEndpoint(this.handle, stream.handle) == 1; | ||
return this.Module._SherpaOnnxOnlineStreamIsEndpoint( | ||
this.handle, stream.handle) == 1; | ||
} | ||
reset(stream) { | ||
this.Module._Reset(this.handle, stream.handle); | ||
this.Module._SherpaOnnxOnlineStreamReset(this.handle, stream.handle); | ||
} | ||
getResult(stream) { | ||
const r = | ||
this.Module._GetOnlineStreamResultAsJson(this.handle, stream.handle); | ||
const r = this.Module._SherpaOnnxGetOnlineStreamResultAsJson( | ||
this.handle, stream.handle); | ||
const jsonStr = this.Module.UTF8ToString(r); | ||
const ans = JSON.parse(jsonStr); | ||
this.Module._DestroyOnlineStreamResultJson(r); | ||
this.Module._SherpaOnnxDestroyOnlineStreamResultJson(r); | ||
@@ -1024,0 +1027,0 @@ return ans; |
@@ -192,3 +192,3 @@ | ||
if (this.handle) { | ||
this.Module._DestroyOnlineKwsStream(this.handle); | ||
this.Module._SherpaOnnxDestroyOnlineStream(this.handle); | ||
this.handle = null; | ||
@@ -214,3 +214,3 @@ this.Module._free(this.pointer); | ||
this.Module.HEAPF32.set(samples, this.pointer / samples.BYTES_PER_ELEMENT); | ||
this.Module._AcceptWaveform( | ||
this.Module._SherpaOnnxOnlineStreamAcceptWaveform( | ||
this.handle, sampleRate, this.pointer, samples.length); | ||
@@ -220,3 +220,3 @@ } | ||
inputFinished() { | ||
this.Module._InputFinished(this.handle); | ||
this.Module._SherpaOnnxOnlineStreamInputFinished(this.handle); | ||
} | ||
@@ -229,3 +229,3 @@ }; | ||
let config = initKwsConfig(configObj, Module) | ||
let handle = Module._CreateKeywordSpotter(config.ptr); | ||
let handle = Module._SherpaOnnxCreateKeywordSpotter(config.ptr); | ||
@@ -239,3 +239,3 @@ freeConfig(config, Module); | ||
free() { | ||
this.Module._DestroyKeywordSpotter(this.handle); | ||
this.Module._SherpaOnnxDestroyKeywordSpotter(this.handle); | ||
this.handle = 0 | ||
@@ -245,3 +245,3 @@ } | ||
createStream() { | ||
let handle = this.Module._CreateKeywordStream(this.handle); | ||
let handle = this.Module._SherpaOnnxCreateKeywordStream(this.handle); | ||
return new Stream(handle, this.Module); | ||
@@ -251,14 +251,16 @@ } | ||
isReady(stream) { | ||
return this.Module._IsKeywordStreamReady(this.handle, stream.handle) === 1; | ||
return this.Module._SherpaOnnxIsKeywordStreamReady( | ||
this.handle, stream.handle) == 1; | ||
} | ||
decode(stream) { | ||
return this.Module._DecodeKeywordStream(this.handle, stream.handle); | ||
return this.Module._SherpaOnnxDecodeKeywordStream( | ||
this.handle, stream.handle); | ||
} | ||
getResult(stream) { | ||
let r = this.Module._GetKeywordResult(this.handle, stream.handle); | ||
let r = this.Module._SherpaOnnxGetKeywordResult(this.handle, stream.handle); | ||
let jsonPtr = this.Module.getValue(r + 24, 'i8*'); | ||
let json = this.Module.UTF8ToString(jsonPtr); | ||
this.Module._DestroyKeywordResult(r); | ||
this.Module._SherpaOnnxDestroyKeywordResult(r); | ||
return JSON.parse(json); | ||
@@ -265,0 +267,0 @@ } |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
1581
12194054