Fix lm fusion (#157)
* share GetHypsRowSplits interface and fix getting Topk not taking logprob * fix lm score of lm fusion and make padding len same with 'icefall/egs/librispeech/ASR/pruned_transducer_stateless7_streaming/decode.py'
This commit is contained in:
@@ -35,7 +35,7 @@ class OnlineRnnLM::Impl {
|
||||
|
||||
// get lm score for cur token given the hyp->ys[:-1] and save to lm_log_prob
|
||||
const float *nn_lm_scores = hyp->nn_lm_scores.value.GetTensorData<float>();
|
||||
hyp->lm_log_prob = nn_lm_scores[hyp->ys.back()] * scale;
|
||||
hyp->lm_log_prob += nn_lm_scores[hyp->ys.back()] * scale;
|
||||
|
||||
// get lm scores for next tokens given the hyp->ys[:] and save to
|
||||
// nn_lm_scores
|
||||
|
||||
@@ -152,7 +152,9 @@ void OnlineTransducerModifiedBeamSearchDecoder::Decode(
|
||||
} else {
|
||||
++new_hyp.num_trailing_blanks;
|
||||
}
|
||||
new_hyp.log_prob = p_logprob[k] - prev_lm_log_prob;
|
||||
new_hyp.log_prob =
|
||||
p_logprob[k] - prev_lm_log_prob; // log_prob only includes the
|
||||
// score of the transducer
|
||||
hyps.Add(std::move(new_hyp));
|
||||
} // for (auto k : topk)
|
||||
cur.push_back(std::move(hyps));
|
||||
|
||||
@@ -94,7 +94,7 @@ for a list of pre-trained models to download.
|
||||
auto s = recognizer.CreateStream();
|
||||
s->AcceptWaveform(sampling_rate, samples.data(), samples.size());
|
||||
|
||||
std::vector<float> tail_paddings(static_cast<int>(0.5 * sampling_rate));
|
||||
std::vector<float> tail_paddings(static_cast<int>(0.3 * sampling_rate));
|
||||
// Note: We can call AcceptWaveform() multiple times.
|
||||
s->AcceptWaveform(sampling_rate, tail_paddings.data(), tail_paddings.size());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user