There are various ways. One of the earliest was the carbon granule microphone, where loosely packed carbon granules rearranged themselves as sound pressure impacted, and that changed the electrical resistance in proportion to the intensity of the sound waves.
Then you have the principle that is the same as the typical loudspeaker, except in reverse. Sound waves impact a surface, which deflects in proportion to the sound pressure level. The material is attached to a moving coil or a magnet surrounded by a fixed coil, and via Faraday’s Law, a potential is induced in the coil in proportion to the deflection.
Then you have a piezo-electric effect, where mechanical pressure (here sound waves) impacting on a crystal cause it to generate a small and proportional voltage.
Finally, not a microphone per se, but an eavesdropping device where a laser is bounced off a window of a room in which people are speaking. The sound pressure level causes minute deflections in the window glass, and the reflected laser beam interferes with itself, with the interference pattern proportional to the sound pressure level.
Lots of ways to skin a cat.
The working principle of micro phone is just opposite of speaker.
Speaker: It converts Electrical energy to sound energy
Microphone: It converts sound energy to electrical energy.
Working of general microphone:
It works on Faraday's law of Electo Magnetic Induction ie when electrical conductor moves in Magnetic field,it produces electric current.
Mangnetic field is produced by permanent magnet and a Electrical conductor coil(generally copper) is placed on a piston (generally plastic or aluminum). When we speak, it creates vibration and conductor on circular membrane/piston moves little bit and electrical current Flows. Speaker at other end again converts electrical current to sound energy.
All microphones have a transducer of some type.
The dynamic uses a moving coil, like a tiny speaker working in reverse, while a condenser uses a capacitor like element, a diaphragm usually of special plastics (rarely metals) vapor coated, or sputtered often with gold or nickel.
This is stretched in front of a back plate, in an arrangement where the diaphragm and backplate are charged at opposite electrical polarities.
The voltages are set so the capsule sits at a zero potential, until the skin of the diaphragm is moved closer or farther away from the backplate by sound pressure waves.
This changes the capacitance, swinging the voltages either negative or positive, resulting in an an electrical representation of the physical movement of the diaphragm.
At this point the voltages are in the millivolts and need to be stepped up by an internal amplifier.
A tube or FET is used in most cases, and the signal may lastly go through a transformer to step the voltage up even more before headi g to the mic preamp.
Ribbon mics use a "Ribbon Motor", in which a thin ribbon of aluminium moves within a gap between two powerful magnets.
As you move a non-magnetic material past a magnet, flux is generated,.
The ribbon moves in unison to the soundwaves it is exposed to, creating positive and negative swings in the voltage.
The tiny amount of voltage is stepped up with a transformer, and in some cases goes through an internal amplifier, as in an active ribbon mic design, then it is off to the mic preamp.