A CLI tool for real-time pitch detection while singing
Project description
Sing Detector 🎤
A real-time pitch detection CLI tool for singers. Analyze your voice and see what note you're singing in real-time!
Features
- 🎵 Real-time pitch detection while you sing
- 🎯 Shows musical note names (C, D, E, etc.) with octave
- 📊 Displays frequency in Hz
- 🎶 Shows how close you are to perfect pitch (in cents)
- ⚡ Two detection algorithms: Autocorrelation and FFT
- 🖥️ Simple command-line interface
Installation
From Source
- Clone or download this repository
- Install the package:
pip install -e .
System Requirements
- Python 3.7 or higher
- A working microphone
- Audio drivers compatible with PyAudio
Dependencies
The package will automatically install:
numpy- For numerical computationsscipy- For signal processingpyaudio- For audio input capture
Usage
Basic Usage
Simply run:
sing
This will start the real-time pitch detector using your default microphone.
Advanced Options
# Use FFT method instead of autocorrelation
sing --method fft
# Change sample rate (default: 44100 Hz)
sing --rate 22050
# Change update rate (default: 20 Hz)
sing --update-rate 30
# Change audio frame size (default: 4096 samples)
sing --frame-size 2048
# Show help
sing --help
Example Output
🎤 Sing Detector - Real-time Pitch Detection
==================================================
Start singing! Press Ctrl+C to stop.
🎵 A4 (440.0 Hz) - in tune
🎵 C5 (523.3 Hz) - +12 cents
🔇 No clear pitch detected...
How It Works
The tool captures audio from your microphone in real-time and analyzes it using digital signal processing techniques:
- Audio Capture: Uses PyAudio to capture audio from your default microphone
- Windowing: Applies a Hanning window to reduce spectral leakage
- Pitch Detection: Uses either:
- Autocorrelation: Finds repeating patterns in the audio signal
- FFT: Analyzes frequency spectrum to find the fundamental frequency
- Note Conversion: Converts frequency to musical note names using equal temperament tuning
- Cents Calculation: Shows how close you are to perfect pitch (±50 cents = ±half semitone)
Troubleshooting
"No audio devices found" Error
This usually means PyAudio can't access your microphone. Try:
- macOS: Grant microphone permissions to your terminal application
- Linux: Install ALSA development headers:
sudo apt-get install libasound2-dev - Windows: Make sure your microphone is set as the default recording device
PyAudio Installation Issues
If PyAudio fails to install:
macOS:
brew install portaudio
pip install pyaudio
Linux (Ubuntu/Debian):
sudo apt-get install portaudio19-dev python3-pyaudio
pip install pyaudio
Windows:
pip install pipwin
pipwin install pyaudio
Poor Pitch Detection
If the tool isn't detecting your voice well:
- Try singing louder and clearer
- Reduce background noise
- Try the alternative detection method:
sing --method fft - Experiment with different frame sizes:
sing --frame-size 2048
Development
Running from Source
python -m sing_detector.main
Testing
You can test the package installation:
# Install in development mode
pip install -e .
# Test the command
sing --help
Contributing
Feel free to open issues or submit pull requests!
License
MIT License - feel free to use and modify as needed.
Happy singing! 🎵
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ashank_pitch-0.1.0.tar.gz.
File metadata
- Download URL: ashank_pitch-0.1.0.tar.gz
- Upload date:
- Size: 9.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9bd4b5766a20bc25859449cee0c671be247578c0aea9d75e748552b57f0ef1a3
|
|
| MD5 |
8d05ec7b943058ae06ceaef65447f989
|
|
| BLAKE2b-256 |
566c1c97a0c921339736c8d14eda1940a6c2f8e78d6978008e01b54fd5d726f2
|
File details
Details for the file ashank_pitch-0.1.0-py3-none-any.whl.
File metadata
- Download URL: ashank_pitch-0.1.0-py3-none-any.whl
- Upload date:
- Size: 9.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2787f543a6a7996b3f8c23b97e14c1e01c519847236091178020d8bbcf25a014
|
|
| MD5 |
2c7fd087e86805f4dda74010deddef15
|
|
| BLAKE2b-256 |
b2a2b950e7d0037e45e168f45fbcfbd6d32629f208dd5435384fff379374a3e5
|