Context. The MOST, CoRoT, and Kepler space missions have led to the discovery of a large number of intriguing, and in some cases unique, objects among which are pulsating stars, stars hosting exoplanets, binaries, etc. Although the space missions have delivered photometric data of unprecedented quality, these data are lacking any spectral information and we are still in need of ground-based spectroscopic and/or multicolour photometric follow-up observations for a solid interpretation. Aims. The faintness of most of the observed stars and the required high signal-to-noise ratio (S/N) of spectroscopic data both imply the need to use large telescopes, access to which is limited. In this paper, we look for an alternative, and aim for the development of a technique that allows the denoising of the originally low S/N (typically, below 80) spectroscopic data, making observations of faint targets with small telescopes possible and effective. Methods. We present a generalization of the original least-squares deconvolution (LSD) method by implementing a multicomponent average profile and a line strengths correction algorithm. We tested the method on simulated and real spectra of single and binary stars, among which are two intrinsically variable objects. Results. The method was successfully tested on the high-resolution spectra of Vega and a Kepler star, KIC 04749989. Application to the two pulsating stars, 20 Cvn and HD 189631, showed that the technique is also applicable to intrinsically variable stars: the results of frequency analysis and mode identification from the LSD model spectra for both objects are in good agreement with the findings from literature. Depending on the S/N of the original data and spectral characteristics of a star, the gain in S/N in the LSD model spectrum typically ranges from 5 to 15 times. Conclusions. The technique introduced in this paper allows an effective denoising of the originally low S/N spectroscopic data. The high S/N spectra obtained this way can be used to determine fundamental parameters and chemical composition of the stars. The restored LSD model spectra contain all the information on line profile variations present in the original spectra of pulsating stars, for example. The method is applicable to both high-(>30 000) and low-(<30 000) resolution spectra, although the information that can be extracted from the latter is limited by the resolving power itself.