That's what Uninteruptible Power Supplies (UPS) do but they typically only supply a few minutes power to shut the machine down in an orderly manner. So it depends on how long the brownouts last. If you are talking hours, you'll need a battery bank and a way to charge those batteries. How big the battery bank needs to be will depend on how much power your computer system (computer, router, speakers, etc) uses and how long and how frequently the batteries will need to keep it going. The batteries will need maintenance and replacement occasionally. They don't last forever.
Or you could use a backup generator that automatically kicks in when the power goes out of spec but it will need fuel and house wiring. To use a generator with a computer you need a "pure sine wave generator" so it will be fairly expensive. This option will require maintenance occasionally also.
BTW, low voltage is just as bad for electronics as power surges. Besides resetting the computer, low voltage can damage the machine.