The answer is probably Yes. The Yanmar
will need to have a governed speed control, but I think most diesels do. With a 4 pole direct drive generator
will need to turn at 1800 rpm (for 60hz) or 1500 RPM (for 50hz). A 2 pole generator will require double the engine
speed which is probably pushing it for the Yanmar, not to mention the added noise
, etc. You also could set it up as a DC generator and run your AC off an inverter
. With DC you would have more latitude around speed.
Do you have an exact model number for the engine?