From 8a100b731efba8c18f7e7b6cb1cb04ded94248b3 Mon Sep 17 00:00:00 2001
From: aky15 <ankeyu.aky@11.17.44.249>
Date: 星期二, 21 三月 2023 14:52:15 +0800
Subject: [PATCH] add aishell-1 rnnt egs
---
funasr/models_transducer/encoder/blocks/conv_input.py | 24 ++++++++++--------------
1 files changed, 10 insertions(+), 14 deletions(-)
diff --git a/funasr/models_transducer/encoder/blocks/conv_input.py b/funasr/models_transducer/encoder/blocks/conv_input.py
index 931d0f0..ffec93e 100644
--- a/funasr/models_transducer/encoder/blocks/conv_input.py
+++ b/funasr/models_transducer/encoder/blocks/conv_input.py
@@ -120,7 +120,7 @@
self.create_new_mask = self.create_new_conv2d_mask
self.vgg_like = vgg_like
- self.min_frame_length = 2
+ self.min_frame_length = 7
if output_size is not None:
self.output = torch.nn.Linear(output_proj, output_size)
@@ -146,30 +146,31 @@
if mask is not None:
mask = self.create_new_mask(mask)
olens = max(mask.eq(0).sum(1))
-
- b, t_input, f = x.size()
+
+ b, t, f = x.size()
x = x.unsqueeze(1) # (b. 1. t. f)
+
if chunk_size is not None:
max_input_length = int(
- chunk_size * self.subsampling_factor * (math.ceil(float(t_input) / (chunk_size * self.subsampling_factor) ))
+ chunk_size * self.subsampling_factor * (math.ceil(float(t) / (chunk_size * self.subsampling_factor) ))
)
x = map(lambda inputs: pad_to_len(inputs, max_input_length, 1), x)
x = list(x)
x = torch.stack(x, dim=0)
N_chunks = max_input_length // ( chunk_size * self.subsampling_factor)
x = x.view(b * N_chunks, 1, chunk_size * self.subsampling_factor, f)
+
x = self.conv(x)
- _, c, t, f = x.size()
-
+ _, c, _, f = x.size()
if chunk_size is not None:
x = x.transpose(1, 2).contiguous().view(b, -1, c * f)[:,:olens,:]
else:
- x = x.transpose(1, 2).contiguous().view(b, t, c * f)
+ x = x.transpose(1, 2).contiguous().view(b, -1, c * f)
if self.output is not None:
x = self.output(x)
-
+
return x, mask[:,:olens][:,:x.size(1)]
def create_new_vgg_mask(self, mask: torch.Tensor) -> torch.Tensor:
@@ -218,9 +219,4 @@
: Number of frames before subsampling.
"""
- if self.subsampling_factor > 1:
- if self.vgg_like:
- return ((size * 2) * self.stride_1) + 1
-
- return ((size + 2) * 2) + (self.kernel_2 - 1) * self.stride_2
- return size
+ return size * self.subsampling_factor
--
Gitblit v1.9.1