Skip to content
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

Call torch.stft directly #531

Merged
merged 3 commits into from
Apr 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 4 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ cache:
matrix:
fast_finish: true
include:
- env: PYTHON_VERSION="3.5"
- env: PYTHON_VERSION="3.6"
- env: PYTHON_VERSION="3.7"
- env: PYTHON_VERSION="3.5" RUN_FLAKE8="true" SKIP_INSTALL="true" SKIP_TESTS="true"
- env: PYTHON_VERSION="3.5" RUN_EXAMPLE_TESTS="true" SKIP_TESTS="true"
- env: PYTHON_VERSION="3.8"
- env: PYTHON_VERSION="3.6" RUN_FLAKE8="true" SKIP_INSTALL="true" SKIP_TESTS="true"
- env: PYTHON_VERSION="3.6" RUN_EXAMPLE_TESTS="true" SKIP_TESTS="true"
allow_failures:
- env: PYTHON_VERSION="3.5" RUN_EXAMPLE_TESTS="true" SKIP_TESTS="true"
- env: PYTHON_VERSION="3.6" RUN_EXAMPLE_TESTS="true" SKIP_TESTS="true"

addons:
apt:
Expand Down
1 change: 1 addition & 0 deletions build_tools/travis/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ popd
source activate testenv

# Install requirements via pip in our conda environment
conda install -y pytorch cpuonly -c pytorch-nightly
pip install -r requirements.txt

# Install the following only if running tests
Expand Down
1 change: 1 addition & 0 deletions build_tools/travis/test_script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
set -e

python --version
python -c 'import torch;print("torch:", torch.__version__)'

run_tests() {
# find all the test files that match "test*.py"
Expand Down
5 changes: 1 addition & 4 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
torch>=1.2.0
torch>=1.4.0

# Required for Windows because it's the only available backend
SoundFile; sys_platform == 'win32'
Expand All @@ -18,6 +18,3 @@ scipy

# Unit tests with pytest
pytest

# Testing only Py3 compat
backports.tempfile
32 changes: 3 additions & 29 deletions torchaudio/functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,32 +36,6 @@
]


# TODO: remove this once https://github.com/pytorch/pytorch/issues/21478 gets solved
@torch.jit.ignore
def _stft(
waveform: Tensor,
n_fft: int,
hop_length: Optional[int],
win_length: Optional[int],
window: Optional[Tensor],
center: bool,
pad_mode: str,
normalized: bool,
onesided: bool
) -> Tensor:
return torch.stft(
waveform,
n_fft,
hop_length,
win_length,
window,
center,
pad_mode,
normalized,
onesided,
)


def istft(
stft_matrix: Tensor,
n_fft: int,
Expand Down Expand Up @@ -265,7 +239,7 @@ def spectrogram(
waveform = waveform.view(-1, shape[-1])

# default values are consistent with librosa.core.spectrum._spectrogram
spec_f = _stft(
spec_f = torch.stft(
waveform, n_fft, hop_length, win_length, window, True, "reflect", False, True
)

Expand Down Expand Up @@ -365,8 +339,8 @@ def griffinlim(
length=length).float()

# Rebuild the spectrogram
rebuilt = _stft(inverse, n_fft, hop_length, win_length, window,
True, 'reflect', False, True)
rebuilt = torch.stft(inverse, n_fft, hop_length, win_length, window,
True, 'reflect', False, True)

# Update our phase estimates
angles = rebuilt - tprev.mul_(momentum / (1 + momentum))
Expand Down