I did this when I was a teenager and it was surprisingly effective at helping me get out of a depressive period.
Instead of barking I would drown out the negative with a small, pre-thought up, positive sentence about myself. When I caught the negative thoughts, I'd drown them out with it in my head.