From 07b9b9baae36d7e78c2c58a8796aaa8644ed85b1 Mon Sep 17 00:00:00 2001 From: "Edward Z. Yang" Date: Tue, 30 Jul 2019 17:35:16 -0400 Subject: [PATCH 1/2] Make test scripts runnable without being modules. (#186) This makes it easier to test against an installed wheel, as the torchaudio folder is no longer preferentially picked up when you run a test module. I had to move all tests in subfolders into the top level test directory to make this work, since you can't access .. modules without mucking around with sys.path (which I don't want to do.) NB: this BREAKS the syntax where you can run a test by saying `python -m test.test`. Instead, do `python test/test.py` or use the pytest runner. Signed-off-by: Edward Z. Yang --- test/{ => compliance}/__init__.py | 0 test/test.py | 4 ++-- .../test_kaldi.py => test_compliance_kaldi.py} | 10 +++++----- test/test_dataloader.py | 4 ++-- test/{datasets/test_vctk.py => test_datasets_vctk.py} | 4 ++-- test/test_functional.py | 4 ++-- test/test_kaldi_io.py | 4 ++-- test/test_legacy.py | 4 ++-- test/test_sox_effects.py | 4 ++-- test/test_transforms.py | 4 ++-- 10 files changed, 21 insertions(+), 21 deletions(-) rename test/{ => compliance}/__init__.py (100%) rename test/{compliance/test_kaldi.py => test_compliance_kaldi.py} (97%) rename test/{datasets/test_vctk.py => test_datasets_vctk.py} (94%) diff --git a/test/__init__.py b/test/compliance/__init__.py similarity index 100% rename from test/__init__.py rename to test/compliance/__init__.py diff --git a/test/test.py b/test/test.py index 0348a1c3a5..a26c379905 100644 --- a/test/test.py +++ b/test/test.py @@ -1,5 +1,5 @@ import unittest -import test.common_utils +import common_utils import torch import torchaudio import math @@ -7,7 +7,7 @@ class Test_LoadSave(unittest.TestCase): - test_dirpath, test_dir = test.common_utils.create_temp_assets_dir() + test_dirpath, test_dir = common_utils.create_temp_assets_dir() test_filepath = os.path.join(test_dirpath, "assets", "steam-train-whistle-daniel_simon.mp3") diff --git a/test/compliance/test_kaldi.py b/test/test_compliance_kaldi.py similarity index 97% rename from test/compliance/test_kaldi.py rename to test/test_compliance_kaldi.py index 0cd2e37ed5..9e235212df 100644 --- a/test/compliance/test_kaldi.py +++ b/test/test_compliance_kaldi.py @@ -1,7 +1,7 @@ import math import os -import test.common_utils -import test.compliance.utils +import common_utils +import compliance.utils import torch import torchaudio import torchaudio.compliance.kaldi as kaldi @@ -45,11 +45,11 @@ def first_sample_of_frame(frame, window_size, window_shift, snip_edges): class Test_Kaldi(unittest.TestCase): - test_dirpath, test_dir = test.common_utils.create_temp_assets_dir() + test_dirpath, test_dir = common_utils.create_temp_assets_dir() test_filepath = os.path.join(test_dirpath, 'assets', 'kaldi_file.wav') test_8000_filepath = os.path.join(test_dirpath, 'assets', 'kaldi_file_8000.wav') kaldi_output_dir = os.path.join(test_dirpath, 'assets', 'kaldi') - test_filepaths = {prefix: [] for prefix in test.compliance.utils.TEST_PREFIX} + test_filepaths = {prefix: [] for prefix in compliance.utils.TEST_PREFIX} # separating test files by their types (e.g 'spec', 'fbank', etc.) for f in os.listdir(kaldi_output_dir): @@ -151,7 +151,7 @@ def _compliance_test_helper(self, sound_filepath, filepath_key, expected_num_fil args = f.split('-') args[-1] = os.path.splitext(args[-1])[0] assert len(args) == expected_num_args, 'invalid test kaldi file name' - args = [test.compliance.utils.parse(arg) for arg in args] + args = [compliance.utils.parse(arg) for arg in args] output = get_output_fn(sound, args) diff --git a/test/test_dataloader.py b/test/test_dataloader.py index 46e5858c7a..f0c2f33442 100644 --- a/test/test_dataloader.py +++ b/test/test_dataloader.py @@ -1,5 +1,5 @@ import unittest -import test.common_utils +import common_utils import torch import torch.nn as nn from torch.utils.data import Dataset, DataLoader @@ -10,7 +10,7 @@ class TORCHAUDIODS(Dataset): - test_dirpath, test_dir = test.common_utils.create_temp_assets_dir() + test_dirpath, test_dir = common_utils.create_temp_assets_dir() def __init__(self): self.asset_dirpath = os.path.join(self.test_dirpath, "assets") diff --git a/test/datasets/test_vctk.py b/test/test_datasets_vctk.py similarity index 94% rename from test/datasets/test_vctk.py rename to test/test_datasets_vctk.py index 64907ea3e8..c205701bb5 100644 --- a/test/datasets/test_vctk.py +++ b/test/test_datasets_vctk.py @@ -3,13 +3,13 @@ import torch import torchaudio import unittest -import test.common_utils +import common_utils import torchaudio.datasets.vctk as vctk class TestVCTK(unittest.TestCase): def setUp(self): - self.test_dirpath, self.test_dir = test.common_utils.create_temp_assets_dir() + self.test_dirpath, self.test_dir = common_utils.create_temp_assets_dir() def get_full_path(self, file): return os.path.join(self.test_dirpath, 'assets', file) diff --git a/test/test_functional.py b/test/test_functional.py index 02b01620ed..f5571b1162 100644 --- a/test/test_functional.py +++ b/test/test_functional.py @@ -5,7 +5,7 @@ import torchaudio.functional as F import pytest import unittest -import test.common_utils +import common_utils from torchaudio.common_utils import IMPORT_LIBROSA @@ -30,7 +30,7 @@ def _test_istft_is_inverse_of_stft(self, kwargs): # operation to check whether we can reconstruct signal for data_size in self.data_sizes: for i in range(self.number_of_trials): - sound = test.common_utils.random_float_tensor(i, data_size) + sound = common_utils.random_float_tensor(i, data_size) stft = torch.stft(sound, **kwargs) estimate = torchaudio.functional.istft(stft, length=sound.size(1), **kwargs) diff --git a/test/test_kaldi_io.py b/test/test_kaldi_io.py index 08aeff54f6..f4ff557e56 100644 --- a/test/test_kaldi_io.py +++ b/test/test_kaldi_io.py @@ -2,13 +2,13 @@ import torch import torchaudio.kaldi_io as kio import unittest -import test.common_utils +import common_utils class Test_KaldiIO(unittest.TestCase): data1 = [[1, 2, 3], [11, 12, 13], [21, 22, 23]] data2 = [[31, 32, 33], [41, 42, 43], [51, 52, 53]] - test_dirpath, test_dir = test.common_utils.create_temp_assets_dir() + test_dirpath, test_dir = common_utils.create_temp_assets_dir() def _test_helper(self, file_name, expected_data, fn, expected_dtype): """ Takes a file_name to the input data and a function fn to extract the diff --git a/test/test_legacy.py b/test/test_legacy.py index 83af035daa..28e0b62432 100644 --- a/test/test_legacy.py +++ b/test/test_legacy.py @@ -1,5 +1,5 @@ import unittest -import test.common_utils +import common_utils import torch import torchaudio from torchaudio.legacy import save, load @@ -8,7 +8,7 @@ class Test_LoadSave(unittest.TestCase): - test_dirpath, test_dir = test.common_utils.create_temp_assets_dir() + test_dirpath, test_dir = common_utils.create_temp_assets_dir() test_filepath = os.path.join(test_dirpath, "assets", "steam-train-whistle-daniel_simon.mp3") diff --git a/test/test_sox_effects.py b/test/test_sox_effects.py index 2b35a841be..6ebc6eda4b 100644 --- a/test/test_sox_effects.py +++ b/test/test_sox_effects.py @@ -1,5 +1,5 @@ import unittest -import test.common_utils +import common_utils import torch import torchaudio import math @@ -7,7 +7,7 @@ class Test_SoxEffectsChain(unittest.TestCase): - test_dirpath, test_dir = test.common_utils.create_temp_assets_dir() + test_dirpath, test_dir = common_utils.create_temp_assets_dir() test_filepath = os.path.join(test_dirpath, "assets", "steam-train-whistle-daniel_simon.mp3") diff --git a/test/test_transforms.py b/test/test_transforms.py index b15ba40b94..a5a02e9ba5 100644 --- a/test/test_transforms.py +++ b/test/test_transforms.py @@ -7,7 +7,7 @@ from torchaudio.common_utils import IMPORT_LIBROSA, IMPORT_SCIPY import torchaudio.transforms as transforms import unittest -import test.common_utils +import common_utils if IMPORT_LIBROSA: import librosa @@ -26,7 +26,7 @@ class Tester(unittest.TestCase): waveform.unsqueeze_(0) # (1, 64000) waveform = (waveform * volume * 2**31).long() # file for stereo stft test - test_dirpath, test_dir = test.common_utils.create_temp_assets_dir() + test_dirpath, test_dir = common_utils.create_temp_assets_dir() test_filepath = os.path.join(test_dirpath, 'assets', 'steam-train-whistle-daniel_simon.mp3') From 53a9fd1350a3a82a4a668d409cd3a86c2dc5bb68 Mon Sep 17 00:00:00 2001 From: jamarshon Date: Wed, 31 Jul 2019 13:54:23 -0400 Subject: [PATCH 2/2] Binary install instructions (#191) --- README.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/README.md b/README.md index bd543cdd03..f5207a791c 100644 --- a/README.md +++ b/README.md @@ -47,6 +47,29 @@ conda install -c conda-forge sox Installation ------------ +### Binaries + +To install pip wheels of 0.2.0, select the appropriate pip wheel for +your version of Python: + +``` +# Wheels for Python 2 are NOT supported + +# Python 3.5 +pip3 install http://download.pytorch.org/whl/torchaudio-0.2-cp35-cp35m-linux_x86_64.whl + +# Python 3.6 +pip3 install http://download.pytorch.org/whl/torchaudio-0.2-cp36-cp36m-linux_x86_64.whl + +# Python 3.7 +pip3 install http://download.pytorch.org/whl/torchaudio-0.2-cp37-cp37m-linux_x86_64.whl +``` + +### From Source + +If your system configuration is not among the supported configurations +above, you can build from source. + ```bash # Linux python setup.py install