A changing electrical signal is fed to the voice coil of a loudspeaker, which lies within the magnetic field of a permanent magnet.
The signal in the coil causes it to behave like an electromagnet, making it push against the field of the permanent magnet. The speaker cone is then pushed in and out by the coil in time with the signal.