{"id":19831730,"url":"https://github.com/robrohan/theremin-midi","last_synced_at":"2026-02-24T20:37:58.580Z","repository":{"id":244921296,"uuid":"789270202","full_name":"robrohan/theremin-midi","owner":"robrohan","description":"Midi-\u003eGPT-\u003eMidi ML code to train and generate midi music","archived":false,"fork":false,"pushed_at":"2024-12-22T06:08:14.000Z","size":119,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-06-15T17:07:38.274Z","etag":null,"topics":["machine-learning","midi","music","pytorch"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/robrohan.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-04-20T04:54:37.000Z","updated_at":"2025-04-14T14:24:22.000Z","dependencies_parsed_at":"2024-12-22T07:19:56.534Z","dependency_job_id":"b9d52785-8909-40c8-aed5-3e6aa93eff6b","html_url":"https://github.com/robrohan/theremin-midi","commit_stats":null,"previous_names":["robrohan/theremin-midi"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/robrohan/theremin-midi","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robrohan%2Ftheremin-midi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robrohan%2Ftheremin-midi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robrohan%2Ftheremin-midi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robrohan%2Ftheremin-midi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/robrohan","download_url":"https://codeload.github.com/robrohan/theremin-midi/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robrohan%2Ftheremin-midi/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29799210,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-24T19:56:48.334Z","status":"ssl_error","status_checked_at":"2026-02-24T19:55:43.372Z","response_time":75,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["machine-learning","midi","music","pytorch"],"created_at":"2024-11-12T11:34:18.352Z","updated_at":"2026-02-24T20:37:58.565Z","avatar_url":"https://github.com/robrohan.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Theremin-midi - GPT Midi Music Generator\n\nThis is a little toy midi-\u003eGPT-\u003emidi generator. It's purpose is to help \nmusicians (well... me) come up with musical ideas - it does not auto generate \nfull songs like [udio.com](https://udio.com) or [suno.com](https://suno.com) \n\n[Example Output](https://cdn.robrohan.com/theremin_example.mp4)\n\nIt can be used like the \"dice game\" I am sure most musicians have played \n(where you roll a set of dice to create a chord progression or melody).\n\nYou should operate in a separate python environment:\n\n- `conda create -n theremin python==3.11`\n- `conda activate theremin`\n- `sudo apt install fluidsynth`\n- `make install`\n\nThere are some [pretrained models available](https://huggingface.co/robro/theremin-midi/tree/main), \nbut hopefully you just want to train this from your own midi files. \nThe following is how you do that:\n\n## Data Prep\n\n```bash\nmkdir data\n```\n\nPut all the midi files you want to train into the `data` directory.\n\nThen run the prep script:\n\n```bash\nVERSION=$(VERSION) \\\npython3 src/v2/prep.py\n```\n\nThis will take all the midi files in the data directory and turn the notes \ninto a text representation stored in `./models/[version]/training.txt`.\n\n## Vocab Training\n\nThe next step is to create the [byte pair encoding](https://github.com/google/sentencepiece) - \naka, turn the text into integers so we can do that sweet sweet matrix \nmultiplication.\n\n```bash\nVERSION=$(VERSION) \\\npython3 src/v2/tokenization_train.py\n```\n\nDepending on the size of your data set you my need to adjust the variable:\n\n```python\nMAX_VOCAB = 31185\n```\n\nThis will create a `./models/[VERSION]/miditok.model` file that will be needed\nto train the model.\n\n## Model Training \n\nFinally you can call:\n\n```bash\nVERSION=$(VERSION) \\\npython3 src/v2/train.py\n```\n\nTo train the actual model, and the model weights will be saved into \n`./models/[version]/theremin.pt`\n\n## Inference\n\nAnd finally, finally, you can generate magical tunes by running:\n\n```bash\nVERSION=$(VERSION) \\\npython src/v2/inference.py ./input/notes.mid\n```\n\nWhich, if all went well, will output `./output/model_X.midi`.\n\n# Extras\n\n- In order to get \"clean\" midi files for training, see `v2/clean.py`. That file\ncycles thorough midi files, removes any drum tracks, and collapses all other\ninstruments on to one track. If you have some whack midi files this can help\nprep midi files for training.\n\n- The main idea of mine is the midi-\u003eutf8 bit, and the code is in `midichar.py` \nfile.\n\n- There is code in here to create a docker container and also a yaml to deploy it to kubernetes. It's what I used to train my model, but not needed to get the code to work.\n\n- See the Makefile if you are into that kind of thing\n\n# Credits\n\n- The GPT implementation was copied and modified from [minGPT](https://github.com/karpathy/minGPT) - almost completely copied (see license)\n- While abandoned, v1 was from a [tesnsorflow example](https://www.tensorflow.org/tutorials/audio/music_generation)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobrohan%2Ftheremin-midi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frobrohan%2Ftheremin-midi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobrohan%2Ftheremin-midi/lists"}