Download utils/preprocessing.py from root16285/cough_ai: direct link, hf CLI and curl.
- Browser
- Download file 258 Bytes
-
https://huggingface.co/spaces/root16285/cough_ai/resolve/main/utils/preprocessing.py
- Command line
-
hf download hf://spaces/root16285/cough_ai/utils/preprocessing.py
-
curl -L -o preprocessing.py https://huggingface.co/spaces/root16285/cough_ai/resolve/main/utils/preprocessing.py
258 Bytes
| import torchaudio | |
| def load_audio(file_path, target_sr=16000): | |
| waveform, sr = torchaudio.load(file_path) | |
| if sr != target_sr: | |
| waveform = torchaudio.transforms.Resample(orig_freq=sr, new_freq=target_sr)(waveform) | |
| return waveform, target_sr | |