# Music Generation 🎵

Music Generation offers game developers **the ability to create music that perfectly matches the intended mood or atmosphere** of the scene.

## Udio 🔒💸

[Udio](udio.com/) is a **generative AI model that produces music based on prompts**.

What’s interesting is that you c**an generate music instrumental or with lyrics.**

For now, you can make 600 daily generations (music)!

Udio can generate excellent music with lyrics; you can check their examples on the website.

But for the game demo I’m working on for the future unit, where you’re stuck in a ship with aliens, I **needed something abstract and uneasy**, so I used this prompt: *a piece of instrumental music on space void and threatening aliens*

And I got this 👉 https://www.udio.com/songs/pYXsK6GsMiwyMd8B3ZEU7R, which this is perfect for my game menu

The model generates 33 seconds of the music, but you can then **ask the model to extend it.**

If you want to get started with Udio, check this tutorial:

<iframe width="560" height="315" src="https://www.youtube.com/embed/iRn4LcJ6CR8?si=tZ7BEM48UU8nddql" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>

## **MusicGen** 🆓 🤗

This model, made by Meta AI, allows you to **generate 15 seconds of music** with a text prompt and sound file to help control the style of the music.

I used the same prompt as above and I got this lovely result:

<iframe width="560" height="315" src="https://www.youtube.com/embed/_2dfQlvTapQ?si=rYc6S0RyrROQmqDE" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>


You can try it on Hugging Face Spaces 👉 https://huggingface.co/spaces/facebook/MusicGen

<EditOnGithub source="https://github.com/huggingface/making-games-with-ai-course/blob/main/units/en/unit2/music-generation.mdx" />