fix: stream mode, last chunk of audio file size (#564)

* fix stream mode, last chunk of audio file size

* Update core.py

* Update core.py

* Update core.py
This commit is contained in:
zhipeng
2024-07-16 20:20:06 +08:00
committed by GitHub
parent 3201c24e9d
commit e6090938c3
+6 -1
View File
@@ -415,7 +415,12 @@ class Chat:
else:
yield wavs
if stream:
yield wavs[:, length:]
new_wavs = wavs[:, length:]
# Identify rows with non-zero elements using np.any
# keep_rows = np.any(array != 0, axis=1)
keep_cols = np.sum(new_wavs != 0, axis=0) > 0
# Filter both rows and columns using slicing
yield new_wavs[:][:, keep_cols]
@torch.inference_mode()
def _vocos_decode(self, spec: torch.Tensor) -> np.ndarray: