From b14610a13a4444107d70fce49021f12488626672 Mon Sep 17 00:00:00 2001 From: Karel Vesely Date: Fri, 2 Feb 2024 12:58:55 +0100 Subject: [PATCH] export un-scaled lm_probs --- sherpa-onnx/csrc/online-recognizer.cc | 12 +++++++----- ...online-transducer-modified-beam-search-decoder.cc | 3 +++ 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/sherpa-onnx/csrc/online-recognizer.cc b/sherpa-onnx/csrc/online-recognizer.cc index 5d00c35cc2..52749d1716 100644 --- a/sherpa-onnx/csrc/online-recognizer.cc +++ b/sherpa-onnx/csrc/online-recognizer.cc @@ -21,9 +21,9 @@ namespace sherpa_onnx { /// Helper for `OnlineRecognizerResult::AsJsonString()` template const std::string& VecToString(const std::vector& vec, int32_t precision = 6) { - std::ostringstrean oss; + std::ostringstream oss; oss << std::fixed << std::setprecision(precision); - oss << "[ " << + oss << "[ "; std::string sep = ""; for (auto item : vec) { oss << sep << item; @@ -35,9 +35,11 @@ const std::string& VecToString(const std::vector& vec, int32_t precision = 6) /// Helper for `OnlineRecognizerResult::AsJsonString()` template<> // explicit specialization for T = std::string -const std::string& VecToString(const std::vector& vec, int32_t) { // ignore 2nd arg - std::ostringstrean oss; - oss << "[ " << +const std::string& VecToString(const std::vector& vec, + int32_t) // ignore 2nd arg +{ + std::ostringstream oss; + oss << "[ "; std::string sep = ""; for (auto item : vec) { oss << sep << "\"" << item << "\""; diff --git a/sherpa-onnx/csrc/online-transducer-modified-beam-search-decoder.cc b/sherpa-onnx/csrc/online-transducer-modified-beam-search-decoder.cc index e6bf9c7752..f8f68273d3 100644 --- a/sherpa-onnx/csrc/online-transducer-modified-beam-search-decoder.cc +++ b/sherpa-onnx/csrc/online-transducer-modified-beam-search-decoder.cc @@ -198,6 +198,9 @@ void OnlineTransducerModifiedBeamSearchDecoder::Decode( new_hyp.ys_probs.push_back(y_prob); float lm_prob = new_hyp.lm_log_prob - prev_lm_log_prob; + if (lm_scale_ != 0.0) { + lm_prob /= lm_scale_; // remove lm-scale + } new_hyp.lm_probs.push_back(lm_prob); new_hyp.context_scores.push_back(context_score);