Objective: The objective of this application is to detect beats in an uploaded WAV audio file, allowing users to analyse the tempo and rhythm of the music.
Input Handling:
- Users are prompted to upload a WAV audio file using the file uploader widget provided by Streamlit.
- They can select the desired speed from a dropdown menu ('1x', '2x', '4x').
- Users can also input the beat interval value using a number input widget.
Beat Detection Algorithm:
- We created a function to implement beat detection algorithm.
- It loads the audio file using Librosa, calculates the onset envelope using the function ‘librosa.onset.onset_strength’, and computes the tempogram using ‘librosa.feature.tempogram’.
- The tempo multiplier adjusts the beat frames based on the selected speed.
- Beat frames are calculated using a numpy array and converted to time using Librosa's ‘frames_to_time’ function.
- Finally, the tempo and number of beats are estimated using Librosa's ‘beat_track’ function.
User Interaction:
- Users click the 'Detect Beats' button to trigger the beat detection process.
- If the audio file is uploaded and the button is clicked, the application displays the tempo, number of beats, and the detected beat times.
Output Display:
- The detected tempo in beats per minute (BPM) is shown.
- The number of beats detected in the audio file is displayed.
- The application provides a list of detected beat times, allowing users to visualize the rhythm and tempo variations.
Conclusion:
- This beat detection application provides a user-friendly interface for analyzing the rhythmic characteristics of WAV audio files.
- It leverages the capabilities of the Librosa library and Streamlit framework to streamline the process of beat detection and visualization.
- Users can easily upload their audio files, adjust parameters, and obtain insights into the tempo and beat structure of their music.
Installing the libraries:
- pip install numpy
- pip install librosa
- pip install streamlit
- pip install matplotlib