Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
DeepSpeech
提交
d9d95142
D
DeepSpeech
项目概览
PaddlePaddle
/
DeepSpeech
大约 2 年 前同步成功
通知
210
Star
8425
Fork
1598
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
245
列表
看板
标记
里程碑
合并请求
3
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
DeepSpeech
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
245
Issue
245
列表
看板
标记
里程碑
合并请求
3
合并请求
3
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
d9d95142
编写于
7月 04, 2017
作者:
Y
Yibing Liu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix bugs
上级
fd102c21
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
24 addition
and
23 deletion
+24
-23
deploy.py
deploy.py
+3
-2
deploy/ctc_beam_search_decoder.cpp
deploy/ctc_beam_search_decoder.cpp
+14
-14
deploy/scorer.cpp
deploy/scorer.cpp
+7
-7
未找到文件。
deploy.py
浏览文件 @
d9d95142
...
@@ -58,7 +58,7 @@ parser.add_argument(
...
@@ -58,7 +58,7 @@ parser.add_argument(
help
=
"Manifest path for decoding. (default: %(default)s)"
)
help
=
"Manifest path for decoding. (default: %(default)s)"
)
parser
.
add_argument
(
parser
.
add_argument
(
"--model_filepath"
,
"--model_filepath"
,
default
=
'
ds2_new_models_0628/params.pass-51
.tar.gz'
,
default
=
'
checkpoints/params.latest
.tar.gz'
,
type
=
str
,
type
=
str
,
help
=
"Model filepath. (default: %(default)s)"
)
help
=
"Model filepath. (default: %(default)s)"
)
parser
.
add_argument
(
parser
.
add_argument
(
...
@@ -162,9 +162,10 @@ def infer():
...
@@ -162,9 +162,10 @@ def infer():
for
i
,
probs
in
enumerate
(
probs_split
)
for
i
,
probs
in
enumerate
(
probs_split
)
]
]
# external scorer
ext_scorer
=
Scorer
(
args
.
alpha
,
args
.
beta
,
args
.
language_model_path
)
ext_scorer
=
Scorer
(
args
.
alpha
,
args
.
beta
,
args
.
language_model_path
)
## decode and print
## decode and print
wer_sum
,
wer_counter
=
0
,
0
wer_sum
,
wer_counter
=
0
,
0
for
i
,
probs
in
enumerate
(
probs_split
):
for
i
,
probs
in
enumerate
(
probs_split
):
beam_result
=
ctc_beam_search_decoder
(
beam_result
=
ctc_beam_search_decoder
(
...
...
deploy/ctc_beam_search_decoder.cpp
浏览文件 @
d9d95142
...
@@ -133,8 +133,8 @@ std::vector<std::pair<double, std::string> >
...
@@ -133,8 +133,8 @@ std::vector<std::pair<double, std::string> >
if
(
ext_scorer
!=
NULL
&&
sentence
[
sentence
.
size
()
-
1
]
!=
' '
)
{
if
(
ext_scorer
!=
NULL
&&
sentence
[
sentence
.
size
()
-
1
]
!=
' '
)
{
prob
=
prob
*
ext_scorer
->
get_score
(
sentence
);
prob
=
prob
*
ext_scorer
->
get_score
(
sentence
);
}
}
double
log_prob
=
log
(
it
->
second
);
double
log_prob
=
log
(
prob
);
beam_result
.
push_back
(
std
::
pair
<
double
,
std
::
string
>
(
log_prob
,
it
->
first
));
beam_result
.
push_back
(
std
::
pair
<
double
,
std
::
string
>
(
log_prob
,
sentence
));
}
}
}
}
// sort the result and return
// sort the result and return
...
...
deploy/scorer.cpp
浏览文件 @
d9d95142
...
@@ -47,13 +47,12 @@ inline void strip(std::string &str, char ch=' ') {
...
@@ -47,13 +47,12 @@ inline void strip(std::string &str, char ch=' ') {
int
Scorer
::
word_count
(
std
::
string
sentence
)
{
int
Scorer
::
word_count
(
std
::
string
sentence
)
{
strip
(
sentence
);
strip
(
sentence
);
int
cnt
=
0
;
int
cnt
=
1
;
for
(
int
i
=
0
;
i
<
sentence
.
size
();
i
++
)
{
for
(
int
i
=
0
;
i
<
sentence
.
size
();
i
++
)
{
if
(
sentence
[
i
]
==
' '
&&
sentence
[
i
-
1
]
!=
' '
)
{
if
(
sentence
[
i
]
==
' '
&&
sentence
[
i
-
1
]
!=
' '
)
{
cnt
++
;
cnt
++
;
}
}
}
}
if
(
cnt
>
0
)
cnt
++
;
return
cnt
;
return
cnt
;
}
}
...
@@ -68,15 +67,16 @@ double Scorer::language_model_score(std::string sentence) {
...
@@ -68,15 +67,16 @@ double Scorer::language_model_score(std::string sentence) {
ret
=
model
->
FullScore
(
state
,
vocab
,
out_state
);
ret
=
model
->
FullScore
(
state
,
vocab
,
out_state
);
state
=
out_state
;
state
=
out_state
;
}
}
double
score
=
ret
.
prob
;
//log10 prob
double
log_prob
=
ret
.
prob
;
return
pow
(
10
,
score
)
;
return
log_prob
;
}
}
double
Scorer
::
get_score
(
std
::
string
sentence
)
{
double
Scorer
::
get_score
(
std
::
string
sentence
)
{
double
lm_score
=
language_model_score
(
sentence
);
double
lm_score
=
language_model_score
(
sentence
);
int
word_cnt
=
word_count
(
sentence
);
int
word_cnt
=
word_count
(
sentence
);
double
final_score
=
pow
(
lm_score
,
_alpha
)
*
pow
(
word_cnt
,
_beta
);
double
final_score
=
pow
(
10
,
_alpha
*
lm_score
)
*
pow
(
word_cnt
,
_beta
);
return
final_score
;
return
final_score
;
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录