From 29b39fd2d5dfa411ce9616dbff23bbbdedf9f49b Mon Sep 17 00:00:00 2001 From: imrahul3610 Date: Mon, 5 Oct 2020 22:10:17 +0530 Subject: [PATCH 1/3] JS Binding Fix --- native_client/javascript/client.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/native_client/javascript/client.ts b/native_client/javascript/client.ts index 53c9eac4..3e5f1305 100644 --- a/native_client/javascript/client.ts +++ b/native_client/javascript/client.ts @@ -31,6 +31,7 @@ parser.addArgument(['--audio'], {required: true, help: 'Path to the audio file t parser.addArgument(['--version'], {action: VersionAction, nargs: 0, help: 'Print version and exits'}); parser.addArgument(['--extended'], {action: 'storeTrue', help: 'Output string from extended metadata'}); parser.addArgument(['--stream'], {action: 'storeTrue', help: 'Use streaming code path (for tests)'}); +parser.addArgument(['--hot_words'], {help: 'Hot-words and their boosts. Word:Boost pairs are comma-separated'}); let args = parser.parseArgs(); function totalTime(hrtimeValue: number[]): string { @@ -71,6 +72,14 @@ if (args['scorer']) { } } +if (args['hot_words']) { + console.error('Adding hot-words %s', args['hot_words']); + for (let word_boost of args['hot_words'].split(',')) { + let word = word_boost.split(':'); + model.addHotWord(word[0], parseFloat(word[1])); + } +} + const buffer = Fs.readFileSync(args['audio']); const result = Wav.decode(buffer); From 368f76557a911eb46c2cd964891f92df37e2711e Mon Sep 17 00:00:00 2001 From: imrahul3610 Date: Tue, 6 Oct 2020 14:27:39 +0530 Subject: [PATCH 2/3] Run Tests on CI for JS Client --- taskcluster/tc-node-tests.sh | 2 ++ taskcluster/tc-node_tflite-tests.sh | 2 ++ 2 files changed, 4 insertions(+) diff --git a/taskcluster/tc-node-tests.sh b/taskcluster/tc-node-tests.sh index e697f1ed..818539fc 100644 --- a/taskcluster/tc-node-tests.sh +++ b/taskcluster/tc-node-tests.sh @@ -34,3 +34,5 @@ ensure_cuda_usage "$3" run_all_inference_tests run_js_streaming_inference_tests + +run_hotword_tests diff --git a/taskcluster/tc-node_tflite-tests.sh b/taskcluster/tc-node_tflite-tests.sh index 525d881f..1cf2b314 100644 --- a/taskcluster/tc-node_tflite-tests.sh +++ b/taskcluster/tc-node_tflite-tests.sh @@ -36,3 +36,5 @@ check_runtime_nodejs run_all_inference_tests run_js_streaming_inference_tests + +run_hotword_tests From 9df89bd945fc095d2367052c7951b368f1e95e1b Mon Sep 17 00:00:00 2001 From: imrahul3610 Date: Tue, 6 Oct 2020 17:33:35 +0530 Subject: [PATCH 3/3] Fix JavaScript binding calls for Hot Words --- native_client/javascript/index.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/native_client/javascript/index.ts b/native_client/javascript/index.ts index ec7f5686..cbc94333 100644 --- a/native_client/javascript/index.ts +++ b/native_client/javascript/index.ts @@ -191,7 +191,7 @@ export class Model { * @throws on error */ addHotWord(aWord: string, aBoost: number): void { - const status = binding.addHotWord(this._impl, aWord, aBoost); + const status = binding.AddHotWord(this._impl, aWord, aBoost); if (status !== 0) { throw `addHotWord failed: ${binding.ErrorCodeToErrorMessage(status)} (0x${status.toString(16)})`; } @@ -205,7 +205,7 @@ export class Model { * @throws on error */ eraseHotWord(aWord: string): void { - const status = binding.eraseHotWord(this._impl, aWord); + const status = binding.EraseHotWord(this._impl, aWord); if (status !== 0) { throw `eraseHotWord failed: ${binding.ErrorCodeToErrorMessage(status)} (0x${status.toString(16)})`; } @@ -217,7 +217,7 @@ export class Model { * @throws on error */ clearHotWords(): void { - const status = binding.clearHotWords(this._impl); + const status = binding.ClearHotWords(this._impl); if (status !== 0) { throw `clearHotWord failed: ${binding.ErrorCodeToErrorMessage(status)} (0x${status.toString(16)})`; }