The modeling of the surface pressure spectrum beneath a turbulent boundary layer is investigated, focusing on the case of airfoil flows and associated trailing edge noise prediction using the so-called TNO model. This type of flow is characterized by the presence of an adverse pressure gradient along the airfoil chord. It is shown that discrepancies between measurements and results from the TNO model increase as the pressure gradient increases. The original model is modified by introducing anisotropy in the definition of the turbulent vertical velocity spectrum across the boundary layer and by considering a frequency-dependent vertical correlation length. The degree of anisotropy is directly related to the strength of the pressure gradient. It is shown that by appropriately normalizing the pressure gradient and by tuning the degree of anisotropy, experimental results can be closely reproduced by the modified model. The model is validated against Large Eddy Simulation results and additional wind tunnel measurements. It is further validated in the context of trailing edge noise for which the model formulation makes use of the above surface pressure spectrum.