MCPcopy Create free account
hub / github.com/modelscope/FunASR / _add_overlap_chunk

Method _add_overlap_chunk

funasr/models/sanm/encoder.py:463–477  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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,

Callers 1

forward_chunkMethod · 0.95

Calls 1

to_deviceFunction · 0.90

Tested by

no test coverage detected