Internal: add overlap chunk. Args: feats: Feature tensor (e.g., fbank), shape (batch, frames, dim). cache: State cache dict for streaming inference.
(self, feats: np.ndarray, cache: dict = None)
| 461 | return xs_pad, olens, None |
| 462 | |
| 463 | def _add_overlap_chunk(self, feats: np.ndarray, cache: dict = None): |
| 464 | """Internal: add overlap chunk. |
| 465 | |
| 466 | Args: |
| 467 | feats: Feature tensor (e.g., fbank), shape (batch, frames, dim). |
| 468 | cache: State cache dict for streaming inference. |
| 469 | """ |
| 470 | if cache is None: |
| 471 | cache = {} |
| 472 | if len(cache) == 0: |
| 473 | return feats |
| 474 | cache["feats"] = to_device(cache["feats"], device=feats.device) |
| 475 | overlap_feats = torch.cat((cache["feats"], feats), dim=1) |
| 476 | cache["feats"] = overlap_feats[:, -(cache["chunk_size"][0] + cache["chunk_size"][2]) :, :] |
| 477 | return overlap_feats |
| 478 | |
| 479 | def forward_chunk( |
| 480 | self, |
no test coverage detected