Audacity does not do real-time audio processing, but before you spend a load of time finding a way to do it I was wanting to point out that it would probably not achieve the desired noise cancelling effect.
Most pro-quality mixing desks include a “phase reversal” button on each channel. What this button does is to invert the signal (turn it upside down so that when the input goes +ve the output goes -ve and when the input goes -ve the output goes +ve). This is what you want to do?
The way that mixing desks achieve this is with hardware as that is the best method. It is simple, accurate, and has the lowest possible distortion or time lag effects.
You can easily make a hardware switch to achieve this (which does not require you to cut your speaker cable):
Assuming that your speaker connector is a stereo mini-jack connector, buy the following items:
one mini-jack plug
one mini-jack socket
two double pole single throw switches
one box to put the bits in
There are three connectors on stereo jack plug - one is connected to the tip, one to the ring just behind the tip, and the third goes to the sleeve. The tip connection is for one channel (right) and the ring for the other channel (left). The sleeve is the common (earth) connection for each channel.
Connect a red wire from the “tip” connection of the mini-jack socket, a white wire to the ring, and 2 black wires to the sleeve.
Repeat this for the mini-jack plug.
You then need to connect the wires to the switches such that when switched one direction each colour on the mini-jack connects to the corresponding colour of the socket, but when switched the other way the red wire from the plug goes to the black wire of the socket, and the black from the plug goes to the red of the socket, and the white/black pair swap over in the same manner. Here’s a diagram for the wiring up the switches:
Why you won’t get noise cancelling:
The wavelength of sound is in the range of about 2 cm to 15 metres (in air at sea level). A frequency of 344 Hz has a wavelength of 1 metre, but a frequency of 440 Hz has a wavelength of about 78 cm, and a frequency of 1 kHz has a wavelength of 34.4 cm.
If you are half a wavelength away from a speaker, by the time the sound reaches you it will be inverted. If you then move away from the speaker to twice that distance, the waveform will be “right way up” again.
Putting some actual figures in: At a distance of 500 cm, a frequency of 344 Hz will be inverted, but a frequency of 688 Hz will not be inverted as it is one full wavelength away.
Now compound the situation with reflections from the room and everything in the room and you will appreciate that phase of the sound that you hear is a complex mixture of inverted, non-inverted, and everything in between.
You can achieve some degree of noise cancellation using headphones, since the headphone speaker is very close to your ear, hence frequencies below about 1 kHz are essentially “in-phase”. Your microphones need to be also located in the same position as the speakers (just a few millimetres from your ear). The problem with this is that the microphones will then pick up the sound from the headphones, but what you want is the sound outside of the headphones, which is why noise cancelling headphones need to be cleverly designed and constructed.