How do astronomers determine the mass of a star using spectra. In this answer here https://physics.stackexchange.com/a/503515, they state that the mass of a star is extracted from its spectrum and luminosity. What is the process of this?
The mass of a star cannot be directly determined from a spectrum, but an indirect inference using the luminosity would go something like this
The spectrum is dependent on the temperature and surface gravity of the star. Thus these parameters can be directly determined from a spectrum.
If you also have the luminosity, then this can be combined with the temperature to give the radius via the Stefan-Boltzmann law (NB By definition, the effective temperature of a star is the temperature of a blackbody at that luminosity).
Armed with a radius, then the spectroscopically determined surface gravity would give a mass.
This is unlikely to give very precise results. The spectroscopic gravities can be quite uncertain.
A second route is to use relationships between mass and luminosity, or mass and temperature, that have been calibrated using stars where mass can be directly determined - i.e. astrometric or eclipsing binary systems.