Create Unique Songs with the Open Source AI Music Generator in Google Colab

Written by Future Thinker @Benji - January 17, 2024


Create Unique Songs with the Open Source AI Music Generator in Google Colab

Hey guys, today I want to talk about the AI music generator from Facebook called Music Gen! I asked about what kind of AI tools or workflow you guys want in the community post, whether they are free or open source, allowing you to use them locally or online. And I saw a comment about AI song music. Here's what I found in open source AI for creating music, and Music Gen from Facebook can be one of the options!

On their official website, they have some samples from their text to music generation. Here are a few examples from their tests, showcasing stereo sounds and simple audio sounds from these open-source AI Music models. When you click the "Get Started" link, you will be redirected to their official GitHub page, which has downloadable versions of this open-source audio generator. To run this on your computers, you'll need to follow some installation steps.

However, I found another way to run this using Google Colab, which is also provided in their GitHub page. This music generator produces 32 GHz anchor tokenized with sampled at 50 HZ. I think this is good enough for most videos' background music or even creating some lowii music to play in your videos! So let's try out Google Colab!

Innovative Installation Process with Google Colab

In Google Colab, it's a straightforward process! Unlike other open-source projects where you need to click through many installations, they will be installing their tools from this GitHub link they provide. While you can download their Music Gen AI and install it locally on your PC, we are using Google Colab to remotely download and install it for online use. Just click the "Run" button, and it will start cloning the projects from GitHub and running the installations.

Checking the resources in Google Colab, it doesn't consume a lot of GPU RAM and system RAM. It seems pretty friendly for Google Colab! Let's wait for the installation to complete. The installation files won't be stored on your Google Drive; instead, they'll be in a temporary instance created. You can see the "audiocraft" folder in the files manager here, where these AI tools are installed.

Keep in mind that when you disconnect from Google Colab, these installation files won't be saved to your Google Drive. So, if you're using Google Colab, you'll need to go through this installation process each time. With the green check mark, the installation is complete! Now, let's execute and launch the programs, waiting for the links to appear. It's loading other components in these tools, so wait for the radio public URL to appear. Click on the public URL link to start running this. Additionally, there's another online demo in Hugging Face that you can try if you don't want to install this. But we already have Music Gen on our Google Colab, so let's use it!

Create Unique Songs with Music Gen!

Let's try, for example, a 90s hip hop music with heavy bass and keyboard. The first time the tool loads, it will download the model files, so wait for the download to complete. You can choose other models as well. I'm choosing the Facebook Music Gen manly models. Below that, there are other options we can explore later. Let's wait for the download to finish and generate our first result!

Wow, the first music is generated! Let's check it out. It looks pretty close to what I expected because it's a Melody only. For these models, I chose to download. Let's try another example, and you can also input the model path if you have already downloaded some Music Gen model files. Right now, I've already downloaded them. Let's try another text prompt. Let's try classic piano with relaxed mode!

The second time is faster in the generation since we don't need to download another model. Below, we have options like durations. You can create a maximum of 120 seconds, 10 seconds, or 60 seconds. It's an additional option. Below that, we have settings for the music temperature, the top K, and B. These control the temperature of the music. Let's try it!

Generated Music

This is pretty cool! The piano sounds are great. The preview below is wave files, and the one above is MP4 files. Both can be downloaded when the generation is complete.

Explore Different Music Styles with Music Gen

Now, let's try something else. Let's try their existing example, a cheerful country song. Clicking on this, they have other MP3 files on the right side that will be interrupting the generated music. The melody and rhythm will be similar to the reference MP3 files, but it will inject the sound from where you input the text prompt. Here, I have guitar sounds like in country songs. Let's see the result!

Now, let's try jazz bass guitar R&B styles without the interrupt file. So, it's purely generated by the text prompt. Let's also try another example using an MP3 file as a reference and then a text prompt. This one is a very classical melody that we hear all the time. The interrupt MP3 is injected into these areas, and then we click submit to see how the next generation turns out.

Okay, let's listen. It picks up some rhythm from the MP3 files. Let's listen again and go back to the preview of the generated music. You can see there's an interrupt from the original MP3 files, and it has also injected elements from the text prompt, like drums, arpeggios, pads, and strong emotions into the generated music.

Conclusion

So there you have it! This is a really cool tool for creating AI songs, AI music, and you can try it out! It's called Music Gen. They also have Audio Gen to create sounds like ducks or chickens, but in this video, we focused on Music Gen due to the many requests about AI song creations. You don't have to purchase any tools from other sources. You can use open-source options like this to create your own AI music. I hope this is helpful and inspiring for you to try out. Have a nice day!

FAQs

1. Can I use Music Gen offline?

Yes, you can! Music Gen has downloadable versions on their official GitHub page, which you can install locally on your PC.

2. Is Music Gen compatible with different music styles?

Definitely! Music Gen allows you to create music in various styles, whether it's hip hop, classical piano, jazz, country, or R&B. The possibilities are endless!

3. Can I adjust the duration of the generated music?

Yes, you can! Music Gen provides options for you to choose the duration of the music, whether it's 120 seconds, 10 seconds, or 60 seconds. Customize it to suit your needs!

4. What other AI tools are available from Music Gen?

Aside from Music Gen, they also have Audio Gen, which allows you to create sounds like ducks or chickens. Feel free to explore both tools!

5. Can I combine MP3 files with text prompts in Music Gen?

Absolutely! Music Gen lets you inject the sound from an MP3 file into the generated music, along with the elements from the text prompt. It's a great way to mix and match different musical elements!

  1. In today's data-driven world, the ability to extract and utilize information from the web is a crucial skill. Whether you're a data scientist, a business analyst, or just someone looking to gather ins

  2. If you're looking for a unique and underrated side hustle that can potentially earn you over $1,370 per day, then you're in for a treat. This method leverages the power of Canva's AI tools to create s

  3. Building a full-stack application without any coding knowledge and for free might sound too good to be true, but with the right tools, it's entirely possible. In this article, we'll guide you through

  4. In the ever-evolving landscape of artificial intelligence, new models and tools frequently emerge, each promising to revolutionize how we interact with technology. The latest entrant generating buzz i

  5. Is Journalist AI the ultimate AI writing tool you've been searching for? In this article, we delve into an in-depth review of Journalist AI, exploring its features, advantages, and potential drawbacks