(self, speech, rirs)
| 2125 | return data |
| 2126 | |
| 2127 | def _convolve_rir(self, speech, rirs): |
| 2128 | rir_path = np.random.choice(rirs) |
| 2129 | rir = None |
| 2130 | if rir_path is not None: |
| 2131 | rir, _ = soundfile.read(rir_path, dtype=np.float64, always_2d=True) |
| 2132 | |
| 2133 | # rir: (Nmic, Time) |
| 2134 | rir = rir.T |
| 2135 | |
| 2136 | # normalize rir |
| 2137 | rir = rir / np.sqrt(np.sum(rir**2)) |
| 2138 | |
| 2139 | # speech: (Nmic, Time) |
| 2140 | # Note that this operation doesn't change the signal length |
| 2141 | speech = scipy.signal.convolve(speech, rir, mode="full")[ |
| 2142 | :, : speech.shape[1] |
| 2143 | ] |
| 2144 | return speech, rir |
| 2145 | |
| 2146 | def _load_noise(self, speech, speech_db, noises, noise_db_low, noise_db_high): |
| 2147 | nsamples = speech.shape[1] |
no outgoing calls
no test coverage detected