As born-again Christians, we have a witness of God in our spirits.
Cain and Abel weren't born-again Christians, so they didn't have God inside them. So it's evident God was talking to them.
Genesis 4:6 says, "The Lord said unto Cain."