Molecular spectroscopy in a solid-state device