Realtime audio analysis in Python, using PyAudio and Numpy to extract and visualize FFT features from streaming audio.
The basic pipeline:
.get_audio_features()
, the stream_analyzer, applies a Fast-Fourier-Transform to the most recent audio window in the buffervisualize
is enabled, the visualizer displays these FFT features in realtime using a PyGame GUI (I made two display modes: 2D and 3D)Requirements:
pip install -r requirements.txt
You also might have to
sudo apt install libasound-dev portaudio19-dev libportaudio2 libportaudiocpp0
(tested on Ubuntu)
I developped this code on my local machine --> it has not been properly tested on other setups.. If something doesn't work, please first try to fix it yourself and post an issue/solution when appropriate!
pygame
doesn't work well with the default/Homebrew Python)Tested with:
Alternatively to pyaudio, you can use sounddevice which might be more compatible with Windows/Mac
python3 -m pip install sounddevice
__init__
function of the Stream_Analyzer classUsage:
just run python run_FFT_analyzer.py
and play a sound on your machine!
ToDo:
.get_audio_features()
is called --> fix