I find two helpful strategies that have worked for myself and my clients.
1. Imagine yourself not as you, but as a loved one or best friend. Would you say those negative things to them or would you be understanding and supportive?
We always have very high standards for ourself but are much more forgiving of those around us.
and if the voice is really terrible
2. Personify the voice. It's not in your mind, instead, it's an ugly warty basement dwelling troll. Once you've visualized it saying terrible things about you, promptly tell it where it can stick its unwanted opinion, like you would any other troll in your life.
It takes work to catch it every time, but I've found a lot of success with the technique.