When a changing electric current is passed through a speaker, the magnet becomes an electromagnet. As the current direction changes, the electromagnet moves back and forth due to the force exerted on the current-carrying conductor in the magnetic field, causing the paper cone to vibrate. This produces sound.
The magnets in speakers are mainly ferrite magnets and neodymium iron boron magnets. Depending on the application, ferrite magnets can be divided into five main categories: soft magnets, hard magnets, gyromagnets, rectangular magnets, and piezomagnetic magnets. Neodymium iron boron magnets are widely used in electronic products, such as hard drives, mobile phones, headphones, and battery-powered tools.