Generative artificial intelligence (AI) describes algorithms that help in creating/generating new content, including audio, code, images, text and videos.
In this kit, we build a Music generator from Text and Audio prompts using the Meta's MusicGen model. Meta's Audiocraft research team has released MusicGen, an open source deep learning language model that can generate new music based on text prompts and even be aligned to an existing song.
MusicGen is a single stage auto-regressive Transformer model capable of generating high-quality music samples conditioned on text descriptions or audio prompts. The text descriptions are passed through a frozen text encoder model to obtain a sequence of hidden-state representations. MusicGen is then trained to predict discrete audio tokens, or audio codes, conditioned on these hidden states. These audio tokens are then decoded using an audio compression model, such as EnCodec, to recover the audio waveform.
MusicGen has been trained on 20000 hours of licensed music. MusicGen is exceptional in its capacity to handle both text and musical cues, in addition to the effectiveness of the design and the speed of creation. The text establishes the fundamental style, which the audio file’s music subsequently follows.
Deployment Information
This repository helps you build your own AI based Music generation with MusicGen & Gradio
For Windows OS,
- Download, extract the zip file and run. Do ensure to extract the zip file before running it.
- After successful installation of the kit, press 'Y' to run the kit and execute cells in the notebook.
- To run the kit manually, press 'N' and follow the below steps. To run the solution anytime manually after installation, follow the below steps:
- Navigate to the 'music-generation' folder located in C:\kandikits
- Open command prompt inside the extracted directory 'music-generation'
- Run this command - "music-generation-env\Scripts\activate.bat" to activate the virtual environment
- Run the command - "cd music-generation"
- Run the command 'jupyter notebook' which would start a Jupyter notebook instance.
- Locate and open the 'Music_Generation.ipynb' notebook from the Jupyter Notebook browser window.
- Execute cells in the notebook.
For Linux distros and macOS,
- Follow the instructions to download & install Python3.9 & pip for your respective Linux distros or mac OS.
- Install ffmpeg and its libraries. Check the installation instructions for Linux and Mac.
- Download the repository.
- Extract the zip file and navigate to the directory music-generation.zip
- Open a terminal in the extracted directory 'music-generation'
- Create and activate virtual environment using this command: 'virtualenv venv & source ./venv/bin/activate'
- Install dependencies using the command 'pip3.9 install -r requirements.txt'
- Once the dependencies are installed, run the command 'jupyter notebook' to start jupyter notebook (Pls use --allow-root if you're running as root)
- Locate and open the 'Music_Generation.ipynb' notebook from the Jupyter Notebook browser window.
- Execute cells in the notebook.
Click the button below to download the solution and follow the deployment information to begin set-up. This 1-click kit has all the required dependencies and resources to build your Music Generator App.
Libraries used in this solution
Development Environment
VSCode and Jupyter Notebook are used for development and debugging. Jupyter Notebook is a web based interactive environment often used for experiments, whereas VSCode is used to get a typical experience of IDE for developers.
Jupyter Notebook is used for our development.
jupyterby jupyter
Jupyter metapackage for installation, docs and chat
jupyterby jupyter
Python 14404 Version:Current License: Permissive (BSD-3-Clause)
Artificial Intelligence
AI libraries and frameworks here are helpful in providing state-of-the-art solutions using AI
pytorchby pytorch
Tensors and Dynamic neural networks in Python with strong GPU acceleration
pytorchby pytorch
Python 67874 Version:v2.0.1 License: Others (Non-SPDX)
audiocraftby facebookresearch
Audiocraft is a library for audio processing and generation with deep learning. It features the state-of-the-art EnCodec audio compressor / tokenizer, along with MusicGen, a simple and controllable music generation LM with textual and melodic conditioning.
audiocraftby facebookresearch
Python 6676 Version:Current License: Permissive (MIT)
transformersby huggingface
🤗 Transformers: State-of-the-art Machine Learning for Pytorch, TensorFlow, and JAX.
transformersby huggingface
Python 104111 Version:v4.30.2 License: Permissive (Apache-2.0)
Kit Solution Source
UI app Integration
gradioby gradio-app
Create UIs for your machine learning model in Python in 3 minutes
gradioby gradio-app
Python 18771 Version:v3.35.2 License: Permissive (Apache-2.0)