Electron-phonon and exciton-phonon bound states