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

Method _add_overlap_chunk

funasr/models/scama/encoder.py:480–494  ·  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

478 return xs_pad, olens, None
479
480 def _add_overlap_chunk(self, feats: np.ndarray, cache: dict = None):
481 """Internal: add overlap chunk.
482
483 Args:
484 feats: Feature tensor (e.g., fbank), shape (batch, frames, dim).
485 cache: State cache dict for streaming inference.
486 """
487 if cache is None:
488 cache = {}
489 if len(cache) == 0:
490 return feats
491 cache["feats"] = to_device(cache["feats"], device=feats.device)
492 overlap_feats = torch.cat((cache["feats"], feats), dim=1)
493 cache["feats"] = overlap_feats[:, -(cache["chunk_size"][0] + cache["chunk_size"][2]) :, :]
494 return overlap_feats
495
496 def forward_chunk(
497 self,

Callers 1

forward_chunkMethod · 0.95

Calls 1

to_deviceFunction · 0.90

Tested by

no test coverage detected