Ab initio calculation of phonon dispersions in semiconductors