-
Notifications
You must be signed in to change notification settings - Fork 701
Compute deltas #268
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
Compute deltas #268
Changes from all commits
cfc5b1f
642cd39
5601fc7
792f536
c989567
4d31759
c36710d
ecc358c
e2814cf
e0433db
d08af7d
c4c3756
4730dfa
b6dbbbc
88b4d5c
0501b9a
6c8d9d5
c8bc3c0
22e9fe0
d3f6958
5aee851
a403ae9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -365,3 +365,30 @@ def forward(self, waveform): | |
return kaldi.resample_waveform(waveform, self.orig_freq, self.new_freq) | ||
|
||
raise ValueError('Invalid resampling method: %s' % (self.resampling_method)) | ||
|
||
|
||
class ComputeDeltas(torch.jit.ScriptModule): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if this depends on the jit mode, it's better to add a jit test to make sure that it works properly. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you have an example of what you have in mind? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You just need to add a text case to ensure every operator is traceable. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was already a test verifying that the shape of the output is correct. I added a test to verify that the output matches the functional, see here. Thanks for pointing out this link, but could you clarify what you would like to verify? If the module were not to compile, the test would not run at all. |
||
r"""Compute delta coefficients of a tensor, usually a spectrogram. | ||
|
||
See `torchaudio.functional.compute_deltas` for more details. | ||
|
||
Args: | ||
win_length (int): The window length used for computing delta. | ||
""" | ||
__constants__ = ['win_length'] | ||
|
||
def __init__(self, win_length=5, mode="replicate"): | ||
super(ComputeDeltas, self).__init__() | ||
self.win_length = win_length | ||
self.mode = torch.jit.Attribute(mode, str) | ||
|
||
@torch.jit.script_method | ||
def forward(self, specgram): | ||
vincentqb marked this conversation as resolved.
Show resolved
Hide resolved
|
||
r""" | ||
Args: | ||
specgram (torch.Tensor): Tensor of audio of dimension (channel, n_mfcc, time) | ||
|
||
Returns: | ||
deltas (torch.Tensor): Tensor of audio of dimension (channel, n_mfcc, time) | ||
""" | ||
return F.compute_deltas(specgram, win_length=self.win_length, mode=self.mode) |
Uh oh!
There was an error while loading. Please reload this page.