Generate your own Music using Meta's MusicGen

share link

by kandikits dot icon Updated: Aug 21, 2023

technology logo
technology logo

1-Click Kit 1-Click Kit  


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,

  1. Download, extract the zip file and run. Do ensure to extract the zip file before running it.
  2. After successful installation of the kit, press 'Y' to run the kit and execute cells in the notebook.
  3. To run the kit manually, press 'N' and follow the below steps. To run the solution anytime manually after installation, follow the below steps:
  4. Navigate to the 'music-generation' folder located in C:\kandikits
  5. Open command prompt inside the extracted directory 'music-generation'
  6. Run this command - "music-generation-env\Scripts\activate.bat" to activate the virtual environment
  7. Run the command - "cd music-generation"
  8. Run the command 'jupyter notebook' which would start a Jupyter notebook instance.
  9. Locate and open the 'Music_Generation.ipynb' notebook from the Jupyter Notebook browser window.
  10. Execute cells in the notebook.


For Linux distros and macOS,

  1. Follow the instructions to download & install Python3.9 & pip for your respective Linux distros or mac OS.
  2. Install ffmpeg and its libraries. Check the installation instructions for Linux and Mac.
  3. Download the repository.
  4. Extract the zip file and navigate to the directory music-generation.zip
  5. Open a terminal in the extracted directory 'music-generation'
  6. Create and activate virtual environment using this command: 'virtualenv venv & source ./venv/bin/activate'
  7. Install dependencies using the command 'pip3.9 install -r requirements.txt'
  8. Once the dependencies are installed, run the command 'jupyter notebook' to start jupyter notebook (Pls use --allow-root if you're running as root)
  9. Locate and open the 'Music_Generation.ipynb' notebook from the Jupyter Notebook browser window.
  10. 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

Python doticonstar image 14404 doticonVersion:Currentdoticon
License: Permissive (BSD-3-Clause)

Jupyter metapackage for installation, docs and chat

Support
    Quality
      Security
        License
          Reuse

            jupyterby jupyter

            Python doticon star image 14404 doticonVersion:Currentdoticon License: Permissive (BSD-3-Clause)

            Jupyter metapackage for installation, docs and chat
            Support
              Quality
                Security
                  License
                    Reuse

                      vscodeby microsoft

                      TypeScript doticonstar image 147328 doticonVersion:1.79.2doticon
                      License: Permissive (MIT)

                      Visual Studio Code

                      Support
                        Quality
                          Security
                            License
                              Reuse

                                vscodeby microsoft

                                TypeScript doticon star image 147328 doticonVersion:1.79.2doticon License: Permissive (MIT)

                                Visual Studio Code
                                Support
                                  Quality
                                    Security
                                      License
                                        Reuse

                                          Artificial Intelligence


                                          AI libraries and frameworks here are helpful in providing state-of-the-art solutions using AI

                                          pytorchby pytorch

                                          Python doticonstar image 67874 doticonVersion:v2.0.1doticon
                                          License: Others (Non-SPDX)

                                          Tensors and Dynamic neural networks in Python with strong GPU acceleration

                                          Support
                                            Quality
                                              Security
                                                License
                                                  Reuse

                                                    pytorchby pytorch

                                                    Python doticon star image 67874 doticonVersion:v2.0.1doticon License: Others (Non-SPDX)

                                                    Tensors and Dynamic neural networks in Python with strong GPU acceleration
                                                    Support
                                                      Quality
                                                        Security
                                                          License
                                                            Reuse

                                                              audiocraftby facebookresearch

                                                              Python doticonstar image 6676 doticonVersion:Currentdoticon
                                                              License: Permissive (MIT)

                                                              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.

                                                              Support
                                                                Quality
                                                                  Security
                                                                    License
                                                                      Reuse

                                                                        audiocraftby facebookresearch

                                                                        Python doticon star image 6676 doticonVersion:Currentdoticon License: Permissive (MIT)

                                                                        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.
                                                                        Support
                                                                          Quality
                                                                            Security
                                                                              License
                                                                                Reuse

                                                                                  transformersby huggingface

                                                                                  Python doticonstar image 104111 doticonVersion:v4.30.2doticon
                                                                                  License: Permissive (Apache-2.0)

                                                                                  🤗 Transformers: State-of-the-art Machine Learning for Pytorch, TensorFlow, and JAX.

                                                                                  Support
                                                                                    Quality
                                                                                      Security
                                                                                        License
                                                                                          Reuse

                                                                                            transformersby huggingface

                                                                                            Python doticon star image 104111 doticonVersion:v4.30.2doticon License: Permissive (Apache-2.0)

                                                                                            🤗 Transformers: State-of-the-art Machine Learning for Pytorch, TensorFlow, and JAX.
                                                                                            Support
                                                                                              Quality
                                                                                                Security
                                                                                                  License
                                                                                                    Reuse

                                                                                                      Kit Solution Source

                                                                                                      UI app Integration

                                                                                                      gradioby gradio-app

                                                                                                      Python doticonstar image 18771 doticonVersion:v3.35.2doticon
                                                                                                      License: Permissive (Apache-2.0)

                                                                                                      Create UIs for your machine learning model in Python in 3 minutes

                                                                                                      Support
                                                                                                        Quality
                                                                                                          Security
                                                                                                            License
                                                                                                              Reuse

                                                                                                                gradioby gradio-app

                                                                                                                Python doticon star image 18771 doticonVersion:v3.35.2doticon License: Permissive (Apache-2.0)

                                                                                                                Create UIs for your machine learning model in Python in 3 minutes
                                                                                                                Support
                                                                                                                  Quality
                                                                                                                    Security
                                                                                                                      License
                                                                                                                        Reuse

                                                                                                                          Support


                                                                                                                          For any support, you can reach us at OpenWeaver Community Support

                                                                                                                          See similar Kits and Libraries