Skip to content

Text prompt to MIDI File using OpenAI's GPT-4

Notifications You must be signed in to change notification settings

francescofugazzi/GPT-4-To-MIDI

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

40 Commits
 
 
 
 

Repository files navigation

GPT-4 To MIDI

Text prompt to MIDI File using OpenAI's GPT-4. Now with polyphony and MIDI input!

Web interface available on HugginFace

Screen Shot 2023-04-01 at 9 57 21 AM

Dependencies:

pip install openai midiutil mido

Usage:

Ask it in plain english to generate, including any musical details that you want.

Input:

python g2m.py -p "Full piece of melancholy music with multiple parts. Plan out the structure beforehand, including chords, parts (soprano, alto, tenor, bass), meter, etc." -c
[*] Making request to OpenAI API
[*] Parsing content
[*] Wrote the MIDI file.

Next prompt> Keep it Eb instead of E for the second note 

...

Next prompt> Write a simple soprano melody in the high octave range that fits over this piece.

Output:

melancholy.mp4

Input:

python g2m.py -p "Full piece by Mozart with multiple parts. Plan out the structure beforehand, including chords, parts (soprano, alto, tenor, bass), meter, etc. Over 400 notes total."

Output:

mozart.mp4

Input:

python g2m.py -p "twinkle twinkle little star" -c
[*] Parsing content
[*] Wrote the MIDI file.

Next prompt> Tranpose it to A minor

Output:

eviltwinkle.mp4

Full options:

  -h, --help            show this help message and exit
  -p PROMPT, --prompt PROMPT
                        specify prompt to use (default: Jazz!)
  -c, --chat            send follow up messages to make revisions,
                        continuations, etc. (type 'exit' to quit)
  -l LOAD, --load LOAD  load a MIDI file to be appended to your prompt
  -v, --verbose         display GPT-4 output
  -o OUTPUT, --output OUTPUT
                        specify output directory (default: current)
  -a AUTH, --auth AUTH  specify openai api key (edit this script file to set a
                        default)

About

Text prompt to MIDI File using OpenAI's GPT-4

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%