I've had this happen to 2 4a's. The first one was replaced by Google and it just happened again. I found a thread that temporarily fixed it. I keep my phone in my back pocket, and even though there's no sign of damage, the circuit board is damaged from me sitting on it.
This is how I fixed it. Power down (restart) and as it goes through the restart cycle, flex the phone ( I bent it opposite of the way it bends in my back pocket) as it restarts. The first time I got the speaker to work. I did it again and all audio up and running. The circuit board must be cracked.
I'll keep doing this until I get a new phone and learn not to sit on it.
Hope this helps.