|
|
@ -31,7 +31,7 @@ using paddle::platform::TracerEventType;
|
|
|
|
|
|
|
|
|
|
|
|
namespace ppspeech {
|
|
|
|
namespace ppspeech {
|
|
|
|
|
|
|
|
|
|
|
|
CTCPrefixBeamSearch::CTCPrefixBeamSearch(const std::string vocab_path,
|
|
|
|
CTCPrefixBeamSearch::CTCPrefixBeamSearch(const std::string& vocab_path,
|
|
|
|
const CTCBeamSearchOptions& opts)
|
|
|
|
const CTCBeamSearchOptions& opts)
|
|
|
|
: opts_(opts) {
|
|
|
|
: opts_(opts) {
|
|
|
|
unit_table_ = std::shared_ptr<fst::SymbolTable>(
|
|
|
|
unit_table_ = std::shared_ptr<fst::SymbolTable>(
|
|
|
@ -55,10 +55,7 @@ void CTCPrefixBeamSearch::Reset() {
|
|
|
|
// empty hyp with Score
|
|
|
|
// empty hyp with Score
|
|
|
|
std::vector<int> empty;
|
|
|
|
std::vector<int> empty;
|
|
|
|
PrefixScore prefix_score;
|
|
|
|
PrefixScore prefix_score;
|
|
|
|
prefix_score.b = 0.0f; // log(1)
|
|
|
|
prefix_score.InitEmpty();
|
|
|
|
prefix_score.nb = -kBaseFloatMax; // log(0)
|
|
|
|
|
|
|
|
prefix_score.v_b = 0.0f; // log(1)
|
|
|
|
|
|
|
|
prefix_score.v_nb = 0.0f; // log(1)
|
|
|
|
|
|
|
|
cur_hyps_[empty] = prefix_score;
|
|
|
|
cur_hyps_[empty] = prefix_score;
|
|
|
|
|
|
|
|
|
|
|
|
outputs_.emplace_back(empty);
|
|
|
|
outputs_.emplace_back(empty);
|
|
|
@ -287,19 +284,7 @@ void CTCPrefixBeamSearch::UpdateOutputs(
|
|
|
|
int s = 0;
|
|
|
|
int s = 0;
|
|
|
|
int e = 0;
|
|
|
|
int e = 0;
|
|
|
|
for (int i = 0; i < input.size(); ++i) {
|
|
|
|
for (int i = 0; i < input.size(); ++i) {
|
|
|
|
// if (s < start_boundaries.size() && i == start_boundaries[s]){
|
|
|
|
|
|
|
|
// // <context>
|
|
|
|
|
|
|
|
// output.emplace_back(context_graph_->start_tag_id());
|
|
|
|
|
|
|
|
// ++s;
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
output.emplace_back(input[i]);
|
|
|
|
output.emplace_back(input[i]);
|
|
|
|
|
|
|
|
|
|
|
|
// if (e < end_boundaries.size() && i == end_boundaries[e]){
|
|
|
|
|
|
|
|
// // </context>
|
|
|
|
|
|
|
|
// output.emplace_back(context_graph_->end_tag_id());
|
|
|
|
|
|
|
|
// ++e;
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
outputs_.emplace_back(output);
|
|
|
|
outputs_.emplace_back(output);
|
|
|
|