When you breathe in helium from a balloon, your voice shoots up to a cartoonish high pitch - but technically, your voice isnโt changing. Your vocal cords are still vibrating at exactly the same frequency. Whatโs different is the gas theyโre vibrating.
Sound travels much faster through helium than through normal air - roughly three times faster, because helium atoms are very light and move around quickly. When sound moves faster through a medium, the resonance of any cavity it passes through (like your throat and mouth) shifts to higher frequencies. So while your vocal cords sound the same, the harmonics that color your voice get shifted way up, and your voice sounds higher.
The opposite effect is even more dramatic. Sulfur hexafluoride is a heavy, harmless gas that sound travels through slower than air. Breathe a small puff of it and you sound like a low-pitched movie villain - the harmonics shift downward. Itโs the same physics, just in reverse. Either way, your voice itself never actually changes pitch.