From c568628130ac42ebeea8cf48fe926520a31ff511 Mon Sep 17 00:00:00 2001
From: 嘉渊 <wangjiaming.wjm@alibaba-inc.com>
Date: 星期二, 16 五月 2023 10:57:21 +0800
Subject: [PATCH] update repo

---
 funasr/fileio/sound_scp.py |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/funasr/fileio/sound_scp.py b/funasr/fileio/sound_scp.py
index cec7cd9..7b35a35 100644
--- a/funasr/fileio/sound_scp.py
+++ b/funasr/fileio/sound_scp.py
@@ -1,7 +1,6 @@
 import collections.abc
 from pathlib import Path
 from typing import Union
-from typing import Optional
 
 import random
 import numpy as np
@@ -9,6 +8,7 @@
 import librosa
 from typeguard import check_argument_types
 
+import torch
 import torchaudio
 
 from funasr.fileio.read_text import read_2column_text
@@ -36,7 +36,7 @@
         always_2d: bool = False,
         normalize: bool = False,
         dest_sample_rate: int = 16000,
-        speed_perturb: Optional[list, tuple] = None,
+        speed_perturb: Union[list, tuple] = None,
     ):
         assert check_argument_types()
         self.fname = fname
@@ -63,8 +63,9 @@
             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()
 
         return rate, array
 

--
Gitblit v1.9.1