From 219c2482ab755fbd4e49dfbdee91bf1a8a4ec49a Mon Sep 17 00:00:00 2001
From: 游雁 <zhifu.gzf@alibaba-inc.com>
Date: 星期五, 19 五月 2023 11:33:27 +0800
Subject: [PATCH] websocket 2pass bugfix
---
funasr/fileio/sound_scp.py | 11 ++++++++---
1 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/funasr/fileio/sound_scp.py b/funasr/fileio/sound_scp.py
index 11d582c..c752fe6 100644
--- a/funasr/fileio/sound_scp.py
+++ b/funasr/fileio/sound_scp.py
@@ -8,6 +8,7 @@
import librosa
from typeguard import check_argument_types
+import torch
import torchaudio
from funasr.fileio.read_text import read_2column_text
@@ -51,19 +52,23 @@
if self.normalize:
# soundfile.read normalizes data to [-1,1] if dtype is not given
array, rate = librosa.load(
- wav, sr=self.dest_sample_rate, mono=not self.always_2d
+ wav, sr=self.dest_sample_rate, mono=self.always_2d
)
else:
array, rate = librosa.load(
- wav, sr=self.dest_sample_rate, mono=not self.always_2d, dtype=self.dtype
+ wav, sr=self.dest_sample_rate, mono=self.always_2d, dtype=self.dtype
)
if self.speed_perturb is not None:
speed = random.choice(self.speed_perturb)
if speed != 1.0:
array, _ = torchaudio.sox_effects.apply_effects_tensor(
- array, rate,
+ torch.tensor(array).view(1, -1), rate,
[['speed', str(speed)], ['rate', str(rate)]])
+ array = array.view(-1).numpy()
+
+ if array.ndim==2:
+ array=array.transpose((1, 0))
return rate, array
--
Gitblit v1.9.1