A backup generator can be used if it's listed for fire alarm backup (Fire Rated), regularly tested, and monitored by the fire alarm panel. The generator doesn't eliminate the need for batteries. It might, however, reduce the size of batteries needed.
All fire alarm systems require two sources of power. One source is the primary power, and in case that one fails, a second source for power.
As their primary source of power, fire Alarm Systems, including Fire Alarm Control Panels (FACP), Signal Power Expanders (SPX), and other auxiliary fire alarm power sources, use the AC utility power. This is the most consistent and reliable source.
However, the primary utility power, like any other source of power, sometimes fails. Batteries, as a secondary backup power source, are used only when the primary utility power fails. This is an automatic switchover from the primary source to the backup.
A long time ago, some buildings had an emergency power entry so if the primary power source for the building failed, functions like emergency lights could stay running. At that time, there was no such thing as battery backup, so this emergency power was used to at least sound the trouble buzzer for the fire alarm system.
Nowadays, to back up the utility power for the building, many commercial buildings and larger residential complexes have an automatic standby (emergency) generator. The generator turns on when the utility power fails.
The generator doesn't start instantaneously; there's a short blackout period. During this time, if the fire alarm system is already in alarm, batteries are needed to keep it going.
As far as the generator goes, technically, the generator needs to be "Fire Rated", regularly tested, and monitored by the fire alarm panel as an official backup generator. A generator like this doesn't eliminate the battery requirement for any fire alarm panel; the generator just reduces the size of battery needed for backup.
The manufacturer of the fire alarm equipment has rated and tested the equipment with the batteries, so therefore, batteries are required.
Much of the time, this generator isn't used for the whole building, so for the generator to do any good, the whole fire alarm system (including the SPX) has to be connected to the generator.