Theory of the Photovoltaic Effect in Semiconductors