Batch convert audio files to .wav, preserve folder structure, clean up after, and optionally analyze them using GPT-4o to auto-rename with musical key and tempo.
- 🔍 Recursively scans
downloads/for.m4a,.opus, and.wavfiles - 🔄 Converts to
.wavusingffmpeg, preserving folder structure - 🚀 Parallel processing for speed
- 🧼 Automatically clears converted files from
downloads/(except.gitkeep) - 💬 Clean CLI with progress logging and friendly output
- 🧠 GPT-4o integration to rename tracks by key + BPM (uses
analyze-key-gpt4o.py) - 🧪
--dry-runmode to preview changes without touching files - 🎨 Fancy ASCII banner with
figlet(fallback included)
ai-audio-tool/
├── downloads/ # Drop your audio files in here
│ └── .gitkeep # Keeps directory in Git
├── output/ # Converted files show up here
├── main.py # Main batch conversion + GPT automation
├── analyze-key-gpt4o.py # GPT-based key/BPM analyzer and renamer
├── requirements.txt # Python dependencies
├── .env # Stores your OpenAI API key
└── README.md # You're reading this
# macOS
brew install ffmpeg
# Ubuntu
sudo apt install ffmpeg# macOS
brew install figlet
# Ubuntu
sudo apt install figletpython3 -m venv venv
source venv/bin/activate
pip install -r requirements.txtrequirements.txt:
python-dotenv
openai
tqdmCreate a .env file in the project root:
OPENAI_API_KEY=your-api-key-here
You can get your key from: https://platform.openai.com/account/api-keys
Drop .m4a, .opus, or .wav files into downloads/ (folders are fine):
python main.pyThis will:
- Convert all supported files in
downloads/to.wav - Save the converted files to
output/, preserving subfolders - Clean up the
downloads/directory (excluding.gitkeep) - Run
analyze-key-gpt4o.pyto:- Send filenames to GPT-4o
- Get key + BPM metadata
- Rename each
.wavfile to:
Track Name (Key - BPM).wav
Preview all actions without converting or deleting anything:
python main.py --dry-runThis is useful for testing file paths and GPT output before running for real.
After conversion, analyze-key-gpt4o.py:
- Scans
output/for.wavfiles - Sends a cleaned list of filenames to GPT-4o
- Parses the response to extract musical metadata
- Renames matched files with their key + BPM
Example:
Track Name: The Weeknd - Blinding Lights
Key: F# Minor
BPM: 171
➡️ output/The Weeknd - Blinding Lights (F# Minor - 171 BPM).wavIf no confident match is found, it skips the file and logs it.
- Instrumentals and obscure tracks may not return metadata from GPT
- GPT relies on accurate filenames — try to include artist and title
.gitkeepensures emptydownloads/andoutput/dirs are preserved in Git- You can comment out GPT automation in
main.pyif not needed
Built with love and ffmpeg, OpenAI, tqdm, and way too many .m4a files.
figlet m4a-wavMIT License.