提交 9876bdb4 编写于 作者: H Hui Zhang

fix add_eos_sos and cmvn

上级 28658cc1
...@@ -9,3 +9,4 @@ tools/venv ...@@ -9,3 +9,4 @@ tools/venv
*.tar *.tar
*.tar.gz *.tar.gz
.ipynb_checkpoints .ipynb_checkpoints
*.npz
此差异已折叠。
...@@ -101,7 +101,7 @@ class FeatureNormalizer(object): ...@@ -101,7 +101,7 @@ class FeatureNormalizer(object):
features.append( features.append(
featurize_func(AudioSegment.from_file(instance["feat"]))) featurize_func(AudioSegment.from_file(instance["feat"])))
features = np.hstack(features) #(D, T) features = np.hstack(features) #(D, T)
self._mean = np.mean(features, axis=1).reshape([1, -1]) #(1, D) self._mean = np.mean(features, axis=1) #(D,)
std = np.std(features, axis=1).reshape([1, -1]) #(1, D) std = np.std(features, axis=1) #(D,)
std = np.clip(std, eps, None) std = np.clip(std, eps, None)
self._istd = 1.0 / std self._istd = 1.0 / std
...@@ -132,7 +132,7 @@ def add_sos_eos(ys_pad: paddle.Tensor, sos: int, eos: int, ...@@ -132,7 +132,7 @@ def add_sos_eos(ys_pad: paddle.Tensor, sos: int, eos: int,
ys_out = paddle.cat([ys_pad, _eos], dim=1) ys_out = paddle.cat([ys_pad, _eos], dim=1)
ys_out = ys_out.masked_fill(mask_pad, eos) ys_out = ys_out.masked_fill(mask_pad, eos)
mask_eos = (ys_in == ignore_id) mask_eos = (ys_out == ignore_id)
ys_out = ys_out.masked_fill(mask_eos, eos) ys_out = ys_out.masked_fill(mask_eos, eos)
ys_out = ys_out.masked_fill(mask_pad, ignore_id) ys_out = ys_out.masked_fill(mask_pad, ignore_id)
return ys_in, ys_out return ys_in, ys_out
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册