Yes dselec is right, dont do that.
You need good generator design and electronic device which will do the job. You see Honda do the job with inverter generators, alternator charging battery inside and inverter gives electrically controlled sinusoide, which is better and easier to control single or in paraller unlike the classic just mechanical generator.
This is not easy job, I just post this material to see that is possible. Big companies each have solution design for this in secret, how for small generators and for big systems for buildings.