Audiocraft is a research library from Facebook AI for state-of-the-art audio generation, including models like MusicGen and AudioGen. It is built on PyTorch, providing tools for both model inference and training. Currently at version 1.3.0, it sees active development with new releases roughly every 1-3 months, often coinciding with new model research.
pip install audiocraftVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to load a pretrained MusicGen model, generate an 8-second audio clip based on a text description, and save it to a WAV file. Ensure you have sufficient disk space and a stable internet connection for the initial model download. GPU is highly recommended for faster generation.
Use a GPU with sufficient VRAM (e.g., 24GB+ for 'medium' models and longer generations). Reduce `duration` in `set_generation_params`. Try smaller models ('small'). Consider CPU inference as a last resort, but it will be very slow.Use `model.generate(descriptions=None)` for unconditional generation. The `generate` method now handles both conditional and unconditional generation.
Ensure you have a stable internet connection and at least 5GB of free disk space. On unstable networks, consider pre-downloading models or increasing connection timeout settings if possible.
Install `libflac-dev` (Debian/Ubuntu) or `flac-libs` (Fedora/CentOS) or `libflac` (Arch Linux) using your system's package manager. For example: `sudo apt-get install libflac-dev`.