My gf had this problem, everything indicated that it was a hardware problem - Voice recording wouldn’t work, would drop calls the moment the other person would pick it up etc..
Some time has passed while she used her AirPods for phone calls avoiding the immediate repair.
She could also no longer login using appleid, but everything else worked.
iOS 12.4.1 was released she updated, everything the same.
Another week has passed and then a major problem occurred - she could no longer use iMessage.
She couldn’t call nor could she write, so this was a deal breaker and she asked me for help.
I’ve made I backup on iTunes (just in case) then “Erased settings and contents”.
Restore from iTunes backup failed.
Setting it up as new iPhone worked for iMessage, but she needed info that was still on the Cloud.
So we restored to the latest iCloud backup. Situation was pretty much the same.
Appleid (icloud) login would work for a brief moment then break in case of iMessage.
I thought about restoring to an older backup, but just for the sake of it I decided to try “Reset network settings” before trying that older backup… and it WORKED!
Not only is she able to login to iCloud/iMessage by her appleid but the SPEAKER IS NO LONGER GREYED OUT.
What looked like an expensive hardware failure was actually, a bug in network settings that perhaps could be fixed in the recent iOS version by simple “Reset network settings”.