| | |
| | | import numpy as np |
| | | import kaldiio |
| | | import librosa |
| | | |
| | | |
| | | import torchaudio |
| | | import time |
| | | |
| | | def load_audio(audio_path: str, fs: int=16000): |
| | | audio = None |
| | |
| | | if ".ark:" in audio_path: |
| | | audio = kaldiio.load_mat(audio_path) |
| | | else: |
| | | audio, fs = librosa.load(audio_path, sr=fs) |
| | | # audio, fs = librosa.load(audio_path, sr=fs) |
| | | audio, fs = torchaudio.load(audio_path) |
| | | audio = audio[0, :] |
| | | return audio |
| | | |
| | | def extract_features(data, date_type: str="sound", frontend=None): |
| | |
| | | |
| | | def __getitem__(self, index): |
| | | return self.contents[index] |
| | | |
| | | def get_source_len(self, data_dict): |
| | | return data_dict["source_len"] |
| | | |
| | | def get_target_len(self, data_dict): |
| | | |
| | | return data_dict["target_len"] if "target_len" in data_dict else 0 |
| | | |
| | | |
| | | class AudioDataset(torch.utils.data.Dataset): |