Skip to content

Commit

Permalink
export un-scaled lm_probs
Browse files Browse the repository at this point in the history
  • Loading branch information
KarelVesely84 committed Feb 2, 2024
1 parent 3d4f212 commit b14610a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
12 changes: 7 additions & 5 deletions sherpa-onnx/csrc/online-recognizer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ namespace sherpa_onnx {
/// Helper for `OnlineRecognizerResult::AsJsonString()`
template<typename T>
const std::string& VecToString(const std::vector<T>& 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;
Expand All @@ -35,9 +35,11 @@ const std::string& VecToString(const std::vector<T>& vec, int32_t precision = 6)

/// Helper for `OnlineRecognizerResult::AsJsonString()`
template<> // explicit specialization for T = std::string
const std::string& VecToString<std::string>(const std::vector<T>& vec, int32_t) { // ignore 2nd arg
std::ostringstrean oss;
oss << "[ " <<
const std::string& VecToString<std::string>(const std::vector<std::string>& vec,
int32_t) // ignore 2nd arg
{
std::ostringstream oss;
oss << "[ ";
std::string sep = "";
for (auto item : vec) {
oss << sep << "\"" << item << "\"";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit b14610a

Please sign in to comment.