Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
Torchaudio
Commits
22fe8026
Unverified
Commit
22fe8026
authored
May 20, 2021
by
Caroline Chen
Committed by
GitHub
May 20, 2021
Browse files
Improve resampling documentation (#1519)
parent
7763ed87
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
9 additions
and
12 deletions
+9
-12
torchaudio/compliance/kaldi.py
torchaudio/compliance/kaldi.py
+2
-0
torchaudio/functional/functional.py
torchaudio/functional/functional.py
+4
-9
torchaudio/transforms.py
torchaudio/transforms.py
+3
-3
No files found.
torchaudio/compliance/kaldi.py
View file @
22fe8026
...
@@ -770,6 +770,8 @@ def resample_waveform(waveform: Tensor,
...
@@ -770,6 +770,8 @@ def resample_waveform(waveform: Tensor,
but less efficient. We suggest around 4 to 10 for normal use. (Default: ``6``)
but less efficient. We suggest around 4 to 10 for normal use. (Default: ``6``)
rolloff (float, optional): The roll-off frequency of the filter, as a fraction of the Nyquist.
rolloff (float, optional): The roll-off frequency of the filter, as a fraction of the Nyquist.
Lower values reduce anti-aliasing, but also reduce some of the highest frequencies. (Default: ``0.99``)
Lower values reduce anti-aliasing, but also reduce some of the highest frequencies. (Default: ``0.99``)
resampling_method (str, optional): The resampling method to use.
Options: [``sinc_interpolation``, ``kaiser_window``] (Default: ``'sinc_interpolation'``)
Returns:
Returns:
Tensor: The waveform at the new frequency
Tensor: The waveform at the new frequency
...
...
torchaudio/functional/functional.py
View file @
22fe8026
...
@@ -1424,26 +1424,21 @@ def resample(
...
@@ -1424,26 +1424,21 @@ def resample(
resampling_method
:
str
=
"sinc_interpolation"
,
resampling_method
:
str
=
"sinc_interpolation"
,
beta
:
Optional
[
float
]
=
None
,
beta
:
Optional
[
float
]
=
None
,
)
->
Tensor
:
)
->
Tensor
:
r
"""Resamples the waveform at the new frequency. This matches Kaldi's OfflineFeatureTpl ResampleWaveform
r
"""Resamples the waveform at the new frequency using bandlimited interpolation.
which uses a LinearResample (resample a signal at linearly spaced intervals to upsample/downsample
a signal). LinearResample (LR) means that the output signal is at linearly spaced intervals (i.e
the output signal has a frequency of ``new_freq``). It uses sinc/bandlimited interpolation to
upsample/downsample the signal.
https://ccrma.stanford.edu/~jos/resample/Theory_Ideal_Bandlimited_Interpolation.html
https://ccrma.stanford.edu/~jos/resample/Theory_Ideal_Bandlimited_Interpolation.html
https://github.com/kaldi-asr/kaldi/blob/master/src/feat/resample.h#L56
Args:
Args:
waveform (Tensor): The input signal of dimension (..., time)
waveform (Tensor): The input signal of dimension (..., time)
orig_freq (float): The original frequency of the signal
orig_freq (float): The original frequency of the signal
new_freq (float): The desired frequency
new_freq (float): The desired frequency
lowpass_filter_width (int, optional): Controls the sharpness of the filter, more == sharper
lowpass_filter_width (int, optional): Controls the sharpness of the filter, more == sharper
but less efficient.
We suggest around 4 to 10 for normal use.
(Default: ``6``)
but less efficient. (Default: ``6``)
rolloff (float, optional): The roll-off frequency of the filter, as a fraction of the Nyquist.
rolloff (float, optional): The roll-off frequency of the filter, as a fraction of the Nyquist.
Lower values reduce anti-aliasing, but also reduce some of the highest frequencies. (Default: ``0.99``)
Lower values reduce anti-aliasing, but also reduce some of the highest frequencies. (Default: ``0.99``)
resampling_method (str, optional): The resampling method.
resampling_method (str, optional): The resampling method
to use
.
Options: [``sinc_interpolation``, ``kaiser_window``] (Default: ``'sinc_interpolation'``)
Options: [``sinc_interpolation``, ``kaiser_window``] (Default: ``'sinc_interpolation'``)
beta (float
,
o
ptional
): The shape parameter used for kaiser window.
beta (float o
r None
): The shape parameter used for kaiser window.
Returns:
Returns:
Tensor: The waveform at the new frequency of dimension (..., time).
Tensor: The waveform at the new frequency of dimension (..., time).
...
...
torchaudio/transforms.py
View file @
22fe8026
...
@@ -666,13 +666,13 @@ class Resample(torch.nn.Module):
...
@@ -666,13 +666,13 @@ class Resample(torch.nn.Module):
Args:
Args:
orig_freq (float, optional): The original frequency of the signal. (Default: ``16000``)
orig_freq (float, optional): The original frequency of the signal. (Default: ``16000``)
new_freq (float, optional): The desired frequency. (Default: ``16000``)
new_freq (float, optional): The desired frequency. (Default: ``16000``)
resampling_method (str, optional): The resampling method.
resampling_method (str, optional): The resampling method
to use
.
Options: [``sinc_interpolation``, ``kaiser_window``] (Default: ``'sinc_interpolation'``)
Options: [``sinc_interpolation``, ``kaiser_window``] (Default: ``'sinc_interpolation'``)
lowpass_filter_width (int, optional): Controls the sharpness of the filter, more == sharper
lowpass_filter_width (int, optional): Controls the sharpness of the filter, more == sharper
but less efficient.
We suggest around 4 to 10 for normal use.
(Default: ``6``)
but less efficient. (Default: ``6``)
rolloff (float, optional): The roll-off frequency of the filter, as a fraction of the Nyquist.
rolloff (float, optional): The roll-off frequency of the filter, as a fraction of the Nyquist.
Lower values reduce anti-aliasing, but also reduce some of the highest frequencies. (Default: ``0.99``)
Lower values reduce anti-aliasing, but also reduce some of the highest frequencies. (Default: ``0.99``)
beta (float
,
o
ptional
): The shape parameter used for kaiser window.
beta (float o
r None
): The shape parameter used for kaiser window.
Note: If resampling on waveforms of higher precision than float32, there may be a small loss of precision
Note: If resampling on waveforms of higher precision than float32, there may be a small loss of precision
because the kernel is cached once as float32. If high precision resampling is important for your application,
because the kernel is cached once as float32. If high precision resampling is important for your application,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment