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.
Maybe like [this?](https://www.sciencealert.com/adobe-s-new-photoshop-for-voice-app-lets-you-put-words-in-people-s-mouths)
"While audio-editing apps have long enabled people to manually cut, copy, and splice together parts of sound waves, VoCo (voice conversion) operates on a new principle, using an algorithm that breaks down and recompiles human speech.
Adobe hasn't explained how this technology works just yet, but the software seems to identify and log phonemes – the individual speech sounds we put together to make up words and sentences.
With the right amount of sound data on file – which Adobe says is about 20 minutes of one person talking – VoCo will have actually recorded enough of these phonemes to basically impersonate that person, by stitching them together into new word and sentence formations."
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
I like this one!
Instead of thinking of our memories as a video recorders we should think of them as the product of a note-taker. The brain is a very efficient note taker and more than that is capable of abstraction: taking many notes and combining them in original ways. This means not only can you hear the tone of their voice saying any line you could imagine you could picture them wearing things they've never worn or in places they've never been.