Open-source speech recognition toolkit for training, inference, streaming ASR, VAD, punctuation, speaker diarization pipelines, and OpenAI-compatible/MCP serving.
Python asraudiochineseemotion-recognitionfunasrmcp-servermultilingual-asropenai-compatible-apiparaformerpunctuationpytorchreal-time-asrspeaker-diarizationspeech-recognitionspeech-to-textstreaming-asrtranscriptionvllmvoice-activity-detectionwhisper-alternative
update
嘉渊7f7c23c36fab
diff --git a/funasr/datasets/small_datasets/dataset.py b/funasr/datasets/small_datasets/dataset.pyindex a7017a5c4..a6c678aee 100644--- a/funasr/datasets/small_datasets/dataset.py+++ b/funasr/datasets/small_datasets/dataset.py@@ -110,6 +110,7 @@ class ESPnetDataset(Dataset):float_dtype: str = "float32",int_dtype: str = "long",dest_sample_rate: int = 16000,+ speed_perturb: tuple = None,):assert check_argument_types()if len(path_name_type_list) == 0:@@ -123,6 +124,7 @@ class ESPnetDataset(Dataset):self.float_dtype = float_dtypeself.int_dtype = int_dtypeself.dest_sample_rate = dest_sample_rate+ self.speed_perturb = speed_perturbself.loader_dict = {}self.debug_info = {}@@ -146,7 +148,7 @@ class ESPnetDataset(Dataset):loader_type: loader_type. sound, npy, text, etc"""if loader_type == "sound":- loader = SoundScpReader(path, self.dest_sample_rate, normalize=True, always_2d=False)+ loader = SoundScpReader(path, self.dest_sample_rate, normalize=True, always_2d=False, speed_perturb=self.speed_perturb)return AdapterForSoundScpReader(loader, self.float_dtype)elif loader_type == "kaldi_ark":loader = kaldiio.load_scp(path)diff --git a/funasr/fileio/sound_scp.py b/funasr/fileio/sound_scp.pyindex dc872b047..f0ac053c3 100644--- a/funasr/fileio/sound_scp.py+++ b/funasr/fileio/sound_scp.py@@ -2,11 +2,14 @@ import collections.abcfrom pathlib import Pathfrom typing import Union+import randomimport numpy as npimport soundfileimport librosafrom typeguard import check_argument_types+import torchaudio+from funasr.fileio.read_text import read_2column_text@@ -32,6 +35,7 @@ class SoundScpReader(collections.abc.Mapping):always_2d: bool = False,normalize: bool = False,dest_sample_rate: int = 16000,+ speed_perturb: tuple = None,):assert check_argument_types()self.fname = fname@@ -40,6 +44,7 @@ class SoundScpReader(collections.abc.Mapping):self.normalize = normalizeself.data = read_2column_text(fname)self.dest_sample_rate = dest_sample_rate+ self.speed_perturb = speed_perturbdef __getitem__(self, key):wav = self.data[key]@@ -53,6 +58,13 @@ class SoundScpReader(collections.abc.Mapping):wav, sr=self.dest_sample_rate, mono=not 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,+ [['speed', str(speed)], ['rate', str(rate)]])+return rate, arraydef get_path(self, key):