Gaps on audio¶
Gaps are generally produced by hardware or software issues in the process of recording or copying audio data. They can be distinguished from discontinuities because instead of missing some audio timestamps, the degraded segment is overwritten with zeros or a constant value.
Gaps vs. pauses¶
The main challenge in detecting audio gaps is to distinguish them from natural musical pauses that are a creative decision rather than an audio problem.
First of all, let’s listen to examples of both cases to get familiar with them. The following clip contains a musical pause at the beginning and an artificially generated gap at the second 15.
from IPython.display import Audio from essentia.standard import MonoLoader, GapsDetector, FrameGenerator import matplotlib.pyplot as plt import numpy as np plt.rcParams["figure.figsize"] = (12, 9)
file_name = '011916.mp3' audio = MonoLoader(filename=file_name)() sr = 44100 time_axis = np.arange(len(audio)) / sr gap_position = 15 gap_duration = 0.5 gap_start = gap_position * sr gap_end = int(gap_start + gap_duration * sr) audio[gap_start: gap_end] = np.zeros(gap_duration * sr)