zhifu gao
2023-11-22 b57b98364ff60ae0119b2e8d92471316bb4e504f
funasr/fileio/sound_scp.py
@@ -4,9 +4,8 @@
import random
import numpy as np
import soundfile
import librosa
from typeguard import check_argument_types
import librosa
import torch
import torchaudio
@@ -106,7 +105,6 @@
        dest_sample_rate: int = 16000,
        speed_perturb: Union[list, tuple] = None,
    ):
        assert check_argument_types()
        self.fname = fname
        self.dtype = dtype
        self.always_2d = always_2d
@@ -118,7 +116,7 @@
    def __getitem__(self, key):
        wav = self.data[key]
        if self.normalize:
            # soundfile.read normalizes data to [-1,1] if dtype is not given
            # librosa.load normalizes data to [-1,1] if dtype is not given
            array, rate = librosa.load(
                wav, sr=self.dest_sample_rate, mono=self.always_2d
            )
@@ -179,7 +177,6 @@
        format="wav",
        dtype=None,
    ):
        assert check_argument_types()
        self.dir = Path(outdir)
        self.dir.mkdir(parents=True, exist_ok=True)
        scpfile = Path(scpfile)