(
self,
train: bool,
target_duration: float, # in seconds
spk2utt: Optional[str] = None,
sample_rate: int = 16000,
num_eval: int = 10,
rir_scp: Optional[str] = None,
rir_apply_prob: float = 1.0,
noise_info: List[
Tuple[float, str, Tuple[int, int], Tuple[float, float]]
] = None,
noise_apply_prob: float = 1.0,
short_noise_thres: float = 0.5,
)
| 1990 | """ |
| 1991 | |
| 1992 | def __init__( |
| 1993 | self, |
| 1994 | train: bool, |
| 1995 | target_duration: float, # in seconds |
| 1996 | spk2utt: Optional[str] = None, |
| 1997 | sample_rate: int = 16000, |
| 1998 | num_eval: int = 10, |
| 1999 | rir_scp: Optional[str] = None, |
| 2000 | rir_apply_prob: float = 1.0, |
| 2001 | noise_info: List[ |
| 2002 | Tuple[float, str, Tuple[int, int], Tuple[float, float]] |
| 2003 | ] = None, |
| 2004 | noise_apply_prob: float = 1.0, |
| 2005 | short_noise_thres: float = 0.5, |
| 2006 | ): |
| 2007 | |
| 2008 | self.train = train |
| 2009 | |
| 2010 | if rir_apply_prob == 0: |
| 2011 | self.rir_scp = None |
| 2012 | else: |
| 2013 | self.rir_scp = rir_scp |
| 2014 | super().__init__(train, rir_scp=self.rir_scp, rir_apply_prob=rir_apply_prob) |
| 2015 | |
| 2016 | self.spk2label = None # a dictionary that maps string speaker label to int |
| 2017 | self.sample_rate = sample_rate |
| 2018 | self.target_duration = int(target_duration * sample_rate) |
| 2019 | self.num_eval = num_eval |
| 2020 | |
| 2021 | if train: |
| 2022 | with open(spk2utt, "r") as f_s2u: |
| 2023 | self.spk2utt = f_s2u.readlines() |
| 2024 | self._make_label_mapping() |
| 2025 | self.nspk = len(self.spk2utt) |
| 2026 | |
| 2027 | self.noise_apply_prob = noise_apply_prob |
| 2028 | self.short_noise_thres = short_noise_thres |
| 2029 | self.noises = [] |
| 2030 | self.noise_probs = [] |
| 2031 | self.noise_db_ranges = [] |
| 2032 | self.noise_num_to_mix = [] |
| 2033 | if noise_apply_prob > 0: |
| 2034 | for prob, noise_scp, num_to_mix, db_range in noise_info: |
| 2035 | if prob > 0: |
| 2036 | assert len(db_range) == 2, db_range |
| 2037 | assert db_range[0] <= db_range[1], db_range |
| 2038 | assert len(num_to_mix) == 2, num_to_mix |
| 2039 | assert num_to_mix[0] <= num_to_mix[1], num_to_mix |
| 2040 | self.noise_probs.append(prob) |
| 2041 | self.noise_db_ranges.append(tuple(db_range)) |
| 2042 | self.noise_num_to_mix.append(num_to_mix) |
| 2043 | noises = [] |
| 2044 | with open(noise_scp, "r", encoding="utf-8") as f: |
| 2045 | for line in f: |
| 2046 | sps = line.strip().split(None, 1) |
| 2047 | if len(sps) == 1: |
| 2048 | noises.append(sps[0]) |
| 2049 | else: |
nothing calls this directly
no test coverage detected