Spaces:
Runtime error
Runtime error
Download audio_enhance/functions.py from olivergray/SimpleRVC: direct link, hf CLI and curl.
- Browser
- Download file 755 Bytes
-
https://huggingface.co/spaces/olivergray/SimpleRVC/resolve/main/audio_enhance/functions.py
- Command line
-
hf download hf://spaces/olivergray/SimpleRVC/audio_enhance/functions.py
-
curl -L -o functions.py https://huggingface.co/spaces/olivergray/SimpleRVC/resolve/main/audio_enhance/functions.py
755 Bytes
| import torchaudio | |
| import numpy as np | |
| import torchaudio.transforms as T | |
| from df import enhance, init_df | |
| df_sr = 48000 | |
| model, df_state, _ = init_df() | |
| def audio_enchance(input_audio): | |
| extension = input_audio.split('.')[-1] | |
| if extension not in ['wav', 'mpeg', 'ogg']: | |
| return "El formato del audio no es valido, usa wav, mpeg o ogg", None | |
| else: | |
| noisy_audio, sr = torchaudio.load(input_audio) | |
| print("np.shape(noisy_audio)", np.shape(noisy_audio)) | |
| if sr != df_sr: | |
| resampler = T.Resample(orig_freq=sr, new_freq=df_sr) | |
| noisy_audio = resampler(noisy_audio) | |
| output_audio = enhance(model, df_state, noisy_audio) | |
| return np.shape(noisy_audio), noisy_audio | |