Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
DeepSpeech
提交
ae87bc8c
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看板
提交
ae87bc8c
编写于
9月 22, 2021
作者:
H
Hui Zhang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
dump decode result as jsonlines
上级
c6e8a33b
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
24 addition
and
15 deletion
+24
-15
deepspeech/exps/deepspeech2/model.py
deepspeech/exps/deepspeech2/model.py
+6
-4
deepspeech/exps/u2/model.py
deepspeech/exps/u2/model.py
+6
-4
deepspeech/exps/u2_kaldi/model.py
deepspeech/exps/u2_kaldi/model.py
+6
-4
deepspeech/exps/u2_st/model.py
deepspeech/exps/u2_st/model.py
+6
-3
未找到文件。
deepspeech/exps/deepspeech2/model.py
浏览文件 @
ae87bc8c
...
@@ -18,6 +18,7 @@ from collections import defaultdict
...
@@ -18,6 +18,7 @@ from collections import defaultdict
from
contextlib
import
nullcontext
from
contextlib
import
nullcontext
from
pathlib
import
Path
from
pathlib
import
Path
from
typing
import
Optional
from
typing
import
Optional
import
jsonlines
import
numpy
as
np
import
numpy
as
np
import
paddle
import
paddle
...
@@ -305,9 +306,10 @@ class DeepSpeech2Tester(DeepSpeech2Trainer):
...
@@ -305,9 +306,10 @@ class DeepSpeech2Tester(DeepSpeech2Trainer):
len_refs
+=
len_ref
len_refs
+=
len_ref
num_ins
+=
1
num_ins
+=
1
if
fout
:
if
fout
:
fout
.
write
(
utt
+
" "
+
result
+
"
\n
"
)
fout
.
write
({
"utt"
:
utt
,
"ref"
,
target
,
"hyp"
:
result
})
logger
.
info
(
"
\n
Target Transcription: %s
\n
Output Transcription: %s"
%
logger
.
info
(
f
"Utt:
{
utt
}
"
)
(
target
,
result
))
logger
.
info
(
f
"Ref:
{
target
}
"
)
logger
.
info
(
f
"Hyp:
{
result
}
"
)
logger
.
info
(
"Current error rate [%s] = %f"
%
logger
.
info
(
"Current error rate [%s] = %f"
%
(
cfg
.
error_rate_type
,
error_rate_func
(
target
,
result
)))
(
cfg
.
error_rate_type
,
error_rate_func
(
target
,
result
)))
...
@@ -350,7 +352,7 @@ class DeepSpeech2Tester(DeepSpeech2Trainer):
...
@@ -350,7 +352,7 @@ class DeepSpeech2Tester(DeepSpeech2Trainer):
cfg
=
self
.
config
cfg
=
self
.
config
error_rate_type
=
None
error_rate_type
=
None
errors_sum
,
len_refs
,
num_ins
=
0.0
,
0
,
0
errors_sum
,
len_refs
,
num_ins
=
0.0
,
0
,
0
with
open
(
self
.
args
.
result_file
,
'w'
)
as
fout
:
with
jsonlines
.
open
(
self
.
args
.
result_file
,
'w'
)
as
fout
:
for
i
,
batch
in
enumerate
(
self
.
test_loader
):
for
i
,
batch
in
enumerate
(
self
.
test_loader
):
utts
,
audio
,
audio_len
,
texts
,
texts_len
=
batch
utts
,
audio
,
audio_len
,
texts
,
texts_len
=
batch
metrics
=
self
.
compute_metrics
(
utts
,
audio
,
audio_len
,
texts
,
metrics
=
self
.
compute_metrics
(
utts
,
audio
,
audio_len
,
texts
,
...
...
deepspeech/exps/u2/model.py
浏览文件 @
ae87bc8c
...
@@ -21,6 +21,7 @@ from collections import OrderedDict
...
@@ -21,6 +21,7 @@ from collections import OrderedDict
from
contextlib
import
nullcontext
from
contextlib
import
nullcontext
from
pathlib
import
Path
from
pathlib
import
Path
from
typing
import
Optional
from
typing
import
Optional
import
jsonlines
import
numpy
as
np
import
numpy
as
np
import
paddle
import
paddle
...
@@ -466,9 +467,10 @@ class U2Tester(U2Trainer):
...
@@ -466,9 +467,10 @@ class U2Tester(U2Trainer):
len_refs
+=
len_ref
len_refs
+=
len_ref
num_ins
+=
1
num_ins
+=
1
if
fout
:
if
fout
:
fout
.
write
(
utt
+
" "
+
result
+
"
\n
"
)
fout
.
write
({
"utt"
:
utt
,
"ref"
,
target
,
"hyp"
:
result
})
logger
.
info
(
"
\n
Target Transcription: %s
\n
Output Transcription: %s"
%
logger
.
info
(
f
"Utt:
{
utt
}
"
)
(
target
,
result
))
logger
.
info
(
f
"Ref:
{
target
}
"
)
logger
.
info
(
f
"Hyp:
{
result
}
"
)
logger
.
info
(
"One example error rate [%s] = %f"
%
logger
.
info
(
"One example error rate [%s] = %f"
%
(
cfg
.
error_rate_type
,
error_rate_func
(
target
,
result
)))
(
cfg
.
error_rate_type
,
error_rate_func
(
target
,
result
)))
...
@@ -493,7 +495,7 @@ class U2Tester(U2Trainer):
...
@@ -493,7 +495,7 @@ class U2Tester(U2Trainer):
errors_sum
,
len_refs
,
num_ins
=
0.0
,
0
,
0
errors_sum
,
len_refs
,
num_ins
=
0.0
,
0
,
0
num_frames
=
0.0
num_frames
=
0.0
num_time
=
0.0
num_time
=
0.0
with
open
(
self
.
args
.
result_file
,
'w'
)
as
fout
:
with
jsonlines
.
open
(
self
.
args
.
result_file
,
'w'
)
as
fout
:
for
i
,
batch
in
enumerate
(
self
.
test_loader
):
for
i
,
batch
in
enumerate
(
self
.
test_loader
):
metrics
=
self
.
compute_metrics
(
*
batch
,
fout
=
fout
)
metrics
=
self
.
compute_metrics
(
*
batch
,
fout
=
fout
)
num_frames
+=
metrics
[
'num_frames'
]
num_frames
+=
metrics
[
'num_frames'
]
...
...
deepspeech/exps/u2_kaldi/model.py
浏览文件 @
ae87bc8c
...
@@ -20,6 +20,7 @@ from collections import defaultdict
...
@@ -20,6 +20,7 @@ from collections import defaultdict
from
contextlib
import
nullcontext
from
contextlib
import
nullcontext
from
pathlib
import
Path
from
pathlib
import
Path
from
typing
import
Optional
from
typing
import
Optional
import
jsonlines
import
numpy
as
np
import
numpy
as
np
import
paddle
import
paddle
...
@@ -445,9 +446,10 @@ class U2Tester(U2Trainer):
...
@@ -445,9 +446,10 @@ class U2Tester(U2Trainer):
len_refs
+=
len_ref
len_refs
+=
len_ref
num_ins
+=
1
num_ins
+=
1
if
fout
:
if
fout
:
fout
.
write
(
utt
+
" "
+
result
+
"
\n
"
)
fout
.
write
({
"utt"
:
utt
,
"ref"
,
target
,
"hyp"
:
result
})
logger
.
info
(
"
\n
Target Transcription: %s
\n
Output Transcription: %s"
%
logger
.
info
(
f
"Utt:
{
utt
}
"
)
(
target
,
result
))
logger
.
info
(
f
"Ref:
{
target
}
"
)
logger
.
info
(
f
"Hyp:
{
result
}
"
)
logger
.
info
(
"One example error rate [%s] = %f"
%
logger
.
info
(
"One example error rate [%s] = %f"
%
(
cfg
.
error_rate_type
,
error_rate_func
(
target
,
result
)))
(
cfg
.
error_rate_type
,
error_rate_func
(
target
,
result
)))
...
@@ -472,7 +474,7 @@ class U2Tester(U2Trainer):
...
@@ -472,7 +474,7 @@ class U2Tester(U2Trainer):
errors_sum
,
len_refs
,
num_ins
=
0.0
,
0
,
0
errors_sum
,
len_refs
,
num_ins
=
0.0
,
0
,
0
num_frames
=
0.0
num_frames
=
0.0
num_time
=
0.0
num_time
=
0.0
with
open
(
self
.
args
.
result_file
,
'w'
)
as
fout
:
with
jsonlines
.
open
(
self
.
args
.
result_file
,
'w'
)
as
fout
:
for
i
,
batch
in
enumerate
(
self
.
test_loader
):
for
i
,
batch
in
enumerate
(
self
.
test_loader
):
metrics
=
self
.
compute_metrics
(
*
batch
,
fout
=
fout
)
metrics
=
self
.
compute_metrics
(
*
batch
,
fout
=
fout
)
num_frames
+=
metrics
[
'num_frames'
]
num_frames
+=
metrics
[
'num_frames'
]
...
...
deepspeech/exps/u2_st/model.py
浏览文件 @
ae87bc8c
...
@@ -20,6 +20,7 @@ from collections import defaultdict
...
@@ -20,6 +20,7 @@ from collections import defaultdict
from
contextlib
import
nullcontext
from
contextlib
import
nullcontext
from
pathlib
import
Path
from
pathlib
import
Path
from
typing
import
Optional
from
typing
import
Optional
import
jsonlines
import
numpy
as
np
import
numpy
as
np
import
paddle
import
paddle
...
@@ -479,8 +480,10 @@ class U2STTester(U2STTrainer):
...
@@ -479,8 +480,10 @@ class U2STTester(U2STTrainer):
len_refs
+=
len
(
target
.
split
())
len_refs
+=
len
(
target
.
split
())
num_ins
+=
1
num_ins
+=
1
if
fout
:
if
fout
:
fout
.
write
(
utt
+
" "
+
result
+
"
\n
"
)
fout
.
write
({
"utt"
:
utt
,
"ref"
,
target
,
"hyp"
:
result
})
logger
.
info
(
"
\n
Reference: %s
\n
Hypothesis: %s"
%
(
target
,
result
))
logger
.
info
(
f
"Utt:
{
utt
}
"
)
logger
.
info
(
f
"Ref:
{
target
}
"
)
logger
.
info
(
f
"Hyp:
{
result
}
"
)
logger
.
info
(
"One example BLEU = %s"
%
logger
.
info
(
"One example BLEU = %s"
%
(
bleu_func
([
result
],
[[
target
]]).
prec_str
))
(
bleu_func
([
result
],
[[
target
]]).
prec_str
))
...
@@ -508,7 +511,7 @@ class U2STTester(U2STTrainer):
...
@@ -508,7 +511,7 @@ class U2STTester(U2STTrainer):
len_refs
,
num_ins
=
0
,
0
len_refs
,
num_ins
=
0
,
0
num_frames
=
0.0
num_frames
=
0.0
num_time
=
0.0
num_time
=
0.0
with
open
(
self
.
args
.
result_file
,
'w'
)
as
fout
:
with
jsonlines
.
open
(
self
.
args
.
result_file
,
'w'
)
as
fout
:
for
i
,
batch
in
enumerate
(
self
.
test_loader
):
for
i
,
batch
in
enumerate
(
self
.
test_loader
):
metrics
=
self
.
compute_translation_metrics
(
metrics
=
self
.
compute_translation_metrics
(
*
batch
,
bleu_func
=
bleu_func
,
fout
=
fout
)
*
batch
,
bleu_func
=
bleu_func
,
fout
=
fout
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录