Primordial spectrum of gauge fields from inflation