How is a NMR spectrum obtained?
The description is simplified, but actually fairly accurate. You can find all the details in a specialised NMR book (other general texts usually do not go into much detail).

Quantum mechanically, you can show that the precession frequency (Larmor frequency), denoted $\omega_0$, is related to the energy difference between the up and down spin states of a spin-1/2 nucleus. The energy levels are

$$\begin{align}
E_\alpha &amp;= +\frac{1}{2}\hbar\omega_0 \\
E_\beta &amp;= -\frac{1}{2}\hbar\omega_0 \\
\end{align}$$

and so the transition occurs at the frequency $|E_\beta - E_\alpha|/\hbar = \omega_0$, so if we can identify how much precession is happening at the frequency $\omega_0$, that tells us how strong the corresponding signal should be in the spectrum.

The initial data that you get is in the form of a free induction decay (FID), which plots the amount of detected magnetisation against time. The process of extracting the frequencies from the raw time-domain data is accomplished by a Fourier transform.

Feel free to ask if you would like any part of this to be elaborated. I intentionally did not go into great detail, partly because that is the role of a textbook, but also partly because it can get pretty complicated very quickly.

(There is also a complicated sign convention to do with the definition of $\omega_0$, and different books define it differently. Occasionally the definition even depends on the sign of the gyromagnetic ratio $\gamma$. I would advise to not worry too much about plus/minus signs.)