Let me say it like this: we cannot tell if it's God or not, because a human cannot discern it on our own. However, the Spirit teaches us how to do it. By praying, being still and listening to the Spirit, eventually we will learn how to recognize His voice. He has to reveal his presence to us first. He does this when we obey His commandments. John 14:21
We are told to test all the spirits. 1 John 14:3 The passage refers to false prophets, but since false prophets are created by Satan's lies, this passage can be applied to ourselves as well.
We cannot ask a question, and then listen for a voice. Our brains will just make something up. We have to wait for God. Sometimes it takes a while, and He teaches through Scripture mostly, and through experience and trials. And through mistakes.
It comes with practice. We get to know Him better through reading His word, prayer and most of all doing the commandments. Then it will just happen easily, and God will make it clear to you that it is Him. He is not a God of confusion.