Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
DeepSpeech
提交
f9221b4b
D
DeepSpeech
项目概览
PaddlePaddle
/
DeepSpeech
大约 1 年 前同步成功
通知
206
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
f9221b4b
编写于
11月 05, 2021
作者:
H
Hui Zhang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix ctc align
上级
56d06f2a
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
12 addition
and
13 deletion
+12
-13
paddlespeech/s2t/exps/u2/model.py
paddlespeech/s2t/exps/u2/model.py
+1
-1
paddlespeech/s2t/exps/u2_kaldi/model.py
paddlespeech/s2t/exps/u2_kaldi/model.py
+1
-1
paddlespeech/s2t/exps/u2_st/model.py
paddlespeech/s2t/exps/u2_st/model.py
+3
-3
paddlespeech/s2t/utils/ctc_utils.py
paddlespeech/s2t/utils/ctc_utils.py
+7
-8
未找到文件。
paddlespeech/s2t/exps/u2/model.py
浏览文件 @
f9221b4b
...
...
@@ -554,7 +554,7 @@ class U2Tester(U2Trainer):
@
paddle
.
no_grad
()
def
align
(
self
):
ctc_utils
.
ctc_align
(
ctc_utils
.
ctc_align
(
self
.
config
,
self
.
model
,
self
.
align_loader
,
self
.
config
.
decoding
.
batch_size
,
self
.
align_loader
.
collate_fn
.
stride_ms
,
self
.
align_loader
.
collate_fn
.
vocab_list
,
self
.
args
.
result_file
)
...
...
paddlespeech/s2t/exps/u2_kaldi/model.py
浏览文件 @
f9221b4b
...
...
@@ -527,7 +527,7 @@ class U2Tester(U2Trainer):
@
paddle
.
no_grad
()
def
align
(
self
):
ctc_utils
.
ctc_align
(
ctc_utils
.
ctc_align
(
self
.
config
,
self
.
model
,
self
.
align_loader
,
self
.
config
.
decoding
.
batch_size
,
self
.
align_loader
.
collate_fn
.
stride_ms
,
self
.
align_loader
.
collate_fn
.
vocab_list
,
self
.
args
.
result_file
)
...
...
paddlespeech/s2t/exps/u2_st/model.py
浏览文件 @
f9221b4b
...
...
@@ -543,10 +543,10 @@ class U2STTester(U2STTrainer):
@
paddle
.
no_grad
()
def
align
(
self
):
ctc_utils
.
ctc_align
(
ctc_utils
.
ctc_align
(
self
.
config
,
self
.
model
,
self
.
align_loader
,
self
.
config
.
decoding
.
batch_size
,
self
.
align_loader
.
collate_fn
.
stride_ms
,
self
.
align_loader
.
collate_fn
.
vocab_list
,
self
.
args
.
result_file
)
self
.
config
.
collator
.
stride_ms
,
self
.
vocab_list
,
self
.
args
.
result_file
)
def
load_inferspec
(
self
):
"""infer model and input spec.
...
...
paddlespeech/s2t/utils/ctc_utils.py
浏览文件 @
f9221b4b
...
...
@@ -13,7 +13,7 @@
# limitations under the License.
# Modified from wenet(https://github.com/wenet-e2e/wenet)
from
typing
import
List
from
pathlib
import
Path
import
numpy
as
np
import
paddle
...
...
@@ -139,26 +139,27 @@ def forced_align(ctc_probs: paddle.Tensor, y: paddle.Tensor,
return
output_alignment
def
ctc_align
(
model
,
dataloader
,
batch_size
,
stride_ms
,
token_dict
,
def
ctc_align
(
config
,
model
,
dataloader
,
batch_size
,
stride_ms
,
token_dict
,
result_file
):
"""ctc alignment.
Args:
config (cfgNode): config
model (nn.Layer): U2 Model.
dataloader (io.DataLoader): dataloader.
batch_size (int): decoding batchsize.
stride_ms (int): audio feature stride in ms unit.
token_dict (List[str]): vocab list, e.g. ['blank', 'unk', 'a', 'b', '<eos>'].
result_file (str): alignment output file, e.g. xxx.align.
result_file (str): alignment output file, e.g.
/path/to/
xxx.align.
"""
if
batch_size
>
1
:
logger
.
fatal
(
'alignment mode must be running with batch_size == 1'
)
sys
.
exit
(
1
)
assert
result_file
and
result_file
.
endswith
(
'.align'
)
model
.
eval
()
# conv subsampling rate
subsample
=
utility
.
get_subsample
(
config
)
logger
.
info
(
f
"Align Total Examples:
{
len
(
dataloader
.
dataset
)
}
"
)
with
open
(
result_file
,
'w'
)
as
fout
:
...
...
@@ -187,13 +188,11 @@ def ctc_align(model, dataloader, batch_size, stride_ms, token_dict,
logger
.
info
(
f
"align tokens:
{
key
[
0
]
}
,
{
align_segs
}
"
)
# IntervalTier, List["start end token\n"]
subsample
=
utility
.
get_subsample
(
self
.
config
)
tierformat
=
text_grid
.
align_to_tierformat
(
align_segs
,
subsample
,
token_dict
)
# write tier
align_output_path
=
Path
(
self
.
args
.
result_file
).
parent
/
"align"
align_output_path
=
Path
(
result_file
).
parent
/
"align"
align_output_path
.
mkdir
(
parents
=
True
,
exist_ok
=
True
)
tier_path
=
align_output_path
/
(
key
[
0
]
+
".tier"
)
with
tier_path
.
open
(
'w'
)
as
f
:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录