{"id":13825772,"url":"https://github.com/samim23/polymath","last_synced_at":"2025-07-08T22:32:13.573Z","repository":{"id":65748371,"uuid":"597873678","full_name":"samim23/polymath","owner":"samim23","description":"Convert any music library into a music production sample-library with ML","archived":false,"fork":false,"pushed_at":"2024-08-17T14:23:56.000Z","size":58,"stargazers_count":1483,"open_issues_count":5,"forks_count":112,"subscribers_count":24,"default_branch":"main","last_synced_at":"2024-08-17T15:36:12.603Z","etag":null,"topics":["audio","machine-learning","ml","music","python"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/samim23.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":"2023-02-05T21:57:29.000Z","updated_at":"2024-08-17T14:24:00.000Z","dependencies_parsed_at":null,"dependency_job_id":"93d6f83c-ca0e-4d7e-a853-3229b7d7655d","html_url":"https://github.com/samim23/polymath","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samim23%2Fpolymath","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samim23%2Fpolymath/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samim23%2Fpolymath/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samim23%2Fpolymath/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/samim23","download_url":"https://codeload.github.com/samim23/polymath/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225470631,"owners_count":17479366,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["audio","machine-learning","ml","music","python"],"created_at":"2024-08-04T09:01:26.828Z","updated_at":"2024-11-20T04:30:52.888Z","avatar_url":"https://github.com/samim23.png","language":"Python","readme":"\n# Polymath\n\nPolymath uses machine learning to convert any music library (*e.g from Hard-Drive or YouTube*) into a music production sample-library. The tool automatically separates songs into stems (*beats, bass, etc.*), quantizes them to the same tempo and beat-grid (*e.g. 120bpm*), analyzes musical structure (*e.g. verse, chorus, etc.*), key (*e.g C4, E3, etc.*) and other infos (*timbre, loudness, etc.*), and converts audio to midi. The result is a searchable sample library that streamlines the workflow for music producers, DJs, and ML audio developers.\n\n\u003cp align=\"center\"\u003e\u003cimg alt=\"Polymath\" src=\"https://samim.io/static/upload/illustration3.688a510b-bocuz8wh.png\" /\u003e\u003c/p\u003e\n\n## Use-cases\nPolymath makes it effortless to combine elements from different songs to create unique new compositions: Simply grab a beat from a Funkadelic track, a bassline from a Tito Puente piece, and fitting horns from a Fela Kuti song, and seamlessly integrate them into your DAW in record time. Using Polymath's search capability to discover related tracks, it is a breeze to create a polished, hour-long mash-up DJ set. For ML developers, Polymath simplifies the process of creating a large music dataset, for training generative models, etc.\n\n## How does it work?\n- Music Source Separation is performed with the [Demucs](https://github.com/facebookresearch/demucs) neural network\n- Music Structure Segmentation/Labeling is performed with the [sf_segmenter](https://github.com/wayne391/sf_segmenter) neural network\n- Music Pitch Tracking and Key Detection are performed with [Crepe](https://github.com/marl/crepe) neural network\n- Music to MIDI transcription is performed with [Basic Pitch](https://github.com/spotify/basic-pitch) neural network\n- Music Quantization and Alignment are performed with [pyrubberband](https://github.com/bmcfee/pyrubberband)\n- Music Info retrieval and processing is performed with [librosa](https://github.com/librosa/librosa)\n\n## Community\n\nJoin the Polymath Community on [Discord](https://discord.gg/gaZMZKzScj)\n\n## Requirements\n\nYou need to have the following software installed on your system:\n\n- ``ffmpeg``\n\n## Installation\n\nYou need python version `\u003e=3.7` and `\u003c=3.10`. From your terminal run:\n```bash\ngit clone https://github.com/samim23/polymath\ncd polymath\npip install -r requirements.txt\n```\n\nIf you run into an issue with basic-pitch while trying to run Polymath, run this command after your installation:\n```bash\npip install git+https://github.com/spotify/basic-pitch.git\n```\n\n## GPU support\n\nMost of the libraries polymath uses come with native GPU support through cuda. Please follow the steps on https://www.tensorflow.org/install/pip to setup tensorflow for use with cuda. If you have followed these steps, tensorflow and torch will both automatically pick up the GPU and use it. This only applied to native setups, for dockerized deployments (see next section), gpu support is forthcoming\n\n## Docker setup\n\nIf you have [Docker](https://www.docker.com/) installed on your system, you can use the provided `Dockerfile` to quickly build a polymath docker image (if your user is not part of the `docker` group, remember to prepend `sudo` to the following command):\n\n```bash\ndocker build -t polymath ./\n```\n\nIn order to exchange input and output files between your hosts system and the polymath docker container, you need to create the following four directories:\n\n- `./input`\n- `./library`\n- `./processed`\n- `./separated`\n\nNow put any files you want to process with polymath into the `input` folder.\nThen you can run polymath through docker by using the `docker run` command and pass any arguments that you would originally pass to the python command, e.g. if you are in a linux OS call:\n\n```bash\ndocker run \\\n    -v \"$(pwd)\"/processed:/polymath/processed \\\n    -v \"$(pwd)\"/separated:/polymath/separated \\\n    -v \"$(pwd)\"/library:/polymath/library \\\n    -v \"$(pwd)\"/input:/polymath/input \\\n    polymath python /polymath/polymath.py -a ./input/song1.wav\n```\n\n## Run Polymath\n\n### 1. Add songs to the Polymath Library\n\n##### Add YouTube video to library (auto-download)\n```bash\npython polymath.py -a n6DAqMFe97E\n```\n##### Add audio file (wav or mp3)\n```bash\npython polymath.py -a /path/to/audiolib/song.wav\n```\n##### Add multiple files at once\n```bash\npython polymath.py -a n6DAqMFe97E,eaPzCHEQExs,RijB8wnJCN0\npython polymath.py -a /path/to/audiolib/song1.wav,/path/to/audiolib/song2.wav\npython polymath.py -a /path/to/audiolib/\n```\nSongs are automatically analyzed once which takes some time. Once in the database, they can be access rapidly. The database is stored in the folder \"/library/database.p\". To reset everything, simply delete it.\n\n### 2. Quantize songs in the Polymath Library\n##### Quantize a specific songs in the library to tempo 120 BPM (-q = database audio file ID, -t = tempo in BPM)\n```bash\npython polymath.py -q n6DAqMFe97E -t 120\n```\n##### Quantize all songs in the library to tempo 120 BPM\n```bash\npython polymath.py -q all -t 120\n```\n##### Quantize a specific songs in the library to the tempo of the song (-k)\n```bash\npython polymath.py -q n6DAqMFe97E -k\n```\nSongs are automatically quantized to the same tempo and beat-grid and saved to the folder “/processed”.\n\n### 3. Search for similar songs in the Polymath Library\n##### Search for 10 similar songs based on a specific songs in the library (-s = database audio file ID, -sa = results amount)\n```bash\npython polymath.py -s n6DAqMFe97E -sa 10\n```\n##### Search for similar songs based on a specific songs in the library and quantize all of them to tempo 120 BPM\n```bash\npython polymath.py -s n6DAqMFe97E -sa 10 -q all -t 120\n```\n##### Include BPM as search criteria  (-st)\n```bash\npython polymath.py -s n6DAqMFe97E -sa 10 -q all -t 120 -st -k\n```\nSimilar songs are automatically found and optionally quantized and saved to the folder \"/processed\". This makes it easy to create for example an hour long mix of songs that perfectly match one after the other. \n\n### 4. Convert Audio to MIDI\n##### Convert all processed audio files and stems to MIDI (-m)\n```bash\npython polymath.py -a n6DAqMFe97E -q all -t 120 -m\n```\nGenerated Midi Files are currently always 120BPM and need to be time adjusted in your DAW. This will be resolved [soon](https://github.com/spotify/basic-pitch/issues/40). The current Audio2Midi model gives mixed results with drums/percussion. This will be resolved with additional audio2midi model options in the future.\n\n\n## Audio Features\n\n### Extracted Stems\nThe Demucs Neural Net has settings that can be adjusted in the python file\n```bash\n- bass\n- drum\n- guitare\n- other\n- piano\n- vocals\n```\n### Extracted Features\nThe audio feature extractors have settings that can be adjusted in the python file\n```bash\n- tempo\n- duration\n- timbre\n- timbre_frames\n- pitch\n- pitch_frames\n- intensity\n- intensity_frames\n- volume\n- avg_volume\n- loudness\n- beats\n- segments_boundaries\n- segments_labels\n- frequency_frames\n- frequency\n- key\n```\n\n## License\nPolymath is released under the MIT license as found in the [LICENSE](https://github.com/samim23/polymath/blob/main/LICENSE) file.\n","funding_links":[],"categories":["Python","排行榜 [2025-03-18]"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsamim23%2Fpolymath","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsamim23%2Fpolymath","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsamim23%2Fpolymath/lists"}