I taught mine to fetch and bring me a toy when he wants to bark. It was fairly easy and effective. I did it accidentally by using toys to distract him from barking at things out of the window when I was working. It's not how I would usually train out this behaviour but if you have a dog who loves to play it is very effective.
I basically just waited for a second of silence, grabbed a toy and called him over to play. After a few days of this he started bringing me a toy instead of barking. It's not always perfect. Yesterday for instance he brought me a roll of wallpaper because he'd buried all his toys in the garden the day before.
My usual way of training this was to train "speak" and "quiet" in dedicated training sessions and to wait for silence when they do bark outside of training sessions and immediately treat, you can add the quiet command to reinforce it if you've already started the speak/quiet training. Once you have their attention this way lead them away from the window and run through some simple commands/lure training to burn off a bit of energy.
Just sitting outside/in the window and rewarding calm behaviour is also an effective way of calming an overstimulated dog. If there is a general trigger eg other dogs/people try to sit at a distance where your dog notices and is interested in the trigger but not so close that they lose their shit. Reward any behaviour you like (sitting, laying, checking in with you and ignore them when they're focused on the trigger).
I haven't watched all of the below videos but their training is generally spot on
Avoid antibark collars. They're cruel and ineffective. The dog can get confused and start to believe that what they are barking at is what caused the pain and it can add to fear aggression issues. It's also common for dogs to learn they can bark and bark and bark and the collar will run out. Dogs have burned and injured themselves this way in the past.
These collars should be banned imo.