17.02.2026 r. - there are problems with downloading YT videos via yt_dlp! Please use sites on Google
Convert YouTube or local MP3 audio into Arduino / ESP32 buzzer code.
This project allows you to download audio from YouTube and convert it into a sequence of frequencies that can be played on a buzzer connected to an Arduino or ESP32.
-
Download YouTube videos as MP3
-
Convert MP3 audio into Arduino/ESP32 compatible buzzer code
-
Support for:
- Arduino UNO (PROGMEM)
- ESP32 (PWM tone output)
-
Progress bar feedback during conversion
-
Automatic generation of ready‑to‑use
generated.inofile
mp3tobuzzer/
├── mp3_to_buzzer.py
├── yt2mp3.py
├── requirements_yt2mp3.txt
├── requirements_mp3tobuzzer.txt
├── generated.ino # auto‑generated Arduino/ESP32 sketch
└── README.md
This project requires:
- Python 3.10 / 3.11 / 3.12
⚠️ Python 3.13+ and 3.14 removed theaudioopmodule, which breaks some audio‑related libraries.
python3 -m venv venv
source venv/bin/activatepip install -r requirements_yt2mp3.txtpip install -r requirements_mp3tobuzzer.txt✔ FFmpeg — required for audio processing
Install on macOS:
brew install ffmpegInstall on Arch Linux:
sudo pacman -S ffmpegInstall on Ubuntu:
sudo apt install ffmpegInstall on Windows:
winget install ffmpegpython yt2mp3.py --url "https://www.youtube.com/watch?v=VIDEO_ID"This creates a MP3 file in the current directory.
python mp3_to_buzzer.py --input yourfile.mp3 --arduinoor for ESP32:
python mp3_to_buzzer.py --input yourfile.mp3 --esp| Option | Description |
|---|---|
--input |
Path to the input MP3 file |
--arduino |
Generate code for Arduino UNO |
--esp |
Generate code for ESP32 |
--chunk |
Chunk size in milliseconds (default: 100) |
--minfreq |
Minimum frequency threshold |
--maxfreq |
Maximum frequency threshold |
The script generates a file called:
generated.ino
This sketch includes:
- A buzzer pin definition
- A frequency table of tones
- Playback logic
- Memory optimization for Arduino (PROGMEM)
- PWM tone on ESP32
- The MP3 file is split into short chunks (ms based)
- FFT is applied to detect dominant frequency per chunk
- Frequencies are translated into buzzer notes
- Sketch is built with those notes
# 1. Download YouTube audio
python yt2mp3.py --url "https://www.youtube.com/watch?v=ynON9o2yHVk"
# 2. Convert MP3 to Arduino code
python mp3_to_buzzer.py --input "Song Title.mp3" --arduino
# 3. Upload `generated.ino` to Arduino or ESP32- This is not a full MP3 player — it approximates dominant frequencies into buzzer tones
- Works best with monophonic sound or simple melodies
- ESP32 uses PWM output (higher quality than
tone())
Inspired by hobbyist projects converting audio into microcontroller buzzer output.
MIT © 2026 OneDevelopment