The Rebbe advises seeking a medical specialist while stressing the spiritual impact of negative speech and anger, especially for a sofer STaM. He recommends studying Iggeres HaKodesh chapter 25 and reciting daily Tehillim after Shacharis, along with checking the tefillin—especially the shel rosh.
https://www.torahrecordings.com/rebbe/igroskodesh/015/010/5557