Do you have sound when using headphones? If so and a factory reset didn't work and assuming you tried playing with the settings then you probably going to need to open the device and see if the speaker is connected properly. If it is then it probably failed and you need to replace it. Shouldn't cost much if you DIY
Hi nicolasphilippides I figured it out. you will need to reflow the baseband chip. take the logic board out and with a hot air rework station heat the baseband chip. i used 350 degrees celsius with air pressure on 5 with a hakko station and 4.4 mm nozzle, heat the chip in a circular fashion for 30 seconds. if that doesn't do the trick or if the problem reoccurs you will need to replace 3 chips as they are all paired: 1. Hynix H2JTDG2MBR (nand flash) 2. Qualcomm MDM9615 (baseband chip) 3. U601_RF (baseband memory) which is not that simple so basically not really worth it on an iPhone 5 IMO. thats all the information you need, good luck.