I have a similar problem with my S6. I have to hold my hand at the bottom of the phone slightly cupping my hand to catch my voice. Otherwise people cannot hear me.
However the microphone works fine on speaker phone and Bluetooth. There are no problems for others to hear me.
It doesn't fix the problem, but it helps.
Update; forgot to add... When I called AT&T about my problem they suggest restart into safe mode to see if an app is causing the problem. Then to do a factory reset. Also if you r in your first year of having the phone you may get a replacement under warranty
The primary phone mic could be blocked by debris (like lint), so inspect it closely and consider using a fine-tipped needle or pin to gently clean t out. Also, if you have a case, make sure it isn't blocking the primary mic as well as the secondary noise-cancelling mic (which is near the top of the phone).
If the problem persists, then the primary phone mic may just be faulty.