Inspiration

We wanted to make music creation accessible to everyone, even those without formal training. By combining AI with Python and web technologies, we aimed to let anyone generate melodies from just a song name and instantly get a playable MIDI file.

What it does

The MusicHelp allows users to input a song name through a simple web interface. Using OpenAI GPT-4o, it generates a sequence of musical notes. These notes are converted into a MIDI file using music21, which users can download and play in any music software or digital audio workstation.

How we built it

Frontend: Built a clean, user-friendly UI with HTML, CSS, and Flask templates.

Backend: Used Flask to handle form submissions and serve generated MIDI files.

AI Integration: Integrated OpenAI GPT-4o to generate musical notes in Music21 notation.

MIDI Generation: Used music21 Python library to convert the AI-generated notes into a proper MIDI file.

File Handling: Saved generated MIDI files with unique timestamps to prevent conflicts.

Challenges we ran into

  1. Parsing AI output: GPT sometimes returned invalid notes, so we had to handle exceptions and filter out errors.

  2. Sharps and flats: Ensuring proper Music21 notation and compatibility with MIDI required careful parsing.

  3. File access & permissions: Managing MIDI file storage and download links securely.

  4. Realistic melodies: AI-generated sequences were sometimes too simplistic, requiring prompt adjustments.

Accomplishments that we're proud of

  1. Successfully built a AI music composer in Python.

  2. Enabled real-time melody generation with a single input from the user.

  3. Created a clean downloadable MIDI workflow that works in any music software.

  4. Designed a scalable Flask structure ready for future features like multiple tracks or instruments.

What we learned

  1. How to integrate AI content generation (OpenAI) with Python applications.

  2. Basics of music theory and MIDI generation using music21.

  3. Handling user inputs and file downloads in Flask securely.

  4. Importance of prompt engineering to get structured and usable AI outputs.

What's next for The MusicHelp

  1. Support durations and rests for more realistic melodies.

  2. Allow chords and multiple instruments, not just a single melody track.

  3. Improve the AI prompts to produce more musical and varied sequences.

  4. Add a live audio preview feature so users can hear the melody before downloading.

  5. Enable user accounts and saved projects for a fully interactive music platform.

  6. Add singing tools using other python libraries.

Built With

  • datetime
  • flask
  • music21
  • openai
  • os
Share this project:

Updates