A new and efficient scheme for first-principles calculations of phonon spectra