| | |
| | | from typing import Iterator |
| | | from typing import Tuple |
| | | from typing import Union |
| | | from typing import List |
| | | |
| | | import kaldiio |
| | | import numpy as np |
| | |
| | | non_iterable_list = [] |
| | | self.path_name_type_list = [] |
| | | |
| | | if not isinstance(path_name_type_list[0], Tuple): |
| | | if not isinstance(path_name_type_list[0], (Tuple, List)): |
| | | path = path_name_type_list[0] |
| | | name = path_name_type_list[1] |
| | | _type = path_name_type_list[2] |
| | |
| | | array = torch.from_numpy(array) |
| | | array = torchaudio.transforms.Resample(orig_freq=audio_fs, |
| | | new_freq=model_fs)(array) |
| | | if self.mc: |
| | | data[name] = array.transpose(0, 1).numpy() |
| | | array = array.numpy() |
| | | |
| | | if _type == "sound": |
| | | if self.mc: |
| | | data[name] = array.transpose((1, 0)) |
| | | else: |
| | | data[name] = array[0] |
| | | else: |
| | | data[name] = array[0].numpy() |
| | | data[name] = array |
| | | |
| | | if self.preprocess is not None: |
| | | data = self.preprocess(uid, data) |
| | |
| | | array = torch.from_numpy(array) |
| | | array = torchaudio.transforms.Resample(orig_freq=audio_fs, |
| | | new_freq=model_fs)(array) |
| | | array = array.numpy() |
| | | if _type == "sound": |
| | | if self.mc: |
| | | data[name] = array.transpose(0, 1).numpy() |
| | | data[name] = array.transpose((1, 0)) |
| | | else: |
| | | data[name] = array[0].numpy() |
| | | data[name] = array[0] |
| | | else: |
| | | data[name] = array |
| | | if self.non_iterable_dataset is not None: |