It’s informative to compare these two passages:
Then the Lord opened the mouth of the donkey, and she said to Balaam, “What have I done to you, that you have struck me these three times?” (Num 22:28).And it [the Beast] was allowed to give breath to the image of the beast, so that the image of the beast might even speak and might cause those who would not worship the image of the beast to be slain (Rev 13:15).
As one scholar notes:
The second striking feature of this paragraph is that Balaam is not surprised by the donkey’s unnatural ability to speak.11 Why is this so? I have suggested in a previous study that a characteristic of the Balaam traditions is that they employ omens by means of animal activity.12 It was also noted that donkeys are associated with divination throughout ancient Near Eastern literature.13 Therefore, instead of marveling at the donkey’s unusual behavior, it appears that Balaam immediately accepts it as an omen14 and proceeds to investigate by engaging the donkey in dialogue. However, he cannot determine the meaning of the omen—at least not by his own ability.
K. Way, “Animals in the Prophetic World: Literary Reflections on Numbers 22 and 1 Kings 13,” JSOT 34.1 (2009), 50
Compare this with David Aune’s comments on Rev 13:15. Among other things, he says:
This reflects the world of ancient magic in which the animation of images of the gods was an important means for securing oracles.Much earlier, Babylonians had rituals intended to give life to statues of the gods…In ancient Egypt, beginning at an even earlier period, statues of the gods were vitalized through a ceremony of “opening the mouth.”The magical rituals for animating images of the gods in Egypt probably influenced that special branch of magic called theurgy…Theurgists developed a special complex of rituals…which was primarily concerned with consecration and animation of statues in order to receive oracles from them.For the ancients, a statue that speaks is a statue that gives oracles.
Revelation 6-16 (T. Nelson 1998), 762-764.
The talking cult image is analogous to a talking, divinatory donkey. This suggests the Balaam account is a polemic against pagan divination generally, and equid divination in particular. God uses the donkey like a ventriloquist dummy to lampoon pagan divination.