We present a theoretical model that computes the chemical evolution, t
hermal balance, and line emission from the collapsing gas of the envel
opes that surround protostars. This is the first attempt to calculate
self-consistently the line spectrum from the infalling gas with a mode
l that includes dynamics, chemistry, heating and cooling, and radiativ
e transfer. For the dynamics, we have adopted the Shu ''inside-out'' s
pherical collapse of an isothermal cloud valid for r greater than or e
qual to r(c), where the centrifugal radius r(c) similar to 10(14) - 10
(15) cm. A time-dependent chemical code follows the chemical compositi
on of the envelope during the collapse. The main chemical result is th
at the inner regions (r less than or equal to 10(15) cm) have high H2O
abundances caused by the evaporation of H2O ice from grains when dust
temperatures exceed similar to 100 K and by gas-phase chemical reacti
ons when gas temperatures exceed similar to 200 K. The gas is heated m
ainly by absorption of (dust continuum) near-infrared (MR) photons by
H2O molecules in the inner regions, by compressional heating in an int
ermediate zone, and by collisions of gas with warm dust grains in the
outer regions (r greater than or equal to 10(17) cm). The gas is coole
d by H2O rotational lines in the inner regions, by the [O I] 63 mu m f
inestructure line and CO rotational lines in the intermediate region,
and by CO rotational lines in the outer zones. The gas temperature rou
ghly tracks the grain temperature for 10(14) cm less than or equal to
r less than or equal to 10(17) cm, ranging from about 300 K to 10 K. W
e present the computed spectrum of a 1 M. protostar accreting at a rat
e of 10(-5) M(Theta) yr(-1). The H2O lines and the [O I] 63 mu m line
will be easily detectable by the spectrometers on board the Infrared S
pace Observatory (ISO). The [O I] 63 mu m line and the mid J (J simila
r to 7 - 15) CO lines can be detected by the Kuiper Airborne Observato
ry (KAO) or the Stratospheric Observatory For Infrared Astronomy (SOFI
A), and certain low-J CO lines can be detected by ground-based telesco
pes. We present also a large number of other models in which we test t
he sensitivity of the spectrum to the variations in the three main par
ameters of our model: the inner radius of spherically symmetric infall
(e.g., the centrifugal radius), the amount of H2O ice evaporated into
the gas, and the mass accretion rate. We show how H2O lines, CO lines
, and the [O I] 63 mu m line can be used to estimate these three param
eters and how resolved line profiles will show the velocity signature
of the collapse. Comparison between an infalling and static envelope w
ith similar density, chemical, and dust temperature structure shows th
at line fluxes alone are not enough to unmistakably distinguish the tw
o cases. Observable H2O masers may be produced in the innermost collap
sing gas at r similar to 4 x 10(14) cm.