Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for exception on streaming on last chunk #3160

Merged
merged 1 commit into from
Nov 8, 2023
Merged

Conversation

gorkemgoknar
Copy link
Contributor

@gorkemgoknar gorkemgoknar commented Nov 7, 2023

When last chunk is smaller than overlap length it raises exception with following error

The size of tensor a (0) must match the size of tensor b (1024) at non-singleton dimension 0

@erogol
Copy link
Member

erogol commented Nov 8, 2023

@gorkemgoknar when is the last chunk empty?

@gorkemgoknar
Copy link
Contributor Author

@erogol it does not happen always so hard to 100% reproduce, like 1/10 chance due to non-determinism, but when happens it causes a runtime exception.

File ~/.local/lib/python3.10/site-packages/TTS/tts/models/xtts.py:673, in Xtts.handle_chunks(self, wav_gen, wav_gen_prev, wav_overlap, overlap_len)
671 if wav_overlap is not None:
672 crossfade_wav = wav_chunk[:overlap_len]
--> 673 crossfade_wav = crossfade_wav * torch.linspace(0.0, 1.0, overlap_len).to(crossfade_wav.device)
674 wav_chunk[:overlap_len] = wav_overlap * torch.linspace(1.0, 0.0, overlap_len).to(wav_overlap.device)
675 wav_chunk[:overlap_len] += crossfade_wav

RuntimeError: The size of tensor a (0) must match the size of tensor b (1024) at non-singleton dimension 0

This solution tested locally.

@erogol
Copy link
Member

erogol commented Nov 8, 2023

@gorkemgoknar is the problem being last chunk empty or last chunk smaller than the overlap

@gorkemgoknar
Copy link
Contributor Author

last chunk smaller than the overlap

last chunk smaller than the overlap, not actually empty correct.

@gorkemgoknar gorkemgoknar changed the title Fix for exception on streaming if last chunk empty Fix for exception on streaming on last chunk Nov 8, 2023
@erogol erogol merged commit 78a5966 into dev Nov 8, 2023
53 checks passed
@erogol erogol deleted the Streaming_last_chunk_fix branch November 8, 2023 10:32
qtangs added a commit to qtangs/tortoise-tts that referenced this pull request Nov 22, 2023
manmay-nakhashi added a commit to neonbjb/tortoise-tts that referenced this pull request Nov 22, 2023
Fix for exception on streaming on last chunk - copied from coqui-ai/TTS#3160
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants