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
13e50da9
Unverified
Commit
13e50da9
authored
Nov 21, 2019
by
Vincent QB
Committed by
GitHub
Nov 21, 2019
Browse files
remove explicit signature. (#345)
parent
909e445b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
33 deletions
+17
-33
torchaudio/functional.py
torchaudio/functional.py
+14
-30
torchaudio/transforms.py
torchaudio/transforms.py
+3
-3
No files found.
torchaudio/functional.py
View file @
13e50da9
...
...
@@ -225,10 +225,7 @@ def spectrogram(
waveform
,
pad
,
window
,
n_fft
,
hop_length
,
win_length
,
power
,
normalized
):
# type: (Tensor, int, Tensor, int, int, int, Optional[int], bool) -> Tensor
r
"""
spectrogram(waveform, pad, window, n_fft, hop_length, win_length, power, normalized)
Create a spectrogram or a batch of spectrograms from a raw audio signal.
r
"""Create a spectrogram or a batch of spectrograms from a raw audio signal.
The spectrogram can be either magnitude-only or complex.
Args:
...
...
@@ -275,10 +272,7 @@ def spectrogram(
def
amplitude_to_DB
(
x
,
multiplier
,
amin
,
db_multiplier
,
top_db
=
None
):
# type: (Tensor, float, float, float, Optional[float]) -> Tensor
r
"""
amplitude_to_DB(x, multiplier, amin, db_multiplier, top_db=None)
Turns a tensor from the power/amplitude scale to the decibel scale.
r
"""Turn a tensor from the power/amplitude scale to the decibel scale.
This output depends on the maximum value in the input tensor, and so
may return different values for an audio clip split into snippets vs. a
...
...
@@ -309,10 +303,7 @@ def amplitude_to_DB(x, multiplier, amin, db_multiplier, top_db=None):
def
create_fb_matrix
(
n_freqs
,
f_min
,
f_max
,
n_mels
,
sample_rate
):
# type: (int, float, float, int, int) -> Tensor
r
"""
create_fb_matrix(n_freqs, f_min, f_max, n_mels, sample_rate)
Create a frequency bin conversion matrix.
r
"""Create a frequency bin conversion matrix.
Args:
n_freqs (int): Number of frequencies to highlight/apply
...
...
@@ -354,10 +345,7 @@ def create_fb_matrix(n_freqs, f_min, f_max, n_mels, sample_rate):
def
create_dct
(
n_mfcc
,
n_mels
,
norm
):
# type: (int, int, Optional[str]) -> Tensor
r
"""
create_dct(n_mfcc, n_mels, norm)
Creates a DCT transformation matrix with shape (``n_mels``, ``n_mfcc``),
r
"""Create a DCT transformation matrix with shape (``n_mels``, ``n_mfcc``),
normalized depending on norm.
Args:
...
...
@@ -384,10 +372,7 @@ def create_dct(n_mfcc, n_mels, norm):
def
mu_law_encoding
(
x
,
quantization_channels
):
# type: (Tensor, int) -> Tensor
r
"""
mu_law_encoding(x, quantization_channels)
Encode signal based on mu-law companding. For more info see the
r
"""Encode signal based on mu-law companding. For more info see the
`Wikipedia Entry <https://en.wikipedia.org/wiki/%CE%9C-law_algorithm>`_
This algorithm assumes the signal has been scaled to between -1 and 1 and
...
...
@@ -411,10 +396,7 @@ def mu_law_encoding(x, quantization_channels):
def
mu_law_decoding
(
x_mu
,
quantization_channels
):
# type: (Tensor, int) -> Tensor
r
"""
mu_law_decoding(x_mu, quantization_channels)
Decode mu-law encoded signal. For more info see the
r
"""Decode mu-law encoded signal. For more info see the
`Wikipedia Entry <https://en.wikipedia.org/wiki/%CE%9C-law_algorithm>`_
This expects an input with values between 0 and quantization_channels - 1
...
...
@@ -485,14 +467,17 @@ def phase_vocoder(complex_specgrams, rate, phase_advance):
# type: (Tensor, float, Tensor) -> Tensor
r
"""Given a STFT tensor, speed up in time without modifying pitch by a
factor of ``rate``.
Args:
complex_specgrams (torch.Tensor): Dimension of `(channel, freq, time, complex=2)`
rate (float): Speed-up factor
phase_advance (torch.Tensor): Expected phase advance in each bin. Dimension
of (freq, 1)
Returns:
complex_specgrams_stretch (torch.Tensor): Dimension of `(channel,
freq, ceil(time/rate), complex=2)`
Example
>>> freq, hop_length = 1025, 512
>>> # (channel, freq, time, complex=2)
...
...
@@ -547,8 +532,7 @@ def phase_vocoder(complex_specgrams, rate, phase_advance):
def
lfilter
(
waveform
,
a_coeffs
,
b_coeffs
):
# type: (Tensor, Tensor, Tensor) -> Tensor
r
"""
Performs an IIR filter by evaluating difference equation.
r
"""Perform an IIR filter by evaluating difference equation.
Args:
waveform (torch.Tensor): audio waveform of dimension of `(..., time)`. Must be normalized to -1 to 1.
...
...
@@ -621,7 +605,7 @@ def lfilter(waveform, a_coeffs, b_coeffs):
def
biquad
(
waveform
,
b0
,
b1
,
b2
,
a0
,
a1
,
a2
):
# type: (Tensor, float, float, float, float, float, float) -> Tensor
r
"""Perform
s
a biquad filter of input tensor. Initial conditions set to 0.
r
"""Perform a biquad filter of input tensor. Initial conditions set to 0.
https://en.wikipedia.org/wiki/Digital_biquad_filter
Args:
...
...
@@ -655,7 +639,7 @@ def _dB2Linear(x):
def
highpass_biquad
(
waveform
,
sample_rate
,
cutoff_freq
,
Q
=
0.707
):
# type: (Tensor, int, float, float) -> Tensor
r
"""Design
s
biquad highpass filter and perform
s
filtering. Similar to SoX implementation.
r
"""Design biquad highpass filter and perform filtering. Similar to SoX implementation.
Args:
waveform (torch.Tensor): audio waveform of dimension of `(channel, time)`
...
...
@@ -684,7 +668,7 @@ def highpass_biquad(waveform, sample_rate, cutoff_freq, Q=0.707):
def
lowpass_biquad
(
waveform
,
sample_rate
,
cutoff_freq
,
Q
=
0.707
):
# type: (Tensor, int, float, float) -> Tensor
r
"""Design
s
biquad lowpass filter and perform
s
filtering. Similar to SoX implementation.
r
"""Design biquad lowpass filter and perform filtering. Similar to SoX implementation.
Args:
waveform (torch.Tensor): audio waveform of dimension of `(channel, time)`
...
...
@@ -713,7 +697,7 @@ def lowpass_biquad(waveform, sample_rate, cutoff_freq, Q=0.707):
def
equalizer_biquad
(
waveform
,
sample_rate
,
center_freq
,
gain
,
Q
=
0.707
):
# type: (Tensor, int, float, float, float) -> Tensor
r
"""Design
s
biquad peaking equalizer filter and perform
s
filtering. Similar to SoX implementation.
r
"""Design biquad peaking equalizer filter and perform filtering. Similar to SoX implementation.
Args:
waveform (torch.Tensor): audio waveform of dimension of `(channel, time)`
...
...
torchaudio/transforms.py
View file @
13e50da9
...
...
@@ -68,7 +68,7 @@ class Spectrogram(torch.nn.Module):
class
AmplitudeToDB
(
torch
.
jit
.
ScriptModule
):
r
"""Turn
s
a tensor from the power/amplitude scale to the decibel scale.
r
"""Turn a tensor from the power/amplitude scale to the decibel scale.
This output depends on the maximum value in the input tensor, and so
may return different values for an audio clip split into snippets vs. a
...
...
@@ -107,7 +107,7 @@ class AmplitudeToDB(torch.jit.ScriptModule):
class
MelScale
(
torch
.
nn
.
Module
):
r
"""T
his t
urn
s
a normal STFT into a mel frequency STFT, using a conversion
r
"""Turn a normal STFT into a mel frequency STFT, using a conversion
matrix. This uses triangular filter banks.
User can control which device the filter bank (`fb`) is (e.g. fb.to(spec_f.device)).
...
...
@@ -335,7 +335,7 @@ class MuLawDecoding(torch.nn.Module):
class
Resample
(
torch
.
nn
.
Module
):
r
"""Resample
s
a signal from one frequency to another. A resampling method can
r
"""Resample a signal from one frequency to another. A resampling method can
be given.
Args:
...
...
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