The donkey that spoke in the Bible belonged to a man named Balaam. Balaam was a non-Israelite prophet who was hired by the king of Moab, Balak, to curse the Israelites who were passing through Moab on their way to the Promised Land.
On his way to meet with Balak, Balaam's donkey suddenly stopped in the middle of the road and would not move. Balaam became angry and began beating the donkey, but then the donkey spoke and asked him why he was beating her. Balaam was so shocked that he began to speak to the donkey, and then the Lord opened his eyes and he saw an angel of the Lord standing in the road with a sword. The angel told Balaam that the donkey had saved his life by stopping him from going down a dangerous path, and Balaam's eyes were opened to the fact that he had been wrong to try to curse the Israelites.
This story can be found in the book of Numbers, chapter 22, verses 21-35 in the Bible.