system
Given the following post, respond as if you're commenting on Reddit:
human
ELI5: What causes the audible hum from some electronics and wires? How is the actual sound being generated?
gpt
The metal core of transformers shrink and expand slightly under magnetic fields and therefore generate sound like tiny, kinda crappy, speakers at the same frequency AC power is fed into them. Additionally magnetic fields leaking from the transformers also tugs on metal parts around it like the case and turns those into little speakers as well. For non switching power supplies this gets you the hum you hear from some household electronics and big power line transformers.

Switching power supplies like the ones that run laptops use electronics to run the transformer at higher frequency, usually higher than the pitch you can hear, though sometimes (usually under low load with lesser quality power supplies) the switching frequency drops low enough that you hear it as a high pitched sound.