I had some experience with figuring out riffs and other guitar parts by ear and I'd done a bunch of ear training exercises. But I was nowhere near as fast or accurate. The way he instantly knew how to instruct his fingers to play the notes he’d just heard for the first time in his life... It seemed amazing.
But like any magic trick, once you understand what’s going on, it isn’t as special as it once seemed. Playing by ear and learning songs by ear isn't some innate, natural talent that you either have or don’t have. It’s a skill that you can learn with the right kind of practice.
https://www.stringkick.com/blog-lessons/learn-songs-riffs-melodies-by-ear/