From 1be44c63fc1b241cc41fdcfb70b59fc4274cfc3d Mon Sep 17 00:00:00 2001 From: imrahul3610 Date: Sun, 8 Nov 2020 03:19:16 +0530 Subject: [PATCH] Hotword support for .NET client tests --- native_client/dotnet/DeepSpeechConsole/Program.cs | 15 +++++++++++++++ taskcluster/tc-asserts.sh | 5 +++-- taskcluster/tc-netframework-ds-tests.sh | 2 ++ 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/native_client/dotnet/DeepSpeechConsole/Program.cs b/native_client/dotnet/DeepSpeechConsole/Program.cs index 68f3fc54..55bd8fd5 100644 --- a/native_client/dotnet/DeepSpeechConsole/Program.cs +++ b/native_client/dotnet/DeepSpeechConsole/Program.cs @@ -37,12 +37,14 @@ namespace CSharpExamples string model = null; string scorer = null; string audio = null; + string hotwords = null; bool extended = false; if (args.Length > 0) { model = GetArgument(args, "--model"); scorer = GetArgument(args, "--scorer"); audio = GetArgument(args, "--audio"); + hotwords = GetArgument(args, "--hot_words"); extended = !string.IsNullOrWhiteSpace(GetArgument(args, "--extended")); } @@ -65,6 +67,19 @@ namespace CSharpExamples sttClient.EnableExternalScorer(scorer ?? "kenlm.scorer"); } + if(hotwords != null) + { + Console.WriteLine($"Adding hot-words {hotwords}"); + char[] sep = {','}; + string[] word_boosts = hotwords.Split(sep); + foreach(string word_boost in word_boosts) + { + char[] sep1 = {':'}; + string[] word = word_boost.Split(sep1); + sttClient.AddHotWord(word[0], float.Parse(word[1])); + } + } + string audioFile = audio ?? "arctic_a0024.wav"; var waveBuffer = new WaveBuffer(File.ReadAllBytes(audioFile)); using (var waveInfo = new WaveFileReader(audioFile)) diff --git a/taskcluster/tc-asserts.sh b/taskcluster/tc-asserts.sh index d485846e..3b23be1c 100755 --- a/taskcluster/tc-asserts.sh +++ b/taskcluster/tc-asserts.sh @@ -526,11 +526,12 @@ run_multi_inference_tests() run_hotword_tests() { + DS_BINARY_FILE=${DS_BINARY_FILE:-"deepspeech"} set +e - hotwords_decode=$(${DS_BINARY_PREFIX}deepspeech --model ${TASKCLUSTER_TMP_DIR}/${model_name_mmap} --scorer ${TASKCLUSTER_TMP_DIR}/kenlm.scorer --audio ${TASKCLUSTER_TMP_DIR}/${ldc93s1_sample_filename} --hot_words "foo:0.0,bar:-0.1" 2>${TASKCLUSTER_TMP_DIR}/stderr) + hotwords_decode=$(${DS_BINARY_PREFIX}${DS_BINARY_FILE} --model ${TASKCLUSTER_TMP_DIR}/${model_name_mmap} --scorer ${TASKCLUSTER_TMP_DIR}/kenlm.scorer --audio ${TASKCLUSTER_TMP_DIR}/${ldc93s1_sample_filename} --hot_words "foo:0.0,bar:-0.1" 2>${TASKCLUSTER_TMP_DIR}/stderr) status=$? set -e - assert_correct_ldc93s1_lm "${hotwords_decode}" "$status" + assert_working_ldc93s1_lm "${hotwords_decode}" "$status" } run_android_hotword_tests() diff --git a/taskcluster/tc-netframework-ds-tests.sh b/taskcluster/tc-netframework-ds-tests.sh index e74d0cb8..d8659827 100644 --- a/taskcluster/tc-netframework-ds-tests.sh +++ b/taskcluster/tc-netframework-ds-tests.sh @@ -29,3 +29,5 @@ DS_BINARY_FILE="DeepSpeechConsole.exe" ensure_cuda_usage "$2" run_netframework_inference_tests + +run_hotword_tests \ No newline at end of file