Spaces:
Sleeping
Sleeping
Download waveletDenoise.py from cdactvm/Punjabi_ASR_Demo: direct link, hf CLI and curl.
- Browser
- Download file 419 Bytes
-
https://huggingface.co/spaces/cdactvm/Punjabi_ASR_Demo/resolve/main/waveletDenoise.py
- Command line
-
hf download hf://spaces/cdactvm/Punjabi_ASR_Demo/waveletDenoise.py
-
curl -L -o waveletDenoise.py https://huggingface.co/spaces/cdactvm/Punjabi_ASR_Demo/resolve/main/waveletDenoise.py
419 Bytes
| # Function to apply wavelet denoising | |
| import pywt | |
| import numpy as np | |
| def wavelet_denoise(audio, wavelet='db1', level=1): | |
| coeffs = pywt.wavedec(audio, wavelet, mode='per') | |
| sigma = np.median(np.abs(coeffs[-level])) / 0.5 | |
| uthresh = sigma * np.sqrt(2 * np.log(len(audio))) | |
| coeffs[1:] = [pywt.threshold(i, value=uthresh, mode='soft') for i in coeffs[1:]] | |
| return pywt.waverec(coeffs, wavelet, mode='per') |