Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
DeepSpeech
提交
daf9abda
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看板
“c8e905e68c124bfe18fb66b2a596c51b4417eee4”上不存在“api_cn/analysis_api.html”
提交
daf9abda
编写于
6月 15, 2021
作者:
H
Hui Zhang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
format
上级
b98c7cd1
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
25 addition
and
10 deletion
+25
-10
deepspeech/exps/deepspeech2/model.py
deepspeech/exps/deepspeech2/model.py
+11
-3
deepspeech/exps/u2/model.py
deepspeech/exps/u2/model.py
+13
-4
deepspeech/io/dataset.py
deepspeech/io/dataset.py
+1
-2
deepspeech/models/u2.py
deepspeech/models/u2.py
+0
-1
未找到文件。
deepspeech/exps/deepspeech2/model.py
浏览文件 @
daf9abda
...
...
@@ -193,7 +193,13 @@ class DeepSpeech2Tester(DeepSpeech2Trainer):
trans
.
append
(
''
.
join
([
chr
(
i
)
for
i
in
ids
]))
return
trans
def
compute_metrics
(
self
,
utts
,
audio
,
audio_len
,
texts
,
texts_len
,
fout
=
None
):
def
compute_metrics
(
self
,
utts
,
audio
,
audio_len
,
texts
,
texts_len
,
fout
=
None
):
cfg
=
self
.
config
.
decoding
errors_sum
,
len_refs
,
num_ins
=
0.0
,
0
,
0
errors_func
=
error_rate
.
char_errors
if
cfg
.
error_rate_type
==
'cer'
else
error_rate
.
word_errors
...
...
@@ -215,7 +221,8 @@ class DeepSpeech2Tester(DeepSpeech2Trainer):
cutoff_top_n
=
cfg
.
cutoff_top_n
,
num_processes
=
cfg
.
num_proc_bsearch
)
for
utt
,
target
,
result
in
zip
(
utts
,
target_transcripts
,
result_transcripts
):
for
utt
,
target
,
result
in
zip
(
utts
,
target_transcripts
,
result_transcripts
):
errors
,
len_ref
=
errors_func
(
target
,
result
)
errors_sum
+=
errors
len_refs
+=
len_ref
...
...
@@ -245,7 +252,8 @@ class DeepSpeech2Tester(DeepSpeech2Trainer):
with
open
(
self
.
args
.
result_file
,
'w'
)
as
fout
:
for
i
,
batch
in
enumerate
(
self
.
test_loader
):
utts
,
audio
,
audio_len
,
texts
,
texts_len
=
batch
metrics
=
self
.
compute_metrics
(
utts
,
audio
,
audio_len
,
texts
,
texts_len
,
fout
)
metrics
=
self
.
compute_metrics
(
utts
,
audio
,
audio_len
,
texts
,
texts_len
,
fout
)
errors_sum
+=
metrics
[
'errors_sum'
]
len_refs
+=
metrics
[
'len_refs'
]
num_ins
+=
metrics
[
'num_ins'
]
...
...
deepspeech/exps/u2/model.py
浏览文件 @
daf9abda
...
...
@@ -78,7 +78,8 @@ class U2Trainer(Trainer):
start
=
time
.
time
()
utt
,
audio
,
audio_len
,
text
,
text_len
=
batch_data
loss
,
attention_loss
,
ctc_loss
=
self
.
model
(
audio
,
audio_len
,
text
,
text_len
)
loss
,
attention_loss
,
ctc_loss
=
self
.
model
(
audio
,
audio_len
,
text
,
text_len
)
# loss div by `batch_size * accum_grad`
loss
/=
train_conf
.
accum_grad
loss
.
backward
()
...
...
@@ -121,7 +122,8 @@ class U2Trainer(Trainer):
total_loss
=
0.0
for
i
,
batch
in
enumerate
(
self
.
valid_loader
):
utt
,
audio
,
audio_len
,
text
,
text_len
=
batch
loss
,
attention_loss
,
ctc_loss
=
self
.
model
(
audio
,
audio_len
,
text
,
text_len
)
loss
,
attention_loss
,
ctc_loss
=
self
.
model
(
audio
,
audio_len
,
text
,
text_len
)
if
paddle
.
isfinite
(
loss
):
num_utts
=
batch
[
1
].
shape
[
0
]
num_seen_utts
+=
num_utts
...
...
@@ -368,7 +370,13 @@ class U2Tester(U2Trainer):
trans
.
append
(
''
.
join
([
chr
(
i
)
for
i
in
ids
]))
return
trans
def
compute_metrics
(
self
,
utts
,
audio
,
audio_len
,
texts
,
texts_len
,
fout
=
None
):
def
compute_metrics
(
self
,
utts
,
audio
,
audio_len
,
texts
,
texts_len
,
fout
=
None
):
cfg
=
self
.
config
.
decoding
errors_sum
,
len_refs
,
num_ins
=
0.0
,
0
,
0
errors_func
=
error_rate
.
char_errors
if
cfg
.
error_rate_type
==
'cer'
else
error_rate
.
word_errors
...
...
@@ -395,7 +403,8 @@ class U2Tester(U2Trainer):
simulate_streaming
=
cfg
.
simulate_streaming
)
decode_time
=
time
.
time
()
-
start_time
for
utt
,
target
,
result
in
zip
(
utts
,
target_transcripts
,
result_transcripts
):
for
utt
,
target
,
result
in
zip
(
utts
,
target_transcripts
,
result_transcripts
):
errors
,
len_ref
=
errors_func
(
target
,
result
)
errors_sum
+=
errors
len_refs
+=
len_ref
...
...
deepspeech/io/dataset.py
浏览文件 @
daf9abda
...
...
@@ -347,6 +347,5 @@ class ManifestDataset(Dataset):
def
__getitem__
(
self
,
idx
):
instance
=
self
.
_manifest
[
idx
]
feat
,
text
=
self
.
process_utterance
(
instance
[
"feat"
],
instance
[
"text"
])
feat
,
text
=
self
.
process_utterance
(
instance
[
"feat"
],
instance
[
"text"
])
return
instance
[
"utt"
],
feat
,
text
deepspeech/models/u2.py
浏览文件 @
daf9abda
...
...
@@ -905,7 +905,6 @@ class U2InferModel(U2Model):
def
__init__
(
self
,
configs
:
dict
):
super
().
__init__
(
configs
)
def
forward
(
self
,
feats
,
feats_lengths
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录