def compute(self, x): startstopsilence = es.StartStopSilence(threshold=-70) for frame in es.FrameGenerator(x, frameSize=2048, hopSize=512, startFromZero=True): result = startstopsilence(esarray(frame)) solution = np.array([result[0], result[1]]) return solution * 512 / 44100.
def onsetDetection(self, samplePath): # Get audio from file loader = es.MonoLoader(filename=samplePath) audio = loader() startStop = es.StartStopSilence() startFrame = 0 stopFrame = 0 for frame in es.FrameGenerator(audio, 64, 32): startFrame, stopFrame = startStop(frame) startTime = float(startFrame * 32) / 44100.0 stopTime = float((stopFrame * 32) + 64) / 44100.0 return startTime, stopTime
def find_start_stop(audio, sample_rate=44100, seconds=False, threshold=-60): """ Returns a tuple containing the start and the end of sound in an audio array. ARGUMENTS: `audio` : essentia.array an essentia array or numpy array containing the audio `sample_rate` : int sample rate `seconds` : boolean if True, results will be expressed in seconds (float) `threshold` : int a threshold as in `essentia.standard.StartStopSilence` RETURNS: `start` : int or float the sample where sound starts or the corresponding second `end` : int or float the sample where sound ends or the corresponding second """ # reset parameters based on sample_rate ratio = sample_rate / 44100 fs = round(1024 * ratio) hs = round(128 * ratio) processer = es.StartStopSilence(threshold=threshold) for frame in es.FrameGenerator(audio, frameSize=fs, hopSize=hs, startFromZero=True): start, stop = processer(frame) if seconds: start = specframe2sec(start, sample_rate, hs, fs) stop = specframe2sec(stop, sample_rate, hs, fs) else: start = int(specframe2sample(start, hs, fs)) stop = int(specframe2sample(stop, hs, fs)) if start == 2 * hs: start = 0 return start, stop