Skip to content
BIASED

Audio generation: speech and music

Block 1 of 8~3 min

Sound as a signal

Autoregressive transformers left a recipe: a learned autoencoder turns an image into a short sequence of codes, and a transformer continues that sequence one code at a time. This extension takes that recipe, and the flows of The change of variables, to sound.

Sound is long. A microphone records air pressure, and a sound file stores it fsf_s times per second as a waveform, a sequence of numbers in [−1,1][-1, 1]. Speech corpora such as LJ Speech, about 24 hours of one speaker, use fs=22,050f_s = 22{,}050 Hz. WaveNet, the audio model of Autoregressive models, generates those samples one by one: 22,050 network passes for one second of speech. A three-minute song at 32 kHz is almost six million numbers.

Two answers make sound shorter. Speech systems keep a continuous summary, the mel spectrogram. Music systems compress the waveform into a few streams of discrete codes. This topic follows one model of each kind.

The spectrogram shows which frequencies sound when. The short-time Fourier transform cuts the waveform into overlapping windows and takes the Fourier transform of each; the magnitudes form a time–frequency image. With windows of 1024 samples and a hop of 256 samples, one second at 22,050 Hz gives 22,050/256≈86.1322{,}050 / 256 \approx 86.13 frames.

The mel spectrogram also compresses the frequency axis the way hearing does. We tell pitches apart finely at low frequencies and coarsely at high ones, and the mel scale follows that. A frequency ν\nu in hertz becomes, in mel,

m(ν)=2595log⁡10(1+ν700),m(\nu) = 2595 \log_{10}\Big(1 + \frac{\nu}{700}\Big),

so 1000 Hz maps to 1000 mel and 11,025 Hz, the highest frequency a 22,050 Hz recording can hold, to about 3176 mel. A bank of F=80F = 80 triangular filters, equally spaced in mel, sums the magnitudes into bands, and the result goes on a log scale. One second of speech becomes 80⋅86.13≈689180 \cdot 86.13 \approx 6891 numbers instead of 22,050, about 3.2 times fewer. It is a small image: 80 rows, 86 columns per second.

The price is the phase. Magnitudes say how much of each frequency is present, not how the waves line up, so many waveforms share one mel spectrogram. A vocoder must invent a plausible waveform for it.

Answers are saved on the server and tied to this browser until you sign in.