Spectrum tone listener

Hello! I am visually impaired, but still have found a way to use audacity’s spectral view to equalize. I assigned keyboard shortcuts to select high and low frequency peaks. To hear the resonance, I have to open the spectral edit parametric equalizer effect, increase the gain, and hit the preview button. Then I decrease the gain and apply it. As this process is a bit tedious for me, I edited this plug-in so that it plays a sine wave, according to the selected center frequency in the spectrum. I will also assign a keyboard shortcut to this plug-in to be more efficient. The problem is that when you run it, the track’s audio is replaced by unwanted sound, which is not the goal. I edited the plugin quickly, and did not remove some unnecessary lines, and some parts of the code I do not understand. Thanks for the help.
Frequency-Listener.ny (2.5 KB)

To use “Preview” the plug-in must be either a Generate or Process type plug-in, and there must be at least one control so that a GUI is displayed. If there is no GUI then the plug-in is automatically applied to the selection with no option to preview.

I’m not certain what you are trying to do. Do you want to be able to press a key and have a sine tone play at the centre frequency of the “spectral” frequency selection? Do you want to hear a mix of the tone with the selected audio, or just the tone?