"And the LORD opened the mouth of the donkey." From the day she was created, the Holy One, blessed be He, had opened her mouth, for [the gift of speech] was deposited within her mouth; but she was not permitted to speak, for her mouth was stopped up until that hour. For it does not say, "And the LORD placed a word in her mouth," but rather, "And the LORD opened [her mouth]" — from here [we learn] that the matter [of speech] had [already] been placed in her mouth, and she lacked nothing but the opening.
Why the Donkey Only Needed an Opening to Speak to Balaam
Midrash Aggadah, Numbers 22:28
ויפתח ה' את פי האתון. מיום שנבראת הקב"ה פתח את פיה שהיה מסור בפיה, אבל לא היתה רשאה לדבר, כי נסתם פיה עד אותה שעה, שלא נאמר וישם ה' דבר בפיה אלא ויפתח ה', מכאן שהיה הדבר מושם בפיה, ולא היתה חסרה אלא מפתח: