• By applying Wannier-based extended Kugel-Khomskii model, we carry out first-principles calculations and electronic structure analysis to understand the spin-phonon coupling effect in transition-metal perovskites. We demonstrate the successful application of our approach to SrMnO$_3$ and BiFeO$_3$. We show that both the electron orbitals under crystal field splitting and the electronic configuration should be taken into account in order to understand the large variances of spin-phonon coupling effects among various phonon modes as well as in different materials.