Pruebas
Browse files- audio_pipeline.py +14 -8
audio_pipeline.py
CHANGED
|
@@ -1,11 +1,18 @@
|
|
| 1 |
import os
|
| 2 |
import httpx
|
| 3 |
-
#
|
| 4 |
-
|
| 5 |
-
def
|
| 6 |
kwargs.setdefault('follow_redirects', True)
|
| 7 |
-
return
|
| 8 |
-
httpx.Client.__init__ =
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
|
| 10 |
import librosa
|
| 11 |
import numpy as np
|
|
@@ -13,8 +20,7 @@ import soundfile as sf
|
|
| 13 |
import noisereduce as nr
|
| 14 |
from spleeter.separator import Separator
|
| 15 |
|
| 16 |
-
# Directorio base donde guardaremos todos los stems
|
| 17 |
-
BASE_STEMS_DIR = "data/stems"
|
| 18 |
|
| 19 |
def separar_audio_spleeter(input_file, model="spleeter:4stems"):
|
| 20 |
"""
|
|
@@ -26,7 +32,7 @@ def separar_audio_spleeter(input_file, model="spleeter:4stems"):
|
|
| 26 |
out_root = os.path.join(BASE_STEMS_DIR, model_name)
|
| 27 |
os.makedirs(out_root, exist_ok=True)
|
| 28 |
|
| 29 |
-
# Con
|
| 30 |
sep = Separator(model)
|
| 31 |
sep.separate_to_file(input_file, out_root)
|
| 32 |
|
|
|
|
| 1 |
import os
|
| 2 |
import httpx
|
| 3 |
+
# Monkey-patch httpx to follow redirects globally
|
| 4 |
+
orig_client_init = httpx.Client.__init__
|
| 5 |
+
def patched_client_init(self, *args, **kwargs):
|
| 6 |
kwargs.setdefault('follow_redirects', True)
|
| 7 |
+
return orig_client_init(self, *args, **kwargs)
|
| 8 |
+
httpx.Client.__init__ = patched_client_init
|
| 9 |
+
|
| 10 |
+
orig_httpx_get = httpx.get
|
| 11 |
+
|
| 12 |
+
def patched_httpx_get(url, *args, **kwargs):
|
| 13 |
+
kwargs.setdefault('follow_redirects', True)
|
| 14 |
+
return orig_httpx_get(url, *args, **kwargs)
|
| 15 |
+
httpx.get = patched_httpx_get
|
| 16 |
|
| 17 |
import librosa
|
| 18 |
import numpy as np
|
|
|
|
| 20 |
import noisereduce as nr
|
| 21 |
from spleeter.separator import Separator
|
| 22 |
|
| 23 |
+
# Directorio base donde guardaremos todos los stems\BASE_STEMS_DIR = "data/stems"
|
|
|
|
| 24 |
|
| 25 |
def separar_audio_spleeter(input_file, model="spleeter:4stems"):
|
| 26 |
"""
|
|
|
|
| 32 |
out_root = os.path.join(BASE_STEMS_DIR, model_name)
|
| 33 |
os.makedirs(out_root, exist_ok=True)
|
| 34 |
|
| 35 |
+
# Con httpx parcheado, Separator podrá descargar modelo sin errores 302
|
| 36 |
sep = Separator(model)
|
| 37 |
sep.separate_to_file(input_file, out_root)
|
| 38 |
|