There are two times in the Bible when animals spoke.
The first involved a serpent.
“‘You will not certainly die,’ the serpent said to the woman.” Genesis 3:4
The second embroiled a donkey.
“Then the LORD opened the donkey’s mouth, and it said to Balaam, ‘What have I done to you to make you beat me these three times?’” Numbers 22:28
In the second instance, it clearly states that God was the one who opened the donkey’s mouth. However, in the first instance we are told that the serpent categorically spoke, though it was under the influence of Satan.
The question that comes up is, did all animals speak at the beginning of creation?
Though there are no biblical verses to support that they all did, there remains that one recorded time when the serpent did actually speak on its own; which points to the possibility that most likely (some or all) animals did have to some degree the gift of speech, until the fall of man when God’s curse fell upon all creation and removed said gift from them.
“Cursed are you above all livestock and all wild animals!” Genesis 3:14
Just like Adam and Eve were cast out of the Garden of Eden because of their disobedience and could not get back in, animals lost their speech privilege because of their role in man’s fall and could not recover it. Instead, they ended up vocalizing themselves using various feral onomatopoeias.
If animals did not speak from the very beginning, God would not have opened the donkey’s mouth in the 2nd instance (not that He couldn’t otherwise), because God NEVER goes against the order He created in nature.
Every miracle is an instance of God super-activating the existing order. For instance, a supernatural healing is a normal, natural healing that is sped up, given that the body was created to naturally heal itself.
The natural order of things is one of the reasons Jesus did not turn stone into bread when the Devil asked him to.
“If you are the Son of God, tell these stones to become bread.” Matthew 4:3
It’s not that Jesus couldn’t do it, but within the created order rock cannot be made to turn into bread. The Devil wanted Jesus to circumvent God’s natural order of things, and Jesus refused – in addition to not wanting to take orders from Satan.
As further proof of maintaining said order, Jesus turned bread into more bread (super-activation) for the multitudes that came to hear Him.
Don’t you remember the five loaves for the five thousand, and how many basketfuls you gathered? Or the seven loaves for the four thousand, and how many basketfuls you gathered?” Matthew 16:9,10