def __init__(self, mix_scp, s1_scp, s2_scp): """Initialize DataReader. (2 mixtures) Args: mix_scp: scp file for mixed waves (KALDI format) """ check(mix_scp, s1_scp, s2_scp) self.key = read_key(mix_scp) self.mix_path = read_path(mix_scp) self.s1_path = read_path(s1_scp) self.s2_path = read_path(s2_scp)
def __init__(self, mix_scp, s1_scp, s2_scp, sample_rate, sample_clip_size=4): """Initialize the TimeDomainDateset. (2 mixtures) Args: mix_scp: scp file for mixed waves (KALDI format) s1_scp: scp file for speaker 1 s2_scp: scp file for speaker 2 sample_clip_size: segmental length (default: 4s) """ check(mix_scp, s1_scp, s2_scp) self.sample_rate = sample_rate self.sample_clip_size = sample_clip_size self.segment_length = self.sample_rate * self.sample_clip_size self.mix_path = read_path(mix_scp) self.s1_path = read_path(s1_scp) self.s2_path = read_path(s2_scp) self.retrieve_index = [] for i in range(len(self.mix_path)): sample_size = len(wavread(self.mix_path[i])[0]) if sample_size < self.segment_length: # wave length is smaller than segmental length if sample_size * 2 < self.segment_length: continue self.retrieve_index.append((i, -1)) else: # Cut wave into clips and restore the retrieve index sample_index = 0 while sample_index + self.segment_length < sample_size: self.retrieve_index.append((i, sample_index)) sample_index += self.segment_length if sample_index != sample_size - 1: self.retrieve_index.append( (i, sample_size - self.segment_length))