def remove_repeat_test(n: int, threshold: float, silence_threshold: float = 0): frames_arr = tests.input_bulk(n) frames_before = np.reshape(frames_arr, [-1]) frames_after = dsp.remove_silence(frames_before, silence_threshold) frames_after = dsp.remove_repeat(frames_after, tests.config.framerate, 200, 5, max_correlation=threshold) tests.output(frames_before, frames_after)
def apply_some_filters_profile(): frames = tests.input_bulk(200) profiler = Profile() profiler.enable() augmentation.apply_some_filters(frames, tests.config.framerate) profiler.disable() profiler.print_stats()
def remove_silence_compression_test(threshold: float): frames_arr = tests.input_bulk(1000) total_length = 0 total_compressed_length = 0 for frames in frames_arr: total_length += len(frames) total_compressed_length += len(dsp.remove_silence(frames, threshold)) compression = 1 - (total_compressed_length / total_length) print("Threshold: {}, Compression: {}".format(threshold, compression)) return compression
def add_noise_test(): frames_before = tests.input_bulk(10) frames_after = augmentation.add_noise(frames_before) frames_before = np.reshape(frames_before, [-1]) frames_after = np.reshape(frames_after, [-1]) sg = dsp.make_spectrogram(frames_before, seg_length=tests.config.seg_length) tests.plot_matrix("Spectrogram before", sg) sg = dsp.make_spectrogram(frames_after, seg_length=tests.config.seg_length) tests.plot_matrix("Spectrogram after", sg) tests.output(frames_before, frames_after)
def remove_repeat_compression_test(threshold: float, silence_threshold: float = 0): frames_arr = tests.input_bulk(50) total_length = 0 total_compressed_length = 0 for frames in frames_arr: frames = dsp.remove_silence(frames, silence_threshold) total_length += len(frames) total_compressed_length += len( dsp.remove_repeat(frames, tests.config.framerate, 200, 5, max_correlation=threshold)) compression = 1 - (total_compressed_length / total_length) print("Threshold: {}, Compression: {}".format(threshold, compression)) return compression
def remove_silence_test(n: int, threshold: float): frames_arr = tests.input_bulk(n) frames_before = np.reshape(frames_arr, [-1]) frames_after = dsp.remove_silence(frames_before, threshold) tests.output(frames_before, frames_after)