First check all your ports and speakers for any debris that needs cleaning out.
Then test your microphone via launching the phone dialer and key in *#0*#
There's also diagnostic tools in your Samsung Members App.
Put the phone in Safe Mode just to make sure no downloaded App is somehow affecting the phone.
Put the phone in Safe Mode which disables your downloaded app's but let's your stock app's keep working. If the issues stop then this highlights a downloaded app as the possible issue. Come out of Safe Mode and start deleting your most recent downloaded app's one at a time until it stops. https://www.samsung.com/uk/support/mobile-devices/how-to-start-my-galaxy-device-in-safe-mode/
If the phone hasn't had an accidental bump or water damage then you may need to let a Samsung Experience Store or Samsung Service Centre have hands on with it under the manufacturer warranty @everest
Current Phone >Samsung Z Fold³ 5G.
Previous Phone > Note 20 Ultra 5G SM-N9860.