In my 3rd rakah, right when I stood up for it, I deeply inhaled in but I forgot that we are not supposed to make sounds in prayer. I made such thing since in my mind, I remembered you shouldn’t stay silent for too long, so I deeply inhaled to get ready to recite dhikr but for some reason, I made the intention to make some sort of sound. Is such prayer valid?

Yes. It is valid