(self, a:torch.Tensor, prev_a:torch.Tensor = None)
| 209 | return a |
| 210 | |
| 211 | def forward(self, a:torch.Tensor, prev_a:torch.Tensor = None) -> torch.Tensor: |
| 212 | if prev_a is not None: |
| 213 | a = torch.cat([prev_a, a], dim = 1) |
| 214 | if a.shape[1] % int( (self.num_frames_for_clip + self.num_prev_frames) * self.opt.sampling_rate / self.opt.fps) != 0: |
| 215 | a = F.pad(a, (0, int((self.num_frames_for_clip + self.num_prev_frames) * self.opt.sampling_rate / self.opt.fps) - a.shape[1]), mode='replicate') |
| 216 | a = self.get_wav2vec2_feature(a, seq_len = self.num_frames_for_clip + self.num_prev_frames) |
| 217 | else: |
| 218 | if a.shape[1] % int( self.num_frames_for_clip * self.opt.sampling_rate / self.opt.fps) != 0: |
| 219 | a = F.pad(a, (0, int(self.num_frames_for_clip * self.opt.sampling_rate / self.opt.fps) - a.shape[1]), mode = 'replicate') |
| 220 | a = self.get_wav2vec2_feature(a, seq_len = self.num_frames_for_clip) |
| 221 | |
| 222 | return self.audio_projection(a) # frame by frame |
| 223 | |
| 224 | @torch.no_grad() |
| 225 | def inference(self, a: torch.Tensor, seq_len:int) -> torch.Tensor: |
no test coverage detected