Switch microphone to speakerphone mic My primary mic seems to be broken. Google Now voice search records no audio and while in call the other side can not hear me talk. Booting to safe mode does not help either. 

However when I switch to speakerphone, all is working well. As far as I've read the Nexus 5 uses another mic in speaker phone mode (noise cancellation).

Is it somehow possible to always use the speakerphone mic? Since it is the only one working for me.
I found two apps 
one free - Auto speaker here
Try the free one first

second Tasker - Paid here

It has lots of automating features beside your need.
Before paying for App Read the tutorial first.
To use tasker use this tutorial link

Both apps uses sensors. Try on you device.