Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -891,7 +891,12 @@ def chunked_decode(self, codes, chunk_size=300, left_context_size=25):
context_size = left_context_size if start_index - left_context_size > 0 else start_index
codes_chunk = codes[..., start_index - context_size : end_index]
wav_chunk = self(codes_chunk)
wavs.append(wav_chunk[..., context_size * self.total_upsample :])
# The causal decoder may produce fewer samples than context_size * total_upsample
# due to implicit delays in causal convolutions. Taking the last sample_count samples
# from wav_chunk is more robust than slicing from a fixed offset, which can
# over-remove samples when the decoder output is shorter than expected.
sample_count = min((end_index - start_index) * self.total_upsample, wav_chunk.shape[-1])
wavs.append(wav_chunk[..., -sample_count:])
start_index = end_index
return torch.cat(wavs, dim=-1)

Expand Down