Strong anharmonicity in the phonon spectra of PbTe and SnTe from first principles