Small device to detect AC outage
You should not mess with mains AC if you lack the experience.

I recommend using a (old, obsolete) power adapter which can output AC or DC but at a low voltage so that it is safe.

Then if it is AC, rectify the AC to DC.

If it is DC, no need to rectify.

Use that voltage to power a relay.

Use the normally closed contacts (the ones that open when the relay is powered) of the relay to power the buzzer from the battery, like so:







simulate this circuit &ndash; Schematic created using CircuitLab

I did not add many voltage ratings and component values as they will depend on what the Power adapter will deliver.

You need the bridge rectifier only when the Power Adapter outputs AC

But even if the  Power Adapter outputs DC and the Bridge rectifier is present, things will still work. Having the Bridge rectifier makes this more "fool proof".