In this paper, we present a method based on machine learning that improves the resolution of non-invasive spectral diagnostics at the European XFEL by up to 40%, and significantly increases its signal-to-noise ratio. Furthermore, it streamlines and automates the calibration of the spectral diagnostic device, which is otherwise a complex and time-consuming task, by virtue of its underlying detection principles. Additionally, the provision of robust quality metrics and uncertainties enable a transparent and reliable validation of the tool during its operation. A complete characterization of the method under a diverse set of experimental and simulated conditions is provided in the manuscript, detailing advantages and limits, as well as its robustness with respect to the different test cases.