Could be steam damage if you take it into the kitchen or bathroom. Or it could of slightly knocked off its pins. My iPhones been doing it a few times..
Have you checked the headphone socket? Sometimes debris can become stuck in there and trip the speaker switch. Try shining a bright light into the socket and if you see something, try vacuuming it out with a small nozzle.
I completely switched off my ipad by pressing both power button and home button together kept that way over night restarted the same way in the morning yah sound came back and I
t is still there