The oxygen residue in the glass medicine bottle poses a serious threat to the sterility of the medicine in the bottle. In this paper, the peak height of the second harmonic signal demodulated by wavelength modulated spectrum (WMS) technology is used as the basis of oxygen concentration inversion. However, when measuring gas concentration with second harmonic signal, the change of modulation depth will lead to the change of second harmonic peak, which will usually bring errors to the system and reduce the inversion accuracy of concentration. However, the modulation depth is affected by the fluctuation of modulation current, temperature and pressure, and cannot be calculated directly. To solve this problem, we first successfully convert the relationship between modulation depth and secondary harmonic peak height into the relationship between secondary harmonic peak width and peak height. Then, the gas concentration is inversed by using the harmonic peak height after being corrected by peak width. Preliminary experiments show that when using the harmonic peak height after peak width correction to predict the gas concentration in the bottle, not only the accuracy of the system is improved by 2.1%, but also the overall robustness of the system is improved.