I train our cats to stay away from certain things by acting like I am scared and concerned when they first explore the thing. Not mad, not angry, just concerned, and gently keeping them away from the "danger". Cats pick up on that an leave cords and other things alone. Assuming they trust you.
Spay/neuter, that reduces spraying a lot. Use enzyme cleaner on any spots that do happen.
Cats get more territorial when resources are scarce. Food, attention, spots to hang out. Usually behavioral issues can be reduced by giving the cat more attention. More play, seek them out and give them a few pets then walk away, invite them on the lap. Make some more cat friendly spots, cat trees, beds on windows so they can look out. Make sure they know the spot is for them. They might not take you up on it, but they will appreciate the offer.
Make sure if you have N cats you have N+1 litter boxes and keep them scooped. If you do have more than one, make sure everyone gets treats/pets, because cats think things should be fair. They will protest unfairness.
Spraying can be a sign of health issues. Cats do try to hide health problems, but when they suffer they try to let you know. Being stupid humans, we don't pick up the signs and they escalate to things we can't ignore. It can be hard, if you don't see it happen, to know if a spot was sprayed or just peed on. If this is new behavior, then maybe a vet check is in order.
Redirect. If speakers are anywhere near a door, the door is a boundary for territory. A scratching post near the door might help, giving them someplace closer to the door to mark with claws and cheeks.
My cats are very good, but I still have speaker grills on when not in the room.
Good luck!