File size: 445 Bytes
b606b24
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import librosa
import numpy as np
import gradio as gr

def get_bpm(file):
    y, sr = librosa.load(file.name)
    tempo, beats = librosa.beat.tempo(y=y, sr=sr, aggregate=None)
    return np.mean(tempo)

demo = gr.Interface(
    fn=get_bpm,
    inputs=gr.Audio(label="Audio File"),
    outputs=gr.Number(label="BPM"),
    title="BPM Detector",
    description="Upload an audio file to get its BPM",
)

if __name__ == "__main__":
    demo.launch()