Troubleshooting ready board with LM339 IC?
Output stage might have insufficient current to drive low voltages, because of low resistance of speaker.
For testing add a serial resistor 470 ohm ... 1k in series with speaker.
Output stage drive capability is varying from chip to chip, depending on output transistor beta. (assume 6mA as minimum)