Internal: extract feats. Args: speech: Speech audio tensor, shape (batch, time). speech_lengths: Length of each speech sample.
(
self, speech: torch.Tensor, speech_lengths: torch.Tensor
)
| 148 | return encoder_out |
| 149 | |
| 150 | def _extract_feats( |
| 151 | self, speech: torch.Tensor, speech_lengths: torch.Tensor |
| 152 | ) -> Tuple[torch.Tensor, torch.Tensor]: |
| 153 | """Internal: extract feats. |
| 154 | |
| 155 | Args: |
| 156 | speech: Speech audio tensor, shape (batch, time). |
| 157 | speech_lengths: Length of each speech sample. |
| 158 | """ |
| 159 | assert speech_lengths.dim() == 1, speech_lengths.shape |
| 160 | |
| 161 | # for data-parallel |
| 162 | speech = speech[:, : speech_lengths.max()] |
| 163 | |
| 164 | if self.frontend is not None: |
| 165 | # Frontend |
| 166 | # e.g. STFT and Feature extract |
| 167 | # data_loader may send time-domain signal in this case |
| 168 | # speech (Batch, NSamples) -> feats: (Batch, NFrames, Dim) |
| 169 | feats, feats_lengths = self.frontend(speech, speech_lengths) |
| 170 | else: |
| 171 | # No frontend and no feature extract |
| 172 | feats, feats_lengths = speech, speech_lengths |
| 173 | return feats, feats_lengths |
| 174 | |
| 175 | def set_num_updates(self, num_updates): |
| 176 | """Set num updates. |
no outgoing calls
no test coverage detected