The loudspeaker is powered by 2 pins on the motherboard. It is most likely you are getting a bad connection/contact between the speaker and those 2 pins. You may need to verify nothing is blocking the connection and that the pins are not smashed or broken on the motherboard. You should also verify the loudspeaker portion is seated all the way into the midframe so it makes good contact.
On the microphone you could have damaged it or simply purchased a bad part as it is part of the charge port assembly you replaced.