A generalization of the well-known Cauchy-Schwarz inequality with four free parameters is given for both discrete and continuous cases. Some particular cases of interest are also analyzed.