  We present a new approach to constrain galaxy physical parameters from the
combined interpretation of stellar and nebular emission in wide ranges of
observations. This approach relies on the Bayesian analysis of any type of
galaxy spectral energy distribution using a comprehensive library of synthetic
spectra assembled using state-of-the-art models of star formation and chemical
enrichment histories, stellar population synthesis, nebular emission and
attenuation by dust. We focus on the constraints set by 5-band photometry and
low- and medium-resolution spectroscopy at optical rest wavelengths on a set of
physical parameters characterizing the stars and the interstellar medium. Since
these parameters cannot be known a priori for any galaxy sample, we assess the
accuracy to which they can be retrieved by simulating `pseudo-observations'
using models with known parameters. Assuming that these models are good
approximations of true galaxies, we find that the combined analysis of stellar
and nebular emission in low-resolution galaxy spectra provides valuable
constraints on all physical parameters. At higher resolution, the analysis of
the combined stellar and nebular emission in 12,660 SDSS star-forming galaxies
using our approach yields likelihood distributions of stellar mass, gas-phase
oxygen abundance, optical depth of the dust and specific star formation rate
similar to those obtained in previous separate analyses of the stellar and
nebular emission at the original (twice higher) SDSS spectral resolution. We
show that the constraints derived on galaxy physical parameters from these
different types of observations depend sensitively on signal-to-noise ratio.
Our approach can be extended to the analysis of any type of observation across
the wavelength range covered by spectral evolution models. [abridged]
