A loudspeaker converts an electrical signal into motion that drives acoustic waves. In a moving-coil design, electric current through a coil in a magnetic field produces a force on the attached diaphragm. The diaphragm displaces air, creating sound pressure variations.
A small coil, magnet and lightweight cup can demonstrate the conversion directly. [ref]
Loudspeakers by the University of Iowa. University of Iowa, Loudspeakers: coil, magnet and cone demonstration
In an idealized uniform-field geometry, the driving force scales as . The emitted sound also depends on diaphragm inertia, suspension spring constant, damping and acoustic impedance, so the electrical waveform alone does not specify a flat acoustic frequency response.