bpm / app.py
65rted6tfdjhgfjyrf's picture
Create app.py
b606b24 verified
raw
history blame contribute delete
445 Bytes
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()