Skip to content

Commit

Permalink
remove wav effects
Browse files Browse the repository at this point in the history
  • Loading branch information
Caroline Chen committed Apr 8, 2022
1 parent 3d1bea1 commit bf81a63
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 16 deletions.
13 changes: 5 additions & 8 deletions test/torchaudio_unittest/datasets/quesst14_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

from parameterized import parameterized
from torchaudio.datasets import quesst14
from torchaudio.sox_effects import apply_effects_tensor
from torchaudio_unittest.common_utils import (
TempDirMixin,
TorchaudioTestCase,
Expand Down Expand Up @@ -39,18 +38,14 @@ def _save_sample(dataset_dir, folder, language, index, sample_rate, seed):
filename = _get_filename(folder, index)
file_path = os.path.join(path, filename)

raw_data = get_whitenoise(
data = get_whitenoise(
sample_rate=sample_rate,
duration=0.01,
n_channels=1,
seed=seed,
)
save_wav(file_path, raw_data, sample_rate)
save_wav(file_path, data, sample_rate)

data, _ = apply_effects_tensor(
raw_data,
sample_rate=sample_rate,
)
sample = (data.squeeze(0), Path(file_path).with_suffix("").name)

# add audio files and language data to language key files
Expand Down Expand Up @@ -90,7 +85,7 @@ def get_mock_dataset(dataset_dir):
dataset_dir: directory to the mocked dataset
"""
os.makedirs(dataset_dir, exist_ok=True)
sample_rate = 16000
sample_rate = 8000

audio_seed = 0
dev_seed = 1
Expand All @@ -114,6 +109,8 @@ def get_mock_dataset(dataset_dir):

class TestQuesst14(TempDirMixin, TorchaudioTestCase):
root_dir = None
backend = "default"

utterances = {}
dev_samples = {}
eval_samples = {}
Expand Down
10 changes: 2 additions & 8 deletions torchaudio/datasets/quesst14.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
from typing import Tuple, Union, Optional

import torch
import torchaudio
from torch.hub import download_url_to_file
from torch.utils.data import Dataset
from torchaudio.datasets.utils import extract_archive
from torchaudio.sox_effects import apply_effects_file


URL = "https://speech.fit.vutbr.cz/files/quesst14Database.tgz"
Expand Down Expand Up @@ -78,13 +78,7 @@ def __init__(

def _load_sample(self, n: int) -> Tuple[torch.Tensor, str]:
audio_path = self.data[n]
wav, _ = apply_effects_file(
str(audio_path),
[
["channels", "1"],
["rate", "16000"],
],
)
wav, _ = torchaudio.load(audio_path)
wav = wav.squeeze(0)
return wav, audio_path.with_suffix("").name

Expand Down

0 comments on commit bf81a63

Please sign in to comment.