When you pass a metal wire through a magnetic field, an electrical current is created in the wire. This is called electromagnetic induction. Basically, an electrical generator is an engineered means of continuously moving multiple wires through magnetic fields to produce a steady electrical current, so the motion's kinetic energy(a part of mechanical energy) is being converted into electrical energy