I have the original audio signal(MATLAB GENERATED) and the recorded audio signal (anechoic conditions). The setup consists of a DAC with a power amp plugged into the speaker. The audio is recorded via a condenser mic. I need to realize the transfer function of the speaker even though the properties of the rest of the setup are unknown.
Passive speaker or active speaker? If it's passive, then it's easy. If it's active, then you need to pull the transducer out and treat it as a passive speaker.
If you have a signal generator, use it as a source to generate white noise, otherwise use Matlab script.
If you are looking for impedance response, put your speaker in a voltage divider circuit (in series with a known resistor). The impedance of the speaker can be found by FFT the received signal (magnitude response and phase response are both useful). In this case you do need two devices / a tricky audio setup that generates and records at the same time.
If you are looking for surface pressure response, face your speaker at your mic (as close to each other as possible) and then play the same signal in an anechoic environment (no reverberation, ideally somewhere outdoors on a quiet sunny day) and do the same processing to received mic signal. Convert received voltages into pressure with your microphone's sensitivity data.
Impedance response tells you the physical property of the transducer and pressure response is what actually matters.
Use a pseudo random white noise sequence or other waveform that similarly occupies the entire spectrum of interest (as you will not be able to determine the transfer function at frequencies where no signal exists). Then use the approach outlined on this post here which uses the Wiener-Hopf equations to determine the least-mean-square estimate of the channel:
There are methods, sw and hw that are explicitly designed for this purpose. You would expect to get more robust results per second of measurement using those.
If what you have is a recording of the stimulus and the response, you could use an adaptive filter to identify the system response. If the stimulus contains deep nulls or you have lots of room noise, that is problematic.
What you get is a convolution of the dac, amplifier, loudspeaker, room, mic, mic amplifier and adc response. If you choose your setup wisely, the loudspeaker should be the dominant contributor to that chain.
It is possible to reduce the influence of electronics by doing a secondary «loopback» measurement, but it is hard to completely eliminate room and mic influence.