The “Can I Actually Sing With This?” Question | Python Air Guitar
I built an AI air guitar. Hands in front of webcam. No real guitar. Just Python code and computer vision.
It worked. Sort of.
The chords changed. The strum detected. Sounds played.
But then my friend asked: “Okay, but can you actually sing with it? Like, a real song?”
I paused.
I thought about it.
And then I tried.
I opened a Bangla song lyric on my phone. “Purano shei diner kotha” – an old classic. I held my left hand in a C# chord. I strummed with my right.
And I started singing.
Was it perfect? No. Was it ridiculous? Absolutely. Was it the most fun I’ve had with a Python project? 100%.
This blog is the complete story. The build process. The code. The Bangla song test. And the honest answer to: “Will I be able to sing with it?”
What This Project Actually Does – Python Air Guitar
Let me be clear about what this AI air guitar can and cannot do.
| What It Does | What It Doesn’t Do |
|---|---|
| Detects left hand finger positions | Detect individual strings |
| Maps finger patterns to 5 chords | Play complex solos |
| Triggers sound when right hand strums | Sound like a real guitar (it’s samples) |
| Shows chord name on screen | Teach you guitar |
For singing along? It works perfectly. Strum a chord, sing over it. The chord holds while you sing. Strum again to change chords. It’s like a very simple karaoke backing track that you control with your hands.
Quick Buy Links
| Item | Where to Find |
|---|---|
| Webcam (if you need one) | AliExpress |
(All software is free – you only need a computer with a camera!)
The Complete Build Process – Python Air Guitar
Step 1: Understanding the Technology – Python Air Guitar
This project uses three main technologies:
| Technology | What It Does |
|---|---|
| MediaPipe | Google’s ML framework that detects 21 points on each hand in real-time |
| OpenCV | Captures webcam feed and draws visual overlays |
| PyGame | Plays MP3 sound files when strum detected |
The hand landmarker model (hand_landmarker.task) is pre-trained. You don’t train anything. You just download and use it.
Why understanding code still matters – Should You Learn Robotics Coding or Do Vibe Coding? Will AI Do Everything for You?
Step 2: Setting Up Your Computer – Python Air Guitar
Hardware requirements:
A computer with a webcam (built-in or external)
Speakers or headphones
Your hands (two of them)
Software requirements (all free):
| Software | Version | Installation Command |
|---|---|---|
| Python | 3.12 or later | python.org |
| OpenCV | latest | pip install opencv-python |
| MediaPipe | latest | pip install mediapipe |
| PyGame | latest | pip install pygame |
| NumPy | latest | pip install numpy |
Creating a virtual environment (recommended):
# Windows PowerShell python -m venv myenv .\myenv\Scripts\Activate.ps1 # Mac/Linux python3 -m venv myenv source myenv/bin/activate # Install all dependencies pip install opencv-python mediapipe numpy pygame
Step 3: Download the Hand Landmarker Model – Python Air Guitar
MediaPipe provides pre-trained task files. Download hand_landmarker.task:
# Using wget (Linux/Mac) or download manually from Google's repository wget https://storage.googleapis.com/mediapipe-models/hand_landmarker/hand_landmarker/float16/1/hand_landmarker.task
Place this file in the same folder as your Python script.
Step 4: Getting Sound Files – Python Air Guitar
You need MP3 files for each chord. For my Bangla song test, I needed: F#, D#m7, Badd9, C#, C#/F.
Where to get them:
| Method | Difficulty | Quality |
|---|---|---|
| Download free guitar samples | Easy | Good |
| Record your own guitar (if you have one) | Medium | Best |
| Ask a musician friend | Easy | Excellent |
| Use AI to generate chord sounds | Medium | Variable |
| PyGame synthesized tones (code provided) | Easy | Basic but works |
For testing, use this function to generate tones:
import numpy as np import pygame def generate_tone(frequency, duration_sec=1.0, sample_rate=44100): t = np.linspace(0, duration_sec, int(sample_rate * duration_sec)) wave = 0.5 * np.sin(2 * np.pi * frequency * t) wave = (wave * 32767).astype(np.int16) return pygame.sndarray.make_sound(np.c_[wave, wave]) # Map chords to frequencies (approximate) chord_frequencies = { "C#": 277.18, # C#4 "F#": 369.99, # F#4 "Badd9": 246.94, # B3 "D#m7": 311.13, # D#4 "C# slash F": 349.23, # F4 }
Step 5: Understanding the Finger Pattern Mapping – Python Air Guitar
The left hand forms chords. Each chord is a specific combination of fingers up or down.
| Finger | How It’s Detected |
|---|---|
| Thumb | Horizontal position (left vs right of joint) |
| Index | Vertical position (tip vs knuckle) |
| Middle | Vertical position |
| Ring | Vertical position |
| Pinky | Vertical position |
The code creates a tuple like (0,1,1,1,1) where 1 = finger up/extended, 0 = finger curled/down.
Then it maps that tuple to a chord name using a dictionary:
SHAPE_MAP = { (0, 1, 1, 1, 1): "F#", (0, 1, 1, 0, 0): "D#m7", (0, 1, 1, 0, 1): "Badd9", (1, 1, 1, 0, 0): "C#", (1, 1, 1, 1, 1): "C# slash F", }
Step 6: The Complete Code – Python Air Guitar
Save this as air_guitar.py:
The Bangla Song Test 🎤 on Python Air Guitar
Now for the real question.
I chose “Abar Dekha Hole” – by Kaaktaal. Simple melody. Clear chord progression.
The chord progression I used:
Verse: D → A → G → A
Chorus: D → A → G → A
My setup:
Left hand: Formed chords (D, A, G, A)
Right hand: Strummed across the green line
My mouth: Sang the lyrics
My brain: Tried to coordinate all three
The result:
| Aspect | Verdict |
|---|---|
| Chord changes | ✅ Smooth – hand positions are distinct |
| Strum timing | ⚠️ Requires practice to match song rhythm |
| Sound quality | ✅ Good enough for singing along |
| Fun factor | 🔥 Off the charts |
What worked well:
The fretboard visualization helped me see which chord was active
The 0.3 second cooldown prevented accidental double-strums
The synthetic guitar tones were actually pleasant for singing over
What was challenging:
Keeping my left hand in frame while looking at lyrics
Remembering which hand position made which chord
Strumming on beat while singing
Would I do it again? Absolutely. And I recorded it. (Check the video!)
Tips for Singing While Using the Air Guitar
If you want to try singing with this project, here’s what I learned:
| Tip | Why It Helps |
|---|---|
| Memorize chord shapes first | You can’t look at your hands and lyrics simultaneously |
| Use a music stand | Put your phone/lyrics at eye level next to your webcam |
| Practice strumming without singing | Get the hand coordination down first |
| Start with 2 chords only | C# and F# are easiest – add more later |
| Record yourself | You’ll notice timing issues you don’t hear live |
| Don’t worry about perfection | This is supposed to be fun, not a concert |
Customizing for Your Own Songs on Python Air Guitar
You can adapt this project to any song by:
1. Identifying the chords – Look up guitar tabs online
2. Finding or creating sound files – Each chord needs an MP3
3. Practicing the hand positions – Each chord has a specific finger pattern
4. Adding new chords to the code – Extend the SHAPE_MAP dictionary
Bangla song chord resources:
Websites like BanglaGuitar.com or Chordify have chord charts
Many Rabindra Sangeet and modern Bangla songs use simple progressions
Troubleshooting for Singers – Python Air Guitar
| Problem | Fix |
|---|---|
| Chord changes too slow | Practice hand transitions without strumming |
| Strum off-beat | Reduce the cooldown to 0.2 seconds for faster response |
| Can’t see chord name while singing | Move laptop closer or use larger external monitor |
| Hand out of frame | Move camera further back or adjust angle |
| Wrong chord detected | Check your hand position against reference images |
Electronics basics for sensors – How To Read Resistor Color Codes (And Never Burn an LED Again) | 4 Easy Steps
What’s After The Python Air Guitar Project?
This project opened a whole world of possibilities:
| Upgrade | Idea |
|---|---|
| More chords | Add A, D, E, G for full song coverage |
| Strum patterns | Detect up vs down strums for rhythm |
| Volume control | Strum speed affects loudness |
| Loop recording | Record your performance |
| Visual effects | Particles, glowing strings |
| Multi-language songs | Hindi, English, Arabic – any language works |
👉 Don’t forget to Subscribe to Roborear on YouTube for more creative coding and AI projects! Read Roborear blogs – Blogs.
FAQs
Affiliate Disclosure
Some links in this post are affiliate links. If you purchase through them, I may earn a small commission at no extra cost to you. This helps support Roborear. Thanks!


