  [Abridged] Our aim is to explore the gas dynamics and the accretion process
in the early phase of high-mass star formation. The inward motion of molecular
gas in the massive star forming region G34.26+0.15 is investigated by using
high-resolution profiles of seven transitions of ammonia at THz frequencies
observed with Herschel-HIFI. The shapes and intensities of these lines are
interpreted in terms of radiative transfer models of a spherical, collapsing
molecular envelope. An accelerated Lambda Iteration (ALI) method is used to
compute the models. The seven ammonia lines show mixed absorption and emission
with inverse P-Cygni-type profiles that suggest infall onto the central source.
A trend toward absorption at increasingly higher velocities for higher
excitation transitions is clearly seen in the line profiles. The $J =
3\leftarrow2$ lines show only very weak emission, so these absorption profiles
can be used directly to analyze the inward motion of the gas. This is the first
time a multitransitional study of spectrally resolved rotational ammonia lines
has been used for this purpose. Broad emission is, in addition, mixed with the
absorption in the $1_0-0_0$ ortho-NH$_3$ line, possibly tracing a molecular
outflow from the star forming region. The best-fitting ALI model reproduces the
continuum fluxes and line profiles, but slightly underpredicts the emission and
absorption depth in the ground-state ortho line $1_0-0_0$. The derived
ortho-to-para ratio is approximately 0.5 throughout the infalling cloud core
similar to recent findings for translucent clouds in sight lines toward W31C
and W49N. We find evidence of two gas components moving inwards toward the
central region with constant velocities: 2.7 and 5.3 km$\,$s$^{-1}$, relative
to the source systemic velocity. The inferred mass accretion rates derived are
sufficient to overcome the expected radiation pressure from G34.26+0.15.
