A search for a standard model Higgs boson produced in association with a top-quark pair and decaying to bottom quarks is presented. Events with hadronic jets and one or two oppositely charged leptons are selected from a data sample corresponding to an integrated luminosity of 19.5 fb(-1) collected by the CMS experiment at the LHC in pp collisions at a centre-of-mass energy of 8 TeV. In order to separate the signal from the larger t (t) over bar + jets background, this analysis uses a matrix element method that assigns a probability density value to each reconstructed event under signal or background hypotheses. The ratio between the two values is used in a maximum likelihood fit to extract the signal yield. The results are presented in terms of the measured signal strength modifier, mu, relative to the standard model prediction for a Higgs boson mass of 125 GeV. The observed (expected) exclusion limit at a 95% confidence level is mu < 4.2 (3.3), corresponding to a best fit value <(mu)over cap> = 1.2(-1.5)(+1.6).