Oops I misread your question and thought you have a microphone recording of the speaker output with given audio, and answered that. Well here is anyway, as some parts still apply:
Like others have suggested in comments, designing a filter is the way to go. I would recommend a windowed FIR filter design rather than Parks-McClellan. From MATLAB documentation:
firpm exhibits discontinuities at the head and tail of its impulse
response due to this equiripple nature.
Our ears analyze sound with kind of wavelets so they may detect those discontinuities before and after impulsive sounds. With windowed filter design however you can choose a window that smoothly starts from and ends at value 0, avoiding creating such discontinuities.
Doing division (inverse of the amplitude) is a bit dangerous, because if you divide something by a number close to zero you get a huge value. Discrete Fourier transform results often contain values close to zero. If you have a long audio file then you can split the audio into shorter pieces with say 50 % overlap, multiply each with a window function, and calculate the mean squared magnitude of their discrete Fourier transforms (discarding phase). The square root of this is the root mean square spectral power, which is unlikely to be zero anywhere. Do this for both the speaker and raw audio and bin-wise divide the root-mean-square spectral power of the latter by the first. Still, you may get very large values if the speaker is unable to reproduce very low or very high frequencies. You can set a (soft) limit to how much correction you do at most, and you can even softly ramp the correction to nothing at frequencies you know the speaker simply cannot reproduce. Assuming zero phase for all bins, you can directly inverse discrete Fourier transform the division result to get an unwindowed zero-phase impulse response. You would then multiply the unwindowed impulse response with a window function which can be much shorter than the transform result, giving you a practical, short filter impulse response.
One more trick is to convert the filter to its minimum-phase counterpart, which will completely eliminate pre-ringing (taking place before the main peak in the impulse response). There are specialized methods for doing this that preserve the magnitude frequency response. I would not worry about post-ringing because real-world acoustics will give you plenty of post-ringing and echos anyhow and we are used to masking them.