Generating sound and music: AudioLM to Bark
Most audio generators write codec tokens with language models, in a hierarchy (AudioLM, MusicLM, Bark, Jukebox) or with delayed codebooks (MusicGen, AudioGen); AudioLDM 2 runs latent diffusion. Rights and evaluation follow.
What runs in CodeSplash
You will be able to
- Explain hierarchical token generation, from semantic to coarse to fine tokens
- Lay out MusicGen's delay pattern for several codebooks
- Describe latent diffusion for audio and the multi-level codes of Jukebox
- Evaluate generated audio for quality, prompt adherence and copying, and check the rights to its weights and data
Audio as tokens, again
ReadThe codec lesson turned audio into a few integer tokens per frame. Generation then becomes language modeling: predict the next token, sample, repeat, and let the codec's decoder play the result. A codec language modelCodec language modelA language model over neural-codec tokens. It writes audio as token sequences, and the codec's decoder turns them into sound. can continue a prompt, follow a text description, or both.
Two problems shape the designs. Audio needs long context: a few seconds of music span thousands of tokens. And each frame has several codebooks, so "next token" must be defined across them.
AudioLM: meaning first, sound second
ReadAudioLM generates in three stages. Semantic tokens, clusters of a self-supervised speech model's features (discrete speech unitsDiscrete speech unitsTokens made by clustering self-supervised speech features. They stand for sounds and let language-model tools generate speech.), carry content and long-range structure at a low rate. Coarse acoustic tokens, the first codebooks of a neural codec, add voice and recording conditions. Fine tokens add detail:
Given a few seconds of speech or piano, it continues them plausibly, without any text. The reference's example adds the three stage losses: 2.16.
Reference · AUD056 · Explained hereAudioLMA hierarchical generative audio framework combining semantic tokens with acoustic codec tokens. It models continuation from audio context and demonstrates language-model-style generation without requiring text…MusicLM and Bark: the hierarchy with prompts
ReadMusicLM puts a text condition on top of AudioLM's hierarchy. A joint music–text embedding model maps the prompt, "calm piano over soft rain", into the space the semantic stage is conditioned on. Its three stage losses sum to 2.16 in the reference's example.
Bark runs a similar text-to-semantic-to-coarse-to-fine chain over codec tokens and can produce speech, laughter and music-like sounds. It samples, so it isn't a deterministic text reader: it may skip, add or change words. Its staged losses give 2.16 on the same toy table.
Reference · AUD060 · Explained hereMusicLMA research text-to-music framework combining a music–text embedding space with hierarchical semantic and acoustic token generation. Reference · AUD063 · Explained hereBarkA publicly documented text-prompted generative audio model with hierarchical semantic and acoustic token stages.MusicGen: one model, delayed codebooks
ReadMusicGen uses a single Transformer over EnCodec tokens. To predict several codebooks at once without a hierarchy of models, it uses a delay patternCodebook delay patternA way to predict several codebooks with one language model: each codebook's tokens are shifted a step, so they're predicted together.: codebook is shifted steps, so at each step the model emits one token per codebook, and each depends on the earlier codebooks of its frame from previous steps.
T, Q = 5, 3 # frames, codebooks
for q in range(Q):
row = ["."] * (T + Q - 1)
for t in range(T):
row[t + q] = str(t) # frame t of codebook q is predicted at step t + q
print(f"book {q}: " + " ".join(row))T <- 5; Q <- 3 # frames, codebooks
for (q in 0:(Q - 1)) {
row <- rep(".", T + Q - 1)
row[(0:(T - 1)) + q + 1] <- as.character(0:(T - 1)) # frame t of book q at step t + q
cat(sprintf("book %d: %s\n", q, paste(row, collapse = " ")))
}Text, and for some versions a melody, condition the model. Two codebook losses on the reference's toy table sum to 0.919.
Reference · AUD058 · Explained hereMusicGenA controllable music generator using one language model over multiple codec-token streams with an interleaving/delay pattern. It supports text conditioning and, for appropriate variants, melody conditioning.AudioGen: sound effects from words
ReadAudioGen applies the same idea to environmental sound: a Transformer writes codec tokens conditioned on a text description, . Prompts such as "footsteps on gravel, wind" need sounds to be layered at once, which makes prompt adherence harder than for single sources. Its conditional token loss on the reference's toy table is 0.459.
Decoding settings matter: a higher temperature gives more varied, less faithful sound. Keep the original paper and the later AudioCraft implementation apart when you cite results.
Reference · AUD057 · Explained hereAudioGenA text-conditioned environmental-audio generation framework modeling discrete acoustic tokens. It aims to produce sounds matching descriptions rather than only speech or music.Sampling the next token
ExploreDExplorable · Temperature and top-p
What do the sampling settings on a language model actually change?
With these settings, how likely is the single most likely token?
Below 1 sharpens the distribution; above 1 flattens it.
Keep the likeliest tokens until they hold this much probability.
“The p-value tells you how extreme”
- With these settings
- Default (temperature 1, no cut-off)
Twelve sampled tokens: extreme · surprising · surprising · unusual · rare · rare · unusual · surprising · rare · extreme · surprising · likely
Commit your prediction above to see the result
Make your prediction to see the result.
Every codec language model in this lesson chooses tokens this way. Lower the sampling temperatureSampling temperatureRescales a language model's next-token scores; low values sharpen the distribution, high values flatten it. and outputs grow repetitive and safe; raise it and they grow varied and erratic. For audio, too low often loops a phrase, too high adds noise and drift. Report the decoding settings with any sample.
DExplorable · Decoding: greedy, beam search and sampling
How does the way we pick tokens change the sentence a language model writes?
Method
Greedy takes the likeliest token each step; beam search keeps several partial sentences; sampling draws.
Beam search only: partial sentences kept at each step.
Length normalization
Total log-probability always favors shorter sentences; normalizing by length offsets that.
GNMT only: divide by ((5 + length) / 6)^α.
Sampling only: below 1 sharpens, above 1 flattens, as in llm-sampling.
Sampling only: keep the k likeliest tokens.
Sampling only: keep the likeliest tokens until they hold this much probability.
Tokens before the search stops.
“the data fits well today </s>”
Change the sample to draw another sentence from the same settings.
- Log-probability of the result
- −4.239
- Tokens
- 6
- Normalized score
- −4.239
- Gain over greedy (log-probability)
- −0.419
- Puzzle: Find a sentence more likely than greedy's.
- Puzzle: With beam search, make a sentence of five or more tokens win.
Sampling writes “the data fits well today </s>”: log-probability −4.239 over 6 tokens. Greedy's sentence has log-probability −3.820. The toy model's probabilities are fixed; only the way of choosing changes.
AudioLDM 2: latent diffusion
ReadAudioLDM 2 doesn't write tokens. Text is first turned into a sequence of general audio features, a "language of audio"; a latent diffusionLatent diffusionRuns diffusion on an autoencoder's compact codes instead of raw data, then decodes; cheaper, but bounded by the autoencoder. model then generates a compressed audio latent conditioned on it; a decoder and a vocoder render the waveform. One pipeline covers sound effects, speech and music within its training coverage.
The core is the usual noise-prediction error, in latent space: 0.0055 in the reference's example.
Reference · AUD059 · Explained hereAudioLDM 2A general audio-generation framework using a learned audio representation as an intermediate conditioning language and latent diffusion for waveform-related generation.Jukebox: raw audio, three levels
ReadJukebox generates songs as raw audio, with singing. A multi-level VQ-VAE compresses audio into codes at three time scales; the coarsest level carries the song's structure. Autoregressive priors generate the top level from genre, artist and lyrics, then upsamplers fill in each finer level. The VQ-VAE's commitment term is 0.0033 in the reference's example.
It showed raw-audio music generation was possible, at extreme compute: minutes of sampling per second of audio on large GPUs.
Reference · AUD061 · Explained hereJukeboxA music-generation system learning compressed audio codes at multiple temporal scales and autoregressive priors over those codes.Rights and evaluation
ReadGenerators can reproduce training material: a melody, a voice, a recognizable recording. Check the terms of the training data, the code and the weights separately; several models here have non-commercial weights or none public. Evaluate on separate axes: overall quality (Fréchet audio distanceFréchet audio distanceThe Fréchet distance between Gaussian fits to embeddings of real and generated audio. The embedding model is part of the metric. against real audio, and listening tests), prompt adherence (a CLAP score, with its blind spots), diversity, and copying, by searching for near-duplicates of training clips.
DExplorable · Scoring generators: FID, precision and recall
Can one number say how good generated samples are?
How will this generator's precision and recall come out?
Generator
The real data is a ring of 8 clusters. Each generator gets something different wrong.
Feature extractor
FID and the k-NN scores compare features, not raw samples. Real FID uses a vision network; here, four simple maps.
How many real and how many generated samples are compared.
Each sample's ball reaches its k-th nearest neighbor in its own set.
Commit your prediction above to see the result
Make your prediction to see the result.
Where it stands in CodeSplash
Read| Entry | In CodeSplash |
|---|---|
| AudioLM (AUD056) | Explained here; no public weights |
| AudioGen (AUD057) | Explained here; non-commercial weights |
| MusicGen (AUD058) | Explained here; non-commercial weights |
| AudioLDM 2 (AUD059) | Explained here; non-commercial weights |
| MusicLM (AUD060) | Explained here; no public weights |
| Jukebox (AUD061) | Explained here; its terms and compute rule it out |
| Bark (AUD063) | Explained here |
CodeSplash doesn't generate audio or music. The reference programs are component checks, verified in Python and R.
Check: generating audio
CheckpointCheck yourself
What do AudioLM's semantic tokens carry that its acoustic tokens don't model as well?
Show the answer
Answer: b
Clusters of self-supervised features capture what is said or played; codec tokens capture how it sounds.
Check yourself
Does AudioLM need text to generate speech?
Show the answer
Answer: a
It models audio tokens directly. Text conditioning came in later systems built on the same hierarchy.
Check yourself
How does MusicLM bring a text prompt into an AudioLM-style hierarchy?
Show the answer
Answer: b
The embedding links descriptions and music; the hierarchy then generates tokens as before.
Check yourself
A colleague wants to reproduce MusicLM results locally. What's the obstacle?
Show the answer
Answer: b
A paper's capabilities don't come with a checkpoint. Name any reproduction you use.
Check yourself
Why shouldn't Bark be used where the exact words matter, such as reading instructions aloud?
Show the answer
Answer: b
Generative sampling trades faithfulness for expressiveness. Check the output against the text.
Check yourself
Which chain does Bark's documented design follow?
Show the answer
Answer: b
It mirrors AudioLM's hierarchy, with text at the top.
Check yourself
With a delay pattern, 4 codebooks and 4 frames, how many generation steps does MusicGen need?
Show the answer
Answer: 7
Codebook is shifted by steps, so the last token, frame 3 of codebook 3, comes at step , counting from 0: steps.
Check yourself
What does the delay pattern let MusicGen avoid?
Show the answer
Answer: a
One Transformer emits one token per codebook per step, each conditioned on earlier codebooks of its frame from previous steps.
Check yourself
Why is prompt adherence hard for AudioGen-style sound-effect generation?
Show the answer
Answer: b
"Footsteps on gravel, wind, a distant dog" asks for three overlapping sources in the right balance.
Check yourself
You raise the sampling temperature for AudioGen. What do you expect?
Show the answer
Answer: b
Temperature flattens the token distribution: more diversity, less adherence. Report it with any sample.
Check yourself
What does AudioLDM 2's diffusion model generate?
Show the answer
Answer: b
A decoder and a vocoder turn the latent into sound afterwards.
Check yourself
Why can't CodeSplash offer AudioLDM 2 or MusicGen models?
Show the answer
Answer: b
Usable weights are a separate question from published code.
Check yourself
How does Jukebox handle the length of raw-audio songs?
Show the answer
Answer: b
The top level carries song structure at a low rate; lower levels add detail.
Check yourself
What limited Jukebox's practical use?
Show the answer
Answer: a
It proved raw-audio song generation possible; later codec-token models made it far cheaper.
Recap
Recap- Codec language models write audio as tokens; AudioLM, MusicLM and Bark go semantic → coarse → fine.
- MusicGen predicts several codebooks with one model by delaying each; AudioGen does the same for sound effects.
- AudioLDM 2 runs latent diffusion; Jukebox stacks three levels of VQ-VAE codes.
- Check rights and evaluate quality, adherence, diversity and copying separately. All are explained here.
Concepts in this lesson