I agree TRAINING is the answer, and this is coming from someone that grew up with Collies and Shelties - Sadly, 2 of the most common breeds to be debarked

I've known many debarked dogs - Alot make a gasping noise. Sadly, my Benjamin has been debarked. Didn't realize it until this morning, I heard what I thought was him coughing until I realized he was trying to bark at the cat teasing him, made me cry to hear that horrible noise - I'd rather deal with the barking!