This is the "speaker" portion contains parts on the photo. Ring sound from here.
Because it does not decompose, I do not know what kind of speaker in it, is assumed that there is a magnetic speaker about the size of 1.5cm.
I tried to create a diagram of the mechanism of magnetic speaker. The trick is an electromagnet. The electricity flows to the coil that is activated magnetic force and it will move the diaphragm. And the sound is ringing by vibrating the air. Periodic oscillation is about 100 to 20,000 times per second. The higher sound needs the pitch to vibrate faster. If such a small speaker to use earphones, you can also directly connect the terminals of the microcomputer. However, in such a large speaker of NXT current is not enough. So, you need to amplify the signal of the microcomputer. It has been amplified by using the IC for sound output in the NXT.