Headphones or a speaker for falling asleep
Both work. One of them is a lot easier to live with at three in the morning.
Headphones give you detail and a sense of closeness that a speaker cannot match, which is why most people start there. The problem arrives when you roll over, or when the cable finds your neck.
A small speaker at low volume, placed away from the bed, loses the intimacy but gains everything else: nothing to take out, nothing to charge, nothing to wake you at three when the battery dies with a beep.
If you stay with headphones, look for flat, soft ones made for sleeping rather than good-sounding ones made for music. Comfort beats fidelity once your eyes are closed.