fix loading multi-channel mp3 file bug
| | |
| | | try: |
| | | raw_inputs = torchaudio.load(data_path_and_name_and_type[0])[0][0] |
| | | except: |
| | | raw_inputs = torch.tensor(soundfile.read(data_path_and_name_and_type[0])[0]) |
| | | raw_inputs = soundfile.read(data_path_and_name_and_type[0], dtype='float32')[0] |
| | | if raw_inputs.ndim == 2: |
| | | raw_inputs = raw_inputs[:, 0] |
| | | raw_inputs = torch.tensor(raw_inputs) |
| | | if data_path_and_name_and_type is None and raw_inputs is not None: |
| | | if isinstance(raw_inputs, np.ndarray): |
| | | raw_inputs = torch.tensor(raw_inputs) |
| | |
| | | try: |
| | | return torchaudio.load(input)[0].numpy() |
| | | except: |
| | | return np.expand_dims(soundfile.read(input)[0], axis=0) |
| | | waveform, _ = soundfile.read(input, dtype='float32') |
| | | if waveform.ndim == 2: |
| | | waveform = waveform[:, 0] |
| | | return np.expand_dims(waveform, axis=0) |
| | | |
| | | DATA_TYPES = { |
| | | "sound": load_wav, |
| | |
| | | try: |
| | | waveform, sampling_rate = torchaudio.load(path) |
| | | except: |
| | | waveform, sampling_rate = soundfile.read(path) |
| | | waveform, sampling_rate = soundfile.read(path, dtype='float32') |
| | | if waveform.ndim == 2: |
| | | waveform = waveform[:, 0] |
| | | waveform = np.expand_dims(waveform, axis=0) |
| | | waveform = torch.tensor(waveform) |
| | | if self.frontend_conf is not None: |
| | |
| | | try: |
| | | waveform, audio_sr = torchaudio.load(wav_file) |
| | | except: |
| | | waveform, audio_sr = soundfile.read(wav_file) |
| | | waveform, audio_sr = soundfile.read(wav_file, dtype='float32') |
| | | if waveform.ndim == 2: |
| | | waveform = waveform[:, 0] |
| | | waveform = torch.tensor(np.expand_dims(waveform, axis=0)) |
| | | waveform = waveform * (1 << 15) |
| | | waveform = torch_resample(waveform, audio_sr, model_sr) |