Audacity’s “Truncate Silence” effect is written in C++ (not Nyquist).
There’s a related plug-in that is written in Nyquist, called Trim Silence.
Also worth looking at the “Label Sounds” code: https://github.com/audacity/audacity/blob/master/plug-ins/label-sounds.ny