Text prompt to MIDI File using OpenAI's GPT-4. Now with polyphony and MIDI input!
Web interface available on HugginFace
pip install openai midiutil mido
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)