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

RuntimeError: Sizes of tensors must match except in dimension 0. Expected size 80000 but got size 79659 for tensor number 30 in the list #1324

Closed
Pkoiralap opened this issue Apr 11, 2023 · 3 comments
Labels

Comments

@Pkoiralap
Copy link

I was experiencing this issue and was able to solve it using guard rails around the waveform creation process. However, I believe there should be a better way to do this and that's why I am not creating a PR with the fix. If you think this fix works, I can submit a PR.

So in the audio/pipelines/speaker_diarization.py file. i.e. this bit here:

# chunk: Segment(t, t + duration)
# masks: (num_frames, local_num_speakers) np.ndarray
waveform, _ = self._audio.crop(
    file,
    chunk,
    duration=duration,
    mode="pad",
)
# waveform: (1, num_samples) torch.Tensor
...

creates a tensor of a different size than what is expected. The simple fix I am using for now is:

# chunk: Segment(t, t + duration)
# masks: (num_frames, local_num_speakers) np.ndarray
waveform, _ = self._audio.crop(
    file,
    chunk,
    duration=duration,
    mode="pad",
)
# waveform: (1, num_samples) torch.Tensor
if waveform.shape[1] < num_samples:
    pad_num = int(num_samples - waveform.shape[1])
    waveform = torch.nn.functional.pad(waveform, (0, pad_num), "constant", 0)

This is hacky, but it works for me. Also because I didn't have a lot of time reading through the code, I am not sure if this is the right fix for the problem. As I said earlier, depending on whether this is a 'good' fix, I can create a PR accordingly.

Thanks

@github-actions
Copy link

Thank you for your issue. Give us a little time to review it.

PS. You might want to check the FAQ if you haven't done so already.

This is an automated reply, generated by FAQtory

@hbredin
Copy link
Member

hbredin commented Apr 12, 2023

Would you mind narrowing down when this problem occurs?

This is most likely a bug in the implementation of the mode="pad" option which is already supposed to handle this corner case...

@stale
Copy link

stale bot commented Oct 9, 2023

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants