Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
models
提交
77ce7a92
M
models
项目概览
PaddlePaddle
/
models
大约 1 年 前同步成功
通知
222
Star
6828
Fork
2962
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
602
列表
看板
标记
里程碑
合并请求
255
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
M
models
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
602
Issue
602
列表
看板
标记
里程碑
合并请求
255
合并请求
255
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
77ce7a92
编写于
3月 22, 2018
作者:
Y
Yibing Liu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Avoid using namespace kaldi
上级
185ff858
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
11 addition
and
12 deletion
+11
-12
fluid/DeepASR/decoder/post_decode_faster.cc
fluid/DeepASR/decoder/post_decode_faster.cc
+11
-12
未找到文件。
fluid/DeepASR/decoder/post_decode_faster.cc
浏览文件 @
77ce7a92
...
...
@@ -14,7 +14,6 @@ limitations under the License. */
#include "post_decode_faster.h"
using
namespace
kaldi
;
typedef
kaldi
::
int32
int32
;
using
fst
::
SymbolTable
;
using
fst
::
VectorFst
;
...
...
@@ -27,11 +26,11 @@ Decoder::Decoder(std::string word_syms_filename,
"Decode, reading log-likelihoods (of transition-ids or whatever symbol "
"is on the graph) as matrices."
;
ParseOptions
po
(
usage
);
kaldi
::
ParseOptions
po
(
usage
);
binary
=
true
;
acoustic_scale
=
1.5
;
allow_partial
=
true
;
FasterDecoderOptions
decoder_opts
;
kaldi
::
FasterDecoderOptions
decoder_opts
;
decoder_opts
.
Register
(
&
po
,
true
);
// true == include obscure settings.
po
.
Register
(
"binary"
,
&
binary
,
"Write output in binary mode"
);
po
.
Register
(
"allow-partial"
,
...
...
@@ -59,7 +58,7 @@ Decoder::Decoder(std::string word_syms_filename,
// lot of virtual memory.
decode_fst
=
fst
::
ReadFstKaldi
(
fst_in_filename
);
decoder
=
new
FasterDecoder
(
*
decode_fst
,
decoder_opts
);
decoder
=
new
kaldi
::
FasterDecoder
(
*
decode_fst
,
decoder_opts
);
}
...
...
@@ -70,17 +69,17 @@ Decoder::~Decoder() {
}
std
::
vector
<
std
::
string
>
Decoder
::
decode
(
std
::
string
posterior_rspecifier
)
{
SequentialBaseFloatMatrixReader
posterior_reader
(
posterior_rspecifier
);
kaldi
::
SequentialBaseFloatMatrixReader
posterior_reader
(
posterior_rspecifier
);
std
::
vector
<
std
::
string
>
decoding_results
;
BaseFloat
tot_like
=
0.0
;
kaldi
::
BaseFloat
tot_like
=
0.0
;
kaldi
::
int64
frame_count
=
0
;
int
num_success
=
0
,
num_fail
=
0
;
Timer
timer
;
kaldi
::
Timer
timer
;
for
(;
!
posterior_reader
.
Done
();
posterior_reader
.
Next
())
{
std
::
string
key
=
posterior_reader
.
Key
();
Matrix
<
BaseFloat
>
loglikes
(
posterior_reader
.
Value
());
kaldi
::
Matrix
<
kaldi
::
BaseFloat
>
loglikes
(
posterior_reader
.
Value
());
if
(
loglikes
.
NumRows
()
==
0
)
{
KALDI_WARN
<<
"Zero-length utterance: "
<<
key
;
...
...
@@ -92,10 +91,10 @@ std::vector<std::string> Decoder::decode(std::string posterior_rspecifier) {
loglikes
.
ApplyLog
();
loglikes
.
AddVecToRows
(
-
1.0
,
logprior
);
DecodableMatrixScaled
decodable
(
loglikes
,
acoustic_scale
);
kaldi
::
DecodableMatrixScaled
decodable
(
loglikes
,
acoustic_scale
);
decoder
->
Decode
(
&
decodable
);
VectorFst
<
LatticeArc
>
decoded
;
// linear FST.
VectorFst
<
kaldi
::
LatticeArc
>
decoded
;
// linear FST.
if
((
allow_partial
||
decoder
->
ReachedFinal
())
&&
decoder
->
GetBestPath
(
&
decoded
))
{
...
...
@@ -106,7 +105,7 @@ std::vector<std::string> Decoder::decode(std::string posterior_rspecifier) {
std
::
vector
<
int32
>
alignment
;
std
::
vector
<
int32
>
words
;
LatticeWeight
weight
;
kaldi
::
LatticeWeight
weight
;
frame_count
+=
loglikes
.
NumRows
();
GetLinearSymbolSequence
(
decoded
,
&
alignment
,
&
words
,
&
weight
);
...
...
@@ -121,7 +120,7 @@ std::vector<std::string> Decoder::decode(std::string posterior_rspecifier) {
}
decoding_results
.
push_back
(
res
);
}
BaseFloat
like
=
-
weight
.
Value1
()
-
weight
.
Value2
();
kaldi
::
BaseFloat
like
=
-
weight
.
Value1
()
-
weight
.
Value2
();
tot_like
+=
like
;
}
else
{
num_fail
++
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录