(
self,
samples: torch.Tensor,
first_clip_len: int = 81,
clip_len: int = 84,
sr: int = 16000,
fps: int = 16,
)
| 39 | |
| 40 | class RS2V_SlidingWindowReader: |
| 41 | def __init__( |
| 42 | self, |
| 43 | samples: torch.Tensor, |
| 44 | first_clip_len: int = 81, |
| 45 | clip_len: int = 84, |
| 46 | sr: int = 16000, |
| 47 | fps: int = 16, |
| 48 | ): |
| 49 | assert isinstance(samples, torch.Tensor) |
| 50 | assert samples.dim() in [1, 2], "samples 必须是 1D 或 2D Tensor" |
| 51 | if samples.dim() == 1: |
| 52 | samples = samples.unsqueeze(0) |
| 53 | |
| 54 | self.samples = samples |
| 55 | self.first_clip_len = first_clip_len |
| 56 | self.clip_len = clip_len |
| 57 | |
| 58 | self.audio_per_frame = sr // fps |
| 59 | self.pos_frame = 0 |
| 60 | self.chunk_idx = 0 |
| 61 | |
| 62 | def next_frame(self): |
| 63 | cur_clip_len = self.first_clip_len if self.chunk_idx == 0 else self.clip_len |
nothing calls this directly
no outgoing calls
no test coverage detected