you could start by doing a hard reset to eliminate most software issues. If that doesn’t solve the issue, then it could be a modular component issue. You will need to test out the various speakers (ear speaker and loud speaker) and microphones (there are three) to see if the problem is specific to only certain modules or all of them.
There are 3 microphones in the iPhone.
‘The device is not ready’ error In Audio
We Can Fix Call Us