This is most likely because of liquid damage to the internal components. I haven't dealt with liquid damage before, so i recommend going to your local repair shop and ask them exactly whats wrong.
Has the speaker recently come in contact with any sort of dust/water (steam too)? Is the volume turned up? Do you have headphones connected? If the volume is up and there is no headphones connected, then it seems like you have a faulty speaker. I could be wrong though, have you tried resetting your phone?