From a thoughtful reading of the story of Balaam's ass (Num. 22:27-32), we recognize that the question posed is not "How can an ass speak?" but "How can we become like Balaam, able to hear what the world has to say to us?"
We are charged to be a nation of prophets and a holy people. The Jewish prophet is not a seer looking for omens in the entrails of birds. The Jewish prophet is a person, like us, who is on the extreme end of a spectrum that begins with those who are deaf to the meanings found in all of creation and extends to those who are capable of recognizing the divine spark in everything.
At the time of the Exodus, the different capacities to understand what was happening was demonstrated by the varied reactions to the plagues. It took three plagues before the magicians could say, "This is the finger of God." But Pharaoh's heart stiffened. By the time of the plague of hail even Pharaoh's courtiers could recognize God's word and, therefore, brought their livestock indoors to safety. But Pharaoh's heart stiffened.
Stiffening of the heart seems to be the principal cause of inability to hear God's word through world events. And to the contrary, seeing with the eyes of love makes us capable of recognizing God's presence in the world.
Was Balaam really able to see with the eyes of love? We know, from later discussion of him in the Torah, that at some point he ceases to be a prophet and becomes a sorcerer. But at the time of the incident of Balaam's ass, he is able to look on his enemies' camp and say, "How beautiful are your tents, O Jacob, your dwellings, O Israel!" (Num. 24:5) The capacity to hear his ass was the same as the capacity to see the majesty in the camp of Israel.