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
ec0b29f5
Commit
ec0b29f5
authored
May 16, 2019
by
Jason Lian
Browse files
update doc
parent
1059c7ca
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
5 deletions
+5
-5
torchaudio/functional.py
torchaudio/functional.py
+4
-5
torchaudio/transforms.py
torchaudio/transforms.py
+1
-0
No files found.
torchaudio/functional.py
View file @
ec0b29f5
...
@@ -18,6 +18,7 @@ __all__ = [
...
@@ -18,6 +18,7 @@ __all__ = [
'mu_law_expanding'
'mu_law_expanding'
]
]
def
scale
(
tensor
,
factor
):
def
scale
(
tensor
,
factor
):
# type: (Tensor, int) -> Tensor
# type: (Tensor, int) -> Tensor
"""Scale audio tensor from a 16-bit integer (represented as a FloatTensor)
"""Scale audio tensor from a 16-bit integer (represented as a FloatTensor)
...
@@ -26,10 +27,10 @@ def scale(tensor, factor):
...
@@ -26,10 +27,10 @@ def scale(tensor, factor):
Inputs:
Inputs:
tensor (Tensor): Tensor of audio of size (Samples x Channels)
tensor (Tensor): Tensor of audio of size (Samples x Channels)
factor (int): Maximum value of input tensor
. default: 16-bit depth
factor (int): Maximum value of input tensor
Outputs:
Outputs:
Tensor: Scaled by the scale factor
. (default between -1.0 and 1.0)
Tensor: Scaled by the scale factor
"""
"""
if
not
tensor
.
dtype
.
is_floating_point
:
if
not
tensor
.
dtype
.
is_floating_point
:
tensor
=
tensor
.
to
(
torch
.
float32
)
tensor
=
tensor
.
to
(
torch
.
float32
)
...
@@ -51,8 +52,6 @@ def pad_trim(tensor, ch_dim, max_len, len_dim, fill_value):
...
@@ -51,8 +52,6 @@ def pad_trim(tensor, ch_dim, max_len, len_dim, fill_value):
Outputs:
Outputs:
Tensor: Padded/trimmed tensor
Tensor: Padded/trimmed tensor
"""
"""
assert
tensor
.
size
(
ch_dim
)
<
128
,
\
"Too many channels ({}) detected, see channels_first param."
.
format
(
tensor
.
size
(
ch_dim
))
if
max_len
>
tensor
.
size
(
len_dim
):
if
max_len
>
tensor
.
size
(
len_dim
):
# tuple of (padding_left, padding_right, padding_top, padding_bottom)
# tuple of (padding_left, padding_right, padding_top, padding_bottom)
# so pad similar to append (aka only right/bottom) and do not pad
# so pad similar to append (aka only right/bottom) and do not pad
...
@@ -109,7 +108,7 @@ def spectrogram(sig, pad, window, n_fft, hop, ws, power, normalize):
...
@@ -109,7 +108,7 @@ def spectrogram(sig, pad, window, n_fft, hop, ws, power, normalize):
window (Tensor): window_tensor
window (Tensor): window_tensor
n_fft (int): size of fft
n_fft (int): size of fft
hop (int): length of hop between STFT windows
hop (int): length of hop between STFT windows
ws (int): window size
. default: n_fft
ws (int): window size
power (int > 0 ) : Exponent for the magnitude spectrogram,
power (int > 0 ) : Exponent for the magnitude spectrogram,
e.g., 1 for energy, 2 for power, etc.
e.g., 1 for energy, 2 for power, etc.
normalize (bool) : whether to normalize by magnitude after stft
normalize (bool) : whether to normalize by magnitude after stft
...
...
torchaudio/transforms.py
View file @
ec0b29f5
...
@@ -4,6 +4,7 @@ import torch
...
@@ -4,6 +4,7 @@ import torch
import
numpy
as
np
import
numpy
as
np
from
.
import
functional
as
F
from
.
import
functional
as
F
class
Compose
(
object
):
class
Compose
(
object
):
"""Composes several transforms together.
"""Composes several transforms together.
...
...
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