(
self,
train: bool,
lang2utt: Optional[str] = None,
fix_duration: bool = True,
target_duration: Optional[float] = None, # in seconds
sample_rate: int = 16000,
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,
)
| 2267 | """ |
| 2268 | |
| 2269 | def __init__( |
| 2270 | self, |
| 2271 | train: bool, |
| 2272 | lang2utt: Optional[str] = None, |
| 2273 | fix_duration: bool = True, |
| 2274 | target_duration: Optional[float] = None, # in seconds |
| 2275 | sample_rate: int = 16000, |
| 2276 | rir_scp: Optional[str] = None, |
| 2277 | rir_apply_prob: float = 1.0, |
| 2278 | noise_info: List[ |
| 2279 | Tuple[float, str, Tuple[int, int], Tuple[float, float]] |
| 2280 | ] = None, |
| 2281 | noise_apply_prob: float = 1.0, |
| 2282 | short_noise_thres: float = 0.5, |
| 2283 | ): |
| 2284 | super().__init__(train, rir_scp=rir_scp, rir_apply_prob=rir_apply_prob) |
| 2285 | |
| 2286 | self.lang2label = None # a dictionary that maps string speaker label to int |
| 2287 | self.lang2vec = None |
| 2288 | self.sample_rate = sample_rate |
| 2289 | self.target_duration = ( |
| 2290 | int(target_duration * sample_rate) if target_duration else None |
| 2291 | ) |
| 2292 | self.fix_duration = fix_duration |
| 2293 | self.train = train |
| 2294 | self.lang2utt_path = lang2utt |
| 2295 | |
| 2296 | with open(lang2utt, "r") as f_s2u: |
| 2297 | self.lang2utt = f_s2u.readlines() |
| 2298 | self._make_label_mapping() |
| 2299 | # self.nlang = len(self.lang2utt) |
| 2300 | |
| 2301 | self.rir_scp = rir_scp |
| 2302 | |
| 2303 | self.noise_apply_prob = noise_apply_prob |
| 2304 | self.short_noise_thres = short_noise_thres |
| 2305 | self.noises = [] |
| 2306 | self.noise_probs = [] |
| 2307 | self.noise_db_ranges = [] |
| 2308 | self.noise_num_to_mix = [] |
| 2309 | if noise_info is None: |
| 2310 | noise_info = [] |
| 2311 | if noise_apply_prob > 0: |
| 2312 | for prob, noise_scp, num_to_mix, db_range in noise_info: |
| 2313 | if prob > 0: |
| 2314 | assert len(db_range) == 2, db_range |
| 2315 | assert db_range[0] <= db_range[1], db_range |
| 2316 | assert len(num_to_mix) == 2, num_to_mix |
| 2317 | assert num_to_mix[0] <= num_to_mix[1], num_to_mix |
| 2318 | self.noise_probs.append(prob) |
| 2319 | self.noise_db_ranges.append(tuple(db_range)) |
| 2320 | self.noise_num_to_mix.append(num_to_mix) |
| 2321 | noises = [] |
| 2322 | with open(noise_scp, "r", encoding="utf-8") as f: |
| 2323 | for line in f: |
| 2324 | sps = line.strip().split(None, 1) |
| 2325 | if len(sps) == 1: |
| 2326 | noises.append(sps[0]) |
nothing calls this directly
no test coverage detected