Skip to main content
Hulash Chand
homeprojectslocus
Hulash Chand

Bird Song Mathematical Model

←

Bird Song Mathematical Model

↗

An interactive 3D acoustic manifold visualization of bird vocalisations. Extracts 57-dimensional MFCC feature vectors per frame, reduces them to 3 principal components via PCA, classifies species using kNN (cosine similarity, k=5), and serves it all through a FastAPI backend with a Three.js frontend and a conversational AI assistant powered by Llama 3.1.

57Dimensional Feature Vector
PCA57D → 3D Reduction
k=5kNN Cosine Similarity
Llama 3.1AI Assistant via Groq

Research Paper

A full academic paper documenting the mathematical model, feature extraction pipeline, PCA reduction, and system architecture.

Birdsong_paper

Built to explore the intersection of audio DSP, machine learning, and real-time graphics, the project demonstrates how complex sound data can be converted into meaningful visual structures.

Project Overview

The system processes raw bird audio through a Python-based ML pipeline that extracts 57-dimensional feature vectors per frame using librosa. The feature vector comprises MFCCs (1–13), delta and delta-delta MFCCs, spectral centroid, bandwidth, rolloff, zero-crossing rate, RMS energy, and mel-spectrogram bands, capturing timbre, texture, and spectral range of each 23ms frame.

Since visualizing 57 dimensions directly is impossible, the pipeline applies Principal Component Analysis (PCA) using scikit-learn to reduce the feature space into 3 principal components, mapped to Timbre (X), Texture (Y), and Spectral range (Z), while preserving the most important variation in the signal.

The reduced data is rendered as an animated 3D trajectory using Three.js, with points coloured by energy (dark → silence, amber → peak) and sized by amplitude. A kNN classifier (cosine similarity, k=5) identifies the closest matching species from the manifold.

A FastAPI backend serves the manifold data, processes uploaded audio files for real-time classification, and powers a conversational AI assistant built on Llama 3.1 8B Instant via Groq, enabling natural-language questions about each species.

How It Works

01

Audio Processing Pipeline

Feature Extraction

Raw bird audio is loaded and segmented into 23ms frames. 57-dimensional MFCC and spectral features are extracted per frame with librosa, then normalized and scaled before PCA compresses them into 3 principal coordinates.

librosa57-dim Feature VectorPCA Compression
02

Acoustic Manifold

Dimensionality Reduction

The 3 principal components map to Timbre (X axis), Texture (Y axis), and Spectral range (Z axis). Points are coloured by energy and sized by amplitude, turning a 57-dimensional signal into a shape you can actually see.

Timbre / Texture / Range AxesEnergy-Coloured Points
03

Real-Time 3D Visualization

Three.js Rendering

Three.js renders the PCA trajectory as an animated comet trail with free-orbit controls, using binary-search frame mapping to keep the audio and the animation in sync.

Orbit ControlsBinary-Search Sync
04

kNN Species Classification

Real-Time Inference

Visitors can drag and drop their own audio: the same pipeline extracts its features, projects them into the shared PCA space, and a cosine-similarity search (k=5) finds the closest matching species.

Drag-and-Drop UploadCosine Similarity, k=5
05

AI Assistant

Groq / Llama 3.1

A conversational ornithology assistant, powered by Llama 3.1 8B Instant via Groq, answers natural-language questions about species behaviour, habitat, and characteristics, with full chat history kept per session.

Llama 3.1 8B InstantPer-Session Chat History

Technical Highlights

MFCC Feature ExtractionPCA Dimensionality ReductionkNN Species ClassificationFastAPI BackendThree.js 3D RenderingGroq LLM IntegrationAudio Upload & ClassificationGitHub Pages + Render

Audio Signal Processing

Extracted 57-dimensional MFCC and spectral feature vectors from raw audio with librosa: the real DSP work underneath the visualization, not just a pre-processed dataset.

Dimensionality Reduction & ML

Applied PCA to compress a 57-dimensional feature space into 3 interpretable axes, then built a kNN classifier (cosine similarity, k=5) on top of that reduced space.

Real-Time 3D Graphics

Built a Three.js visualization with free-orbit controls and binary-search frame-to-audio sync: an interactive scene, not a static chart.

LLM Integration

Wired a Llama 3.1 8B Instant assistant via Groq into the same app, with per-session chat history, going beyond the visualization into a genuine conversational feature.

References

  1. librosa Audio Analysis Documentation
  2. scikit-learn PCA Documentation
  3. Three.js Documentation
  4. Groq API Documentation

Try the live demo yourself: upload a bird call and watch it drop onto the manifold.

↗ Open the Live Demo
← Back to all projects

Let's build something.

Now Playing

Utopia

Horacio Pagani