Your brain can remember the nuances of your friend's voice well enough to recreate an approximation of it from memory. Your brain is very good with patterns, so it an fill in the blanks even if you've never heard him say those exact words in that order. It's a lot like thinking of an object even though you aren't actively looking at an example of that object.
If it is someone you know very well then subconsciously you know very well how they would say every syllable and express every feeling, so your subconscious makes what it knows and how they should say anything.
If (on the other extreme) you barely know the person, your subconscious takes both what it know and how it sounds, and extrapolates both to what you have experienced to most closly relate to everyone else it's knows well enough and takes the most probable and makes it real in your mind