Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add decoder for deep asr model #753

Merged
merged 11 commits into from
Mar 27, 2018
Merged

Conversation

kuke
Copy link
Collaborator

@kuke kuke commented Mar 21, 2018

Resolve #752

@kuke
Copy link
Collaborator Author

kuke commented Mar 22, 2018

Usage

$python
>>>from post_decode_faster import Decoder
>>>decoder = Decoder(u"./graph/words.txt", u"./graph/TLG.fst", u"./logprior")
>>>res=decoder.decode("ark:kaldi_score.example")
>>> print res[0],'\n', res[1]
比于二零一五年一月将起抓获
饮片发布了第一批定中ANG照
>>>import numpy as np
>>>res=decoder.decode("BAC009S0765W0450", np.loadtxt("BAC009S0765W0450.txt"))
>>>print res
比于二零一五年一月将起抓获

@kuke kuke requested review from pengeorge, zhxfl and pkuyym March 22, 2018 02:40

#include "post_decode_faster.h"

using namespace kaldi;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please avoid importing the whole namespace.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will remove later

res += s;
if (s == "")
KALDI_ERR << "Word-id " << words[i] << " not in symbol table.";
std::cerr << s << ' ';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not use KALDI_ERR?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed

Copy link
Member

@zhxfl zhxfl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@@ -0,0 +1,143 @@
/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we change 2016 to 2018?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

}

std::string Decoder::decode(
std::string key, std::vector<std::vector<kaldi::BaseFloat>>& log_probs) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

std::vector<std::vectorkaldi::BaseFloat>& log_probs --> const std::vector<std::vectorkaldi::BaseFloat>& log_probs

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done


kaldi::ParseOptions po(usage);
binary = true;
acoustic_scale = 1.5;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should these settings be configurable?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Temporarily not necessary.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be better if acoustic_scale is configurable.

Copy link
Contributor

@pkuyym pkuyym left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@kuke kuke merged commit 4d9d141 into PaddlePaddle:develop Mar 27, 2018
Copy link

@pengeorge pengeorge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants