String excitation energies in SU(N) gauge theories beyond the free-string approximation