Example #1
0
    def estimate(cls, audio):
        if audio.is_mono():
            signal = MonoLoader(filename=audio.filename)()
        else:
            signal = StereoLoader(filename=audio.filename)()

        extractor = RhythmExtractor2013(method="multifeature")
        bpm, *_ = extractor(signal)
        return bpm
Example #2
0
 def f_beats_for_minutes(Audio):
     ##  FUNCION PARA EXTRAER LOS BEATS POR MINUTOS DEL ARCHIVO
     ##  CON ESTO PODREMOS LUEGO VALIDAR LOS COMPACES
     rhythm_extractor = RhythmExtractor2013(method="multifeature")
     bpm, beats, b_conf, _, _ = rhythm_extractor(Audio)
     #print("BPM:", bpm)
     #print ("Primer Beat en el segundo ->", beats[0] )
     #print ("Ultimo Beat en el segundo ->", beats[len(beats)-1] )
     #print("beats Detectados ->", len(beats) )##picos de grafica
     #print("Beat positions (sec.):", beats)
     #print("Beat estimation confidence:", b_conf)
     return bpm
Example #3
0
File: main.py Project: SwarajKR/MIR
def lowLevel(songName):
    global dataset
    global lock
    print songName
    key = re.sub(r',', "", songName.split('/')[-1])
    #IF already present in dataset dont extract
    if dataset.has_key(key):
        feature = dataset[key]
        return feature
    else:
        #Loading song and using Extractors
        loader = MonoLoader(filename=songName)
        audio = loader()
        extractor = LowLevelSpectralEqloudExtractor()
        feature = list(extractor(audio))
        del feature[1]
        del feature[1]
        extractor = LowLevelSpectralExtractor()
        featureTwo = list(extractor(audio))
        del featureTwo[0]
        del featureTwo[-2]
        featureTwo[4] = feature[4][1]
        feature.extend(featureTwo)
        extractor = Loudness()
        feature.append(extractor(audio))
        extractor = LogAttackTime()
        feature.append(extractor(audio)[0])
        extractor = KeyExtractor()
        feature.append(extractor(audio)[2])
        extractor = RhythmExtractor2013()
        data = extractor(audio)
        feature.append(data[0])
        feature.append(data[2])
        for x in range(len(feature)):
            if type(feature[x]) is np.ndarray:
                feature[x] = avg(feature[x])
        arr = key + "," + str(feature)[1:-1] + "\n"
        f = open('data.csv', 'a')
        lock.acquire()
        f.write(arr)
        lock.release()
        f.close()
        return feature
def get_song_bpm(audio, params={}) -> Tuple[float, float]:
    """Extracts the BPM for the given monoloaded audio file

    Parameters
    ----------
    audio
        Monoloaded audio to be analyzed
    params
        RhythmExtractor2013 parameters

    Returns
    -------
    Tuple[float, float]
        A tuple of the BPM and a confidence of that BPM
    """

    rhythm_extractor = RhythmExtractor2013(**params)
    bpm, _, beats_confidence, _, _ = rhythm_extractor(audio)

    return bpm, beats_confidence