This is how the Google Pixel 2’s Now Playing Feature Works
The offline song recognition database contains a list of songs in the 10s of thousands. The Now Playing feature is only activated when it hears music. If the Pixel 2 detects music being played (using a combination of software, hardware, and machine learning), it will then look up the audio fingerprint in the database residing on the phone then show you the song name or artist. This database is updated with music each week and is based on the most popular songs from the Google Play Music catalogue. It is also localized according to market, thus, the database is not personalized to the user’s Google Play Music account.