The role of galaxies and AGN in reionizing the IGM - I. Keck spectroscopy of 5 < z < 7 galaxies in the QSO field J1148+5251