The conversion of energy of electrons produced by a radioactive β-source into electricity in a Si and SiC n p junctions is modeled. The features of the generation function that describes the electron-hole pair production by an electron flux and the emergence of a "dead layer" are discussed. The collection efficiency Q that describes the rate of electron-hole pair production by incident beta particles, is calculated taking into account the presence of the dead layer. It is shown that in the case of high-grade Si n p junctions, the collection efficiency of electron-hole pairs created by a high-energy electrons flux (such as, e.g., Pm-147 beta flux) is close or equal to unity in a wide range of electron energies. For SiC p -n junctions, Q is near unity only for electrons with relatively low energies of about 5 keV (produced, e.g., by a tritium source) and decreases rapidly with further increase of electron energy. The conditions, under which the influence of the dead layer on the collection efficiency is negligible, are determined. The open-circuit voltage is calculated for realistic values of the minority carriers' diffusion coefficients and lifetimes in Si and SiC n p junctions, irradiated by a high-energy electrons flux. Our calculations allow to estimate the attainable efficiency of betavoltaic elements.