Umar (ra) narrates: “One day, I was present near the idols. An idol-worshipper slaughtered a calf, by way of making an offering for the idols. In the meanwhile, all of a sudden, a voice came out of the belly of a big idol, in these words:
“O strange man! a useful thing is this that an eloquent person says: There is no god but Allah.”
Umar (ra) stated that the people ran away getting frightened of this call; but I stayed in order to know the reality of this voice. Second time, also, the voice was heard. Thus, after some period, it was heard about Muhammad (sallallahu alayhe wasallam) that he is a Prophet and teaches that there is no god but Allah.
Source: Sahih Bukhari.
The voice came from a Jinn inside the belly of the idol.