{"id":9500,"library":"audiocraft","title":"audiocraft - Audio Generation","description":"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.","status":"active","version":"1.3.0","language":"python","source_language":"en","source_url":"https://github.com/facebookresearch/audiocraft","tags":["audio","generation","AI","PyTorch","ML","musicgen","audiogen"],"install":[{"cmd":"pip install audiocraft","lang":"bash","label":"Stable release"},{"cmd":"pip install -e '.[dev]' --no-deps","lang":"bash","label":"From source (development)"}],"dependencies":[{"reason":"Core deep learning framework (PyTorch)","package":"torch"},{"reason":"Audio I/O and processing for PyTorch","package":"torchaudio"}],"imports":[{"note":"Models are directly accessible from `audiocraft.models`.","wrong":"from audiocraft.models.musicgen import MusicGen","symbol":"MusicGen","correct":"from audiocraft.models import MusicGen"},{"note":"Models are directly accessible from `audiocraft.models`.","wrong":"from audiocraft.models.audiogen import AudioGen","symbol":"AudioGen","correct":"from audiocraft.models import AudioGen"},{"note":"The utility for writing audio files moved from `utils` to `data.audio`.","wrong":"from audiocraft.utils.audio import audio_write","symbol":"audio_write","correct":"from audiocraft.data.audio import audio_write"}],"quickstart":{"code":"from audiocraft.models import MusicGen\nfrom audiocraft.data.audio import audio_write\nimport torch # For moving to CPU if needed\n\n# Load a pretrained MusicGen model ('small' is generally recommended for quick tests)\n# This will download model weights (~2GB for 'small'). Ensure stable internet and disk space.\n# Specify device if needed: model = MusicGen.get_pretrained('small', device='cuda')\n# Ensure you have a compatible PyTorch/CUDA setup for GPU usage.\nmodel = MusicGen.get_pretrained('small')\nmodel.set_generation_params(duration=8) # Generate 8 seconds of audio\n\n# Define a description for the music\ndescription = \"a retro synthwave track with a driving beat\"\n\nprint(f\"Generating audio for: '{description}'...\")\n# The generate method takes a list of descriptions. For unconditional generation, pass descriptions=None.\nsamples = model.generate(descriptions=[description], progress=True)\n\n# Save the generated audio to a WAV file\n# `samples` is a torch.Tensor. It's good practice to move to CPU before saving if it's on GPU.\naudio_write(\n    'my_synthwave_track',\n    samples[0].cpu(), # Take the first generated sample and move to CPU\n    model.sample_rate,\n    strategy=\"loudness\",\n    loudness_compressor=True # Recommended for better audio quality\n)\n\nprint(\"Audio saved as 'my_synthwave_track.wav'\")","lang":"python","description":"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."},"warnings":[{"fix":"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.","message":"Generating audio, especially longer clips or with larger models ('medium', 'large'), is extremely GPU memory intensive. Running out of VRAM is the most common issue.","severity":"gotcha","affected_versions":"All"},{"fix":"Use `model.generate(descriptions=None)` for unconditional generation. The `generate` method now handles both conditional and unconditional generation.","message":"The `model.generate_unconditional()` method has been removed/renamed.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"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.","message":"Initial model loading requires downloading large weights (~2GB-3GB+). This can fail due to network issues or insufficient disk space.","severity":"gotcha","affected_versions":"All"},{"fix":"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`.","message":"On Linux, you might encounter `FileNotFoundError: libFLAC.so.8` or similar errors if audio processing dependencies are missing.","severity":"gotcha","affected_versions":"All"}],"env_vars":null,"search_vec":"'-3':53 '1':52 '1.3.0':42 'activ':45 'ai':11,63 'art':17 'audio':2,18,61 'audiocraft':1,4 'audiogen':25,67 'built':28 'coincid':56 'current':39 'develop':46 'everi':51 'facebook':10 'generat':3,19,62 'includ':20 'infer':36 'librari':8 'like':22 'ml':65 'model':21,35,59 'month':54 'musicgen':23,66 'new':48,58 'often':55 'provid':31 'pytorch':30,64 'releas':49 'research':7,60 'rough':50 'see':44 'state':14 'state-of-the-art':13 'tool':32 'train':38 'version':41","created_at":"2026-04-17T01:19:13.139292+00:00","updated_at":"2026-04-17T01:19:13.139292+00:00","problems":{"verify_error":"× Failed to build `av==11.0.0`\n  ├─▶ The build backend returned an error\n  ╰─▶ Call to `setuptools.build_meta:__legacy__.build_wheel` failed (exit\n      status: 1)\n\n      [stdout]\n      pkg-config could not find libraries ['avformat', 'avcodec', 'avdevice',\n      'avutil', 'avfilter', 'swscale', 'sw"},"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"1.3.0","cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/facebookresearch/audiocraft","docs":null,"changelog":null,"pypi":"https://pypi.org/project/audiocraft/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["ai-ml","data","llm-agents"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"install_fail","verified_at":"2026-06-28","last_verified":"2026-06-28","next_check":"2026-07-05","install_tag":null}}