Run MusicGen on Google Colab/Windows11

What is MusicGen

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.

Meta’s open source AI MusicGen turns text and melody into new songs
https://the-decoder.com/metas-open-source-ai-musicgen-turns-text-and-melody-into-new-songs/

Steps for Colab

  1. Go to Google Colab
  2. Change Runtime
  3. Run code
  4. Try to generate sound

step 1. Go to Google Colab

https://colab.research.google.com/

step 2. Change Runtime

Click Runtime and select GPU

step 3. Run code

<span>!</span><span>git</span> <span>clone</span> <span>-</span><span>b</span> <span>dev</span> <span>https</span><span>:</span><span>//</span><span>github</span><span>.</span><span>com</span><span>/</span><span>camenduru</span><span>/</span><span>MusicGen</span><span>-</span><span>hf</span>
<span>cd</span> <span>MusicGen</span><span>-</span><span>hf</span><span>/</span>
<span>!</span><span>pip</span> <span>install</span> <span>-</span><span>r</span> <span>requirements</span><span>.</span><span>txt</span>
<span>!</span><span>python</span> <span>app</span><span>.</span><span>py</span>
<span>!</span><span>git</span> <span>clone</span> <span>-</span><span>b</span> <span>dev</span> <span>https</span><span>:</span><span>//</span><span>github</span><span>.</span><span>com</span><span>/</span><span>camenduru</span><span>/</span><span>MusicGen</span><span>-</span><span>hf</span>
<span>cd</span> <span>MusicGen</span><span>-</span><span>hf</span><span>/</span>
<span>!</span><span>pip</span> <span>install</span> <span>-</span><span>r</span> <span>requirements</span><span>.</span><span>txt</span>
<span>!</span><span>python</span> <span>app</span><span>.</span><span>py</span>
!git clone -b dev https://github.com/camenduru/MusicGen-hf cd MusicGen-hf/ !pip install -r requirements.txt !python app.py

Enter fullscreen mode Exit fullscreen mode

Installing python packages will take some time.
If everything works properly, you will see something like this.

step4. Try to generate sound

If you click the link Running on public URL:, you will see Gardio.

Now time to create your own sound via prompt!
It would take around 1-2 minutes to generate a mp4 file.

Steps for Windows11

You need to install cuda11.7 on your Windows11.

  1. Create a venv
  2. Install pytorch
  3. Clone repo and install requirements
  4. Try to generate sound

step 1. Create a venv

python <span>-m</span> venv musicgen
<span># activate venv</span>
./musicgen/scripts/activate
python <span>-m</span> venv musicgen
<span># activate venv</span>
./musicgen/scripts/activate
python -m venv musicgen # activate venv ./musicgen/scripts/activate

Enter fullscreen mode Exit fullscreen mode

step 2. Install pytorch

This step will take some time.

pip3 <span>install </span>torch torchvision torchaudio <span>--index-url</span> https://download.pytorch.org/whl/cu117
pip3 <span>install </span>torch torchvision torchaudio <span>--index-url</span> https://download.pytorch.org/whl/cu117
pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu117

Enter fullscreen mode Exit fullscreen mode

step 3. Clone repo and install requirements

git clone https://github.com/facebookresearch/audiocraft.git
<span>cd </span>audiocraft
pip <span>install</span> <span>-e</span> <span>.</span>
git clone https://github.com/facebookresearch/audiocraft.git
<span>cd </span>audiocraft
pip <span>install</span> <span>-e</span> <span>.</span>
git clone https://github.com/facebookresearch/audiocraft.git cd audiocraft pip install -e .

Enter fullscreen mode Exit fullscreen mode

step 4. Try to generate sound

As Google Colab, we will run web ui with the following command.

python app.py
python app.py
python app.py

Enter fullscreen mode Exit fullscreen mode

原文链接:Run MusicGen on Google Colab/Windows11

© 版权声明
THE END
喜欢就支持一下吧
点赞13 分享
No one can change another. But one can be the reason for another to change.
没人能改变另一个人,但是某个人能成为一个人改变的原因
评论 抢沙发

请登录后发表评论

    暂无评论内容