diff options
Diffstat (limited to 'source/use_case/kws_asr')
-rw-r--r-- | source/use_case/kws_asr/src/MainLoop.cc | 11 | ||||
-rw-r--r-- | source/use_case/kws_asr/src/UseCaseHandler.cc | 2 |
2 files changed, 10 insertions, 3 deletions
diff --git a/source/use_case/kws_asr/src/MainLoop.cc b/source/use_case/kws_asr/src/MainLoop.cc index 30cb084..c7e977f 100644 --- a/source/use_case/kws_asr/src/MainLoop.cc +++ b/source/use_case/kws_asr/src/MainLoop.cc @@ -136,8 +136,15 @@ void main_loop(hal_platform& platform) caseContext.Set<const std::vector <std::string>&>("asrlabels", asrLabels); caseContext.Set<const std::vector <std::string>&>("kwslabels", kwsLabels); - /* Index of the kws outputs we trigger ASR on. */ - caseContext.Set<uint32_t>("keywordindex", 9 ); + /* KWS keyword that triggers ASR and associated checks */ + std::string triggerKeyword = std::string("yes"); + if (std::find(kwsLabels.begin(), kwsLabels.end(), triggerKeyword) != kwsLabels.end()) { + caseContext.Set<const std::string &>("triggerkeyword", triggerKeyword); + } + else { + printf_err("Selected trigger keyword not found in labels file\n"); + return; + } /* Loop. */ bool executionSuccessful = true; diff --git a/source/use_case/kws_asr/src/UseCaseHandler.cc b/source/use_case/kws_asr/src/UseCaseHandler.cc index c67be22..a3ebdb1 100644 --- a/source/use_case/kws_asr/src/UseCaseHandler.cc +++ b/source/use_case/kws_asr/src/UseCaseHandler.cc @@ -240,7 +240,7 @@ namespace app { ); /* Keyword detected. */ - if (kwsClassificationResult[0].m_labelIdx == ctx.Get<uint32_t>("keywordindex")) { + if (kwsClassificationResult[0].m_label == ctx.Get<const std::string&>("triggerkeyword")) { output.asrAudioStart = inferenceWindow + kwsAudioDataWindowSize; output.asrAudioSamples = get_audio_array_size(currentIndex) - (audioDataSlider.NextWindowStartIndex() - |