I know of no such machine, but there is a very simple way of doing this:
Buy a tuning device (not a tuning fork) from a reputable music shop: It is a circular device with each note of the scale marked. By sliding the outer ring round till it matches the tonic of the song you are hearing, it will immediately give the key. It uses a reed inside each of the keys.
This may sound a bit messy, but I find it difficult to explain although I have used one for a number of years. Hope this helps