Skip to content

Commit

Permalink
fix stream mode, last chunk of audio file size
Browse files Browse the repository at this point in the history
  • Loading branch information
Ox0400 authored Jul 12, 2024
1 parent d1fc445 commit d6e753e
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions ChatTTS/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -407,12 +407,15 @@ def _infer(
else:
yield wavs
if stream:
new_wavs = np.zeros((wavs.shape[0], params_infer_code.stream_speed))
for i in range(wavs.shape[0]):
a = length[i]
b = len(wavs[i])
wavs[i, : b - a] = wavs[i, a:]
wavs[i, b - a :] = 0
yield wavs
new_wavs[i, : b - a] = wavs[i, a:]
# Remove padding zeros
keep_cols = np.sum(new_wavs != 0, axis=0) > 0
new_wavs = np.delete(new_wavs, np.where(~keep_cols)[0], axis=1)
yield new_wavs

@torch.inference_mode()
def _vocos_decode(self, spec: torch.Tensor) -> np.ndarray:
Expand Down

0 comments on commit d6e753e

Please sign in to comment.