audiocraft-audio-generation
What it does
This skill explains AudioCraft, Meta's PyTorch library for generating audio. It is for creators and developers who want to make music or sound effects from a written description.
When to use it
- βWhen you want to create a piece of background music from a text description.
- βWhen you need environmental sound effects, such as rain or traffic, generated from text.
- βWhen you want to guide a music generation with a melody you provide.
Skill link
https://github.com/Orchestra-Research/AI-Research-SKILLs/blob/main/18-multimodal/audiocraft/SKILL.mdCopy it and paste it into your AI (Claude, ChatGPT or Cursor), asking it to follow the instructions.
How to use
The easiest way: copy the message and paste it into your AI. It reads the skill and follows the instructions.
Ready-to-paste message
For Claude Code, Codex or Cursor: run it in your project folder and the skill gets installed.
Download the SKILL.md and drop it into your agentβs skills folder.
Example of what to ask your AI
βMake a 20 second calm piano track with soft rain sounds in the background.β
5 new skills a week. 1 minute to read.
How it works
You load a MusicGen or AudioGen model and pass a text description, and it generates audio. The skill also covers the EnCodec codec, stereo output and melody-guided generation.
Technical content (original SKILL.md)
Original text by the author, straight from GitHub.
AudioCraft: Audio Generation
Comprehensive guide to using Meta's AudioCraft for text-to-music and text-to-audio generation with MusicGen, AudioGen, and EnCodec.
When to use AudioCraft
Use AudioCraft when:
- Need to generate music from text descriptions
- Creating sound effects and environmental audio
- Building music generation applications
- Need melody-conditioned music generation
- Want stereo audio output
- Require controllable music generation with style transfer
Key features:
- MusicGen: Text-to-music generation with melody conditioning
- AudioGen: Text-to-sound effects generation
- EnCodec: High-fidelity neural audio codec
- Multiple model sizes: Small (300M) to Large (3.3B)
- Stereo support: Full stereo audio generation
- Style conditioning: MusicGen-Style for reference-based generation
Use alternatives instead:
- Stable Audio: For longer commercial music generation
- Bark: For text-to-speech with music/sound effects
- Riffusion: For spectogram-based music generation
- OpenAI Jukebox: For raw audio generation with lyrics
Quick start
Installation
# From PyPI
pip install audiocraft
# From GitHub (latest)
pip install git+https://github.com/facebookresearch/audiocraft.git
# Or use HuggingFace Transformers
pip install transformers torch torchaudio
Basic text-to-music (AudioCraft)
import torchaudio
from audiocraft.models import MusicGen
# Load model
model = MusicGen.get_pretrained('facebook/musicgen-small')
# Set generation parameters
model.set_generation_params(
duration=8, # seconds
top_k=250,
temperature=1.0
)
# Generate from text
descriptions = ["happy upbeat electronic dance music with synths"]
wav = model.generate(descriptions)
# Save audio
torchaudio.save("output.wav", wav[0].cpu(), sample_rate=32000)
Using HuggingFace Transformers
from transformers import AutoProcessor, MusicgenForConditionalGeneration
import scipy
# Load model and processor
processor = AutoProcessor.from_pretrained("facebook/musicgen-small")
model = MusicgenForConditionalGeneration.from_pretrained("facebook/musicgen-small")
model.to("cuda")
# Generate music
inputs = processor(
text=["80s pop track with bassy drums and synth"],
padding=True,
return_tensors="pt"
).to("cuda")
audio_values = model.generate(
**inputs,
do_sample=True,
guidance_scale=3,
max_new_tokens=256
)
# Save
sampling_rate = model.config.audio_encoder.sampling_rate
scipy.io.wavfile.write("output.wav", rate=sampling_rate, data=audio_values[0, 0].cpu().numpy())
Text-to-sound with AudioGen
from audiocraft.models import AudioGen
# Load AudioGen
model = AudioGen.get_pretrained('facebook/audiogen-medium')
model.set_generation_params(duration=5)
# Generate sound effects
descriptions = ["dog barking in a park with birds chirping"]
wav = model.generate(descriptions)
torchaudio.save("sound.wav", wav[0].cpu(), sample_rate=16000)
Core concepts
Architecture overview
AudioCraft Architecture:
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Text Encoder (T5) β
β β β
β Text Embeddings β
ββββββββββββββββββββββββββ¬ββββββββββββββββββββββββββββββββββββββ
β
ββββββββββββββββββββββββββΌββββββββββββββββββββββββββββββββββββββ
β Transformer Decoder (LM) β
β Auto-regressively generates audio tokens β
β Using efficient token interleaving patterns β
ββββββββββββββββββββββββββ¬ββββββββββββββββββββββββββββββββββββββ
β
ββββββββββββββββββββββββββΌββββββββββββββββββββββββββββββββββββββ
β EnCodec Audio Decoder β
β Converts tokens back to audio waveform β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Model variants
| Model | Size | Description | Use Case |
|---|---|---|---|
musicgen-small |
300M | Text-to-music | Quick generation |
musicgen-medium |
1.5B | Text-to-music | Balanced |
musicgen-large |
3.3B | Text-to-music | Best quality |
musicgen-melody |
1.5B | Text + melody | Melody conditioning |
musicgen-melody-large |
3.3B | Text + melody | Best melody |
musicgen-stereo-* |
FAQ
Which models are available?
The skill lists model sizes from small, at 300 million parameters, to large, at 3.3 billion parameters.
Can it make stereo audio?
Yes. The skill says full stereo output is supported.
How do I install it?
Run pip install audiocraft, or use the Hugging Face Transformers route.
Details
Original description by the author
PyTorch library for audio generation including text-to-music (MusicGen) and text-to-sound (AudioGen). Use when you need to generate music from text descriptions, create sound effects, or perform melody-conditioned music generation.
Popularity
- GitHub stars
- 14k
- Ranking position
- #11232
- License
- MIT
- Updated
- 10/10/2026
Comments
- β¦
More skills from this repository
autoresearch
14kGuides your agent through a full AI research project, from literature review to experiments and writing, with a repeating cycle of testing and review.
prompt-guard
14kLets your agent screen text for prompt injection and jailbreak attempts before it reaches your AI app, using Meta's small classifier.
pytorch-fsdp2
14kShows your agent how to add PyTorch FSDP2 to a training script so large models are split across GPUs and saved correctly.
ml-training-recipes
14kGives your agent proven training recipes for neural networks, covering model choice, optimizers, learning rates and fixing loss spikes.
Similar skills
openai-whisper-api
394kLets your agent turn an audio recording into text using OpenAI's transcription service, with options for speaker labels and output files.
openai-whisper
394kHelps your agent transcribe audio on your own computer with the Whisper command, with no API key and no cloud upload needed.
sag
394kHelps your agent read text aloud with ElevenLabs voices and play the result on your computer, with tips for pronunciation and expression.