Hey there and welcome to the Samsung UK and EU Community Customer to Customer Forum
Sorry to hear of your issues.
Please start by running a diagnostics test. Go to Samsung Members App and run diagnostics from there to see if the microphone is showing a fault.
(If it is working for calls, I suspect it won't show an issue but one option at a time
👍)
S24 Ultra