Spectrum of single-photon emission and scattering in cavity optomechanics