diff options
author | Pherkel | 2023-09-11 22:16:26 +0200 |
---|---|---|
committer | Pherkel | 2023-09-11 22:16:26 +0200 |
commit | 64dbb9d32a51b1bce6c9de67069dc8f5943a5399 (patch) | |
tree | 74422120bd33ed39814364801493cb03de8029b0 /swr2_asr/utils | |
parent | 58b30927bd870604a4077a8af9ec3cad7b0be21c (diff) |
added n_feats from config
Diffstat (limited to 'swr2_asr/utils')
-rw-r--r-- | swr2_asr/utils/data.py | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/swr2_asr/utils/data.py b/swr2_asr/utils/data.py index 0e06eec..10f0ea8 100644 --- a/swr2_asr/utils/data.py +++ b/swr2_asr/utils/data.py @@ -15,18 +15,19 @@ from swr2_asr.utils.tokenizer import CharTokenizer class DataProcessing: """Data processing class for the dataloader""" - def __init__(self, data_type: str, tokenizer: CharTokenizer): + def __init__(self, data_type: str, tokenizer: CharTokenizer, hparams: dict): self.data_type = data_type self.tokenizer = tokenizer + n_features = hparams["n_feats"] if data_type == "train": self.audio_transform = torch.nn.Sequential( - torchaudio.transforms.MelSpectrogram(sample_rate=16000, n_mels=128), + torchaudio.transforms.MelSpectrogram(sample_rate=16000, n_mels=n_features), torchaudio.transforms.FrequencyMasking(freq_mask_param=30), torchaudio.transforms.TimeMasking(time_mask_param=100), ) elif data_type == "valid": - self.audio_transform = torchaudio.transforms.MelSpectrogram() + self.audio_transform = torchaudio.transforms.MelSpectrogram(n_mels=n_features) def __call__(self, data) -> tuple[Tensor, Tensor, list, list]: spectrograms = [] |