Text this: Pulse pileup correction method for gamma-ray spectroscopy in high radiation fields