40 years ago, you might have had a computer where the CPU controlled the speaker directly. Those times are over, long ago.
You may have a computer with a primitive sound card. Such a sound card will have a buffer for stereo audio samples, that buffer can be filled, the output function will be started, and the sound card starts generating audio from the samples in its buffers, without the CPU having to do anything. All the CPU needs to do is fill the buffers with more audio samples before it runs out. If you have a one megabyte buffer, that's 250,000 stereo samples in CD quality, that's about six seconds. So every few seconds, the CPU has to fill these buffers again.
In reality, your computer will have something much more advanced. In principle the same, but the buffers can be filled directly with sound in mp3 or aac format, for example, and the sound card will decode this data to stereo samples on its own. Most likely it can be programmed to produce all kinds of different effects, from sound volume, improving sound quality, changing pitch or speed independently, generate surround sound and so on.
The CPU doesn't do very much, just filling the sound buffers from time to time. The rest is done by something else. Of course when I say "sound card", these have shrunk from sound cards to chips to a tiny fleck of transistors on a massive chip with lots of different functionalities.
For one maker of such cards, look at https://en.wikipedia.org/wiki/Wolfson_Microelectronics as a starting point.