🎵 TextToMelody
Convert typed text into music and export MP3s — quick, visual, and interactive.
TextToMelody is a small Pygame-based app that maps alphabetic characters to musical notes. Type letters (A–Z) to play notes live, press Enter to play the whole sequence, and export an MP3 of the generated melody to your Downloads folder.
Small interactive demo — try the textbox and animation:
🔗 https://JanetCheng0311.github.io/TextToMelody/
- 🎹 Live typing → sound: each letter maps to a piano-like note and plays immediately.
- ✍️ Multi-line editable input with caret movement, copy/paste, and character limit enforcement.
- 🎚️ Runtime transpose: use Up/Down arrows to shift pitch by semitones (Left/Right move caret).
- 💿 Export to MP3 only: creates a timestamped MP3 in your Downloads folder (uses timidity if available for MIDI→WAV, otherwise a built-in synth; converts WAV→MP3 with ffmpeg).
- 📁 Clickable export path: click the export path text to choose a different export folder (or open it in Finder).
- 🧪 Testing/process files: see the
testing/folder — it contains example and process utilities used during development.
Letter → note
| Letter | Note | Letter | Note |
|---|---|---|---|
| A | C4 | B | C#4 / Db4 |
| C | D4 | D | D#4 / Eb4 |
| E | E4 | F | F4 |
| G | F#4 / Gb4 | H | G4 |
| I | G#4 / Ab4 | J | A4 |
| K | A#4 / Bb4 | L | B4 |
| M | C5 | N | C#5 / Db5 |
| O | D5 | P | D#5 / Eb5 |
| Q | E5 | R | F5 |
| S | F#5 / Gb5 | T | G5 |
| U | G#5 / Ab5 | V | A5 |
| W | A#5 / Bb5 | X | B5 |
| Y | C6 | Z | C#6 / Db6 |
- Type letters A–Z to play notes.
- ⏎ Enter — play the full typed sequence.
- ⌫ Backspace/Delete — edit at the caret.
- ←/→/↑/↓ Arrow keys — move caret (Left/Right) and transpose pitch (Up/Down).
- ⌘/Ctrl+E or Export button — export MP3 of current text.
- 📁 Click the export path text — left-click opens the native folder chooser; right-click opens the folder.
- Python 3.8+
- pygame
- numpy
- mido
- ffmpeg on PATH (required to produce MP3)
- timidity (optional, recommended for better MIDI→WAV rendering)
- Create and activate a virtual environment (recommended).
- Install dependencies: pip install -r requirements.txt (or manually install pygame, numpy, mido).
- Run the app from the project venv:
source .venv/bin/activate
python Main.pyThis project's letter→note concept was created with reference to the method described at: http://www.d131music.org/make-your-name-a-melody1.html
