From 8e740e9897834c77e2475790741b330c18e518dc Mon Sep 17 00:00:00 2001
From: season <season4675@gmail.com>
Date: 星期日, 02 七月 2023 19:38:48 +0800
Subject: [PATCH] [funasr-runtime-deploy 0.0.4] streamline the process, and add command line parameters. (#697)
---
funasr/utils/prepare_data.py | 7 ++++++-
1 files changed, 6 insertions(+), 1 deletions(-)
diff --git a/funasr/utils/prepare_data.py b/funasr/utils/prepare_data.py
index 7602740..0e773bb 100644
--- a/funasr/utils/prepare_data.py
+++ b/funasr/utils/prepare_data.py
@@ -7,6 +7,7 @@
import numpy as np
import torch.distributed as dist
import torchaudio
+import soundfile
def filter_wav_text(data_dir, dataset):
@@ -42,7 +43,11 @@
def wav2num_frame(wav_path, frontend_conf):
- waveform, sampling_rate = torchaudio.load(wav_path)
+ try:
+ waveform, sampling_rate = torchaudio.load(wav_path)
+ except:
+ waveform, sampling_rate = soundfile.read(wav_path)
+ waveform = np.expand_dims(waveform, axis=0)
n_frames = (waveform.shape[1] * 1000.0) / (sampling_rate * frontend_conf["frame_shift"] * frontend_conf["lfr_n"])
feature_dim = frontend_conf["n_mels"] * frontend_conf["lfr_m"]
return n_frames, feature_dim
--
Gitblit v1.9.1