Buy a buzzer that makes the noise you want and switch it on an off with that single transistor. I work with machinery from dozens probably hundreds of manufactures and nobody would even bother with a speaker as an alarm. The usual approach is some sort of buzzer or possibly a bell. It doesn't matter what the controller is made of either, could be a custom CNC, PLC or a single board computer. It comes down to what you waste your time on and noise makers are not a place to do that.
If you look inside lots of alarm modules you'll find, they quite often have a speaker driven by an amplifier and an oscillator, or a synthesiser. Obviously this doesn't apply to plain old bells and buzzers, but certainly does to those which make more complex sounds, that can be changed/varied, i.e. the type with a small switch, or multiple inputs for different sounds.
If the intention is to integrate this into a small, compact enclosure, then it certainly makes sense to use a speaker, class D amplifier and software/hardware synthesiser, especially if there's an FPGA sitting there with a lot of unused gates, ready to do the job. It has the advantage of flexibility:the alarm sound can be changed with a little programming, rather than having to change the entire alarm module, if it can't make the desired sound.
A similar principle applies to other things such as switched mode power supplies and motor drives: in an industrial application, it would be preferable to use a ready built module, but in mass produced consumer electronics, it's often cheaper to add it to the PCB and there might not be space, for a bulky industrial module.