Welcome. That is a good try at providing the information but it's missing a schematic.
The speaker looks like the electromagnetic type, you can not drive those directly from an Arduino pin (especially an ESP which has a lower current spec).
I'm not saying it is the direct cause of your problem but it's good to eliminate low hanging fruit at the start...