Neil Patrick Harris has apologised publicly for using the term “tranny” on television.

The gay actor, 38, who currently appears on the popular US sitcom How I Met Your Mother, had been inhaling a gas which lowers voices.

Harris apologised after inhaling the gas on Live! with Kelly, he said: “I’ve never sounded more like a tranny in my life.”

Sulphur hexafluoride is a high-density gas which has the opposite effect to helium on vocal cords, by slowing down the speed of sound waves.

Helium, being much less dense than normal air, means sound waves can travel faster, so the speaker’s voice has a higher pitch. Sulphur hexafluoride is 36 times heavier than helium and lowers the human voice.

Harris later posted on Twitter: “Truly sorry for saying the word ‘tranny’ on Live this week. Twice! Should have been more thoughtful. Didn’t at all mean to offend.”

Kelly Osbourne, who has been vocal in her support of gay rights, wrote an open letter last month apologising for her use of the word to refer to a person awaiting gender reassignment surgery.