-
-
Notifications
You must be signed in to change notification settings - Fork 813
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
feat: Using torchaudio for IO #492
Conversation
Looks like the inference needs refactoring as well |
Running the tests I'm getting when the inference notebook is being run.
|
Looks like the data output by inference contains lots of NaNs so pyannote.core cannot display it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I reviewed everything but inference
.
Why? It is late and I need to sleep but also I would like to know your thoughts on updating the shape of model output from (num_frames, num_classes) to (num_classes, num_frames) to be coherent with the new (num_channels, num_samples) input shape.
Co-authored-by: Hervé BREDIN <[email protected]>
Co-authored-by: Hervé BREDIN <[email protected]>
Co-authored-by: Hervé BREDIN <[email protected]>
Co-authored-by: Hervé BREDIN <[email protected]>
Co-authored-by: Hervé BREDIN <[email protected]>
pyannote/audio/core/io.py
Outdated
@staticmethod | ||
def normalize(waveform: np.ndarray) -> np.ndarray: | ||
return waveform / (np.sqrt(np.mean(waveform ** 2)) + 1e-8) | ||
def normalize(waveform: Tensor) -> Tensor: | ||
""" | ||
|
||
Parameters | ||
---------- | ||
waveform : (channel, time) Tensor | ||
Single or multichannel waveform | ||
|
||
|
||
Returns | ||
------- | ||
waveform: (channel, time) Tensor | ||
""" | ||
|
||
means = waveform.mean(dim=1)[:, None] | ||
stds = waveform.std(dim=1)[:, None] | ||
return (waveform - means) / (stds + 1e-8) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, this is not the same. normalize
is not meant as standardize
(mean substraction and putting variance to one).
It is meant as normalizing the power of the signal so that we can later control the signal-to-noise ratio when summing two chunks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, I think torchaudio does that out of the box? https://github.com/pytorch/audio/blob/3b9e93372dd48649624ac2bbf660bb2e3384820e/torchaudio/backend/_soundfile_backend.py#L93
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not the same thing. My understanding is that torchaudio
divides waveform
by max(abs(waveform))
so that it lies in [-1., 1.] interval. My normalize
computes a different thing.
🍾 🥳 Thanks! |
FYI, there is a out-of-bound bug in |
Closes #484