From a0defaf40e62417a76b954819dc8119290ea9ab1 Mon Sep 17 00:00:00 2001
From: haoneng.lhn <haoneng.lhn@alibaba-inc.com>
Date: 星期二, 27 六月 2023 13:12:42 +0800
Subject: [PATCH] fix loading multi-channel mp3 file bug
---
funasr/utils/wav_utils.py | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/funasr/utils/wav_utils.py b/funasr/utils/wav_utils.py
index a6e394f..e523495 100644
--- a/funasr/utils/wav_utils.py
+++ b/funasr/utils/wav_utils.py
@@ -166,7 +166,9 @@
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)
--
Gitblit v1.9.1