The Spectral Characterization of a Class of Almost Periodic Functions