Removing clicks in an audio file with torchaudio

username: rodiram
cooked: <p>Hello all, I have recorded an audio file for a podcast but for some reason there are lot’s of short clicks sounds probably originating from some electronic microphone noise. Attach is an example shown as a spectrogram. I would like to cut this noise and reconstruct the voice signal using torchaudio. Any hint about the method I should use or some python example ? Or some keyword I could use in Google ?<br>
Thanks !<br>
<div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/c/f/cf3cc96497cb8286437681077e9cde3e0be375f8.jpeg" data-download-href="https://discuss.pytorch.org/uploads/default/cf3cc96497cb8286437681077e9cde3e0be375f8" title="Screenshot 2025-03-15 at 17.10.31"><img src="https://discuss.pytorch.org/uploads/default/optimized/3X/c/f/cf3cc96497cb8286437681077e9cde3e0be375f8_2_578x500.jpeg" alt="Screenshot 2025-03-15 at 17.10.31" data-base62-sha1="tzj4pXcjWPfuRsW3RiBGBpNhKeQ" width="578" height="500" srcset="https://discuss.pytorch.org/uploads/default/optimized/3X/c/f/cf3cc96497cb8286437681077e9cde3e0be375f8_2_578x500.jpeg, https://discuss.pytorch.org/uploads/default/optimized/3X/c/f/cf3cc96497cb8286437681077e9cde3e0be375f8_2_867x750.jpeg 1.5x, https://discuss.pytorch.org/uploads/default/optimized/3X/c/f/cf3cc96497cb8286437681077e9cde3e0be375f8_2_1156x1000.jpeg 2x" data-dominant-color="693774"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">Screenshot 2025-03-15 at 17.10.31</span><span class="informations">1348×1166 146 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div></p>

username: KFrank
cooked: <p>Hi Rodiram!</p>
<aside class="quote no-group" data-username="rodiram" data-post="1" data-topic="217889">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://discuss.pytorch.org/letter_avatar_proxy/v4/letter/r/f08c70/48.png" class="avatar"> rodiram:</div>
<blockquote>
<p>I would like to cut this noise and reconstruct the voice signal using torchaudio.</p>
</blockquote>
</aside>
<p>I don’t know off-hand of any pre-packaged tool that would do this for you.  (But there<br>
might be one.)</p>
<p>Try searching for “audio denoising” or “audio restoration” together with things like<br>
pytorch and / or cnn.</p>
<p>I’ve never used torchaudio nor done any machine-learning audio processing.  It is,<br>
however, reasonable to imagine training a model to do this for your.</p>
<p>A similar use case exists for image processing where you want to denoise / restore<br>
images.  A sensible approach (there are others) is to start with some “clean” images<br>
to which you add noise.  The clean images become your ground-truth targets and<br>
the noisy images become the input to your model.  Train the model to recover your<br>
clean ground-truth images from your input images to which you’ve added synthetic<br>
noise.</p>
<p>You can now use that trained model to denoise images that have real noise in them.</p>
<p>If you have some clean audio – maybe some podcasts that don’t have the microphone<br>
noise – and some way to add semi-realistic “clicks” to it, you ought to be able to train<br>
an audio “de-clicker” using the same scheme.</p>
<p>Best.</p>
<p>K. Frank</p>