Spaces:
Running
Running
Update Dockerfile
Browse files- Dockerfile +15 -3
Dockerfile
CHANGED
|
@@ -1,4 +1,3 @@
|
|
| 1 |
-
|
| 2 |
FROM python:3.10-slim
|
| 3 |
|
| 4 |
WORKDIR /app
|
|
@@ -9,7 +8,9 @@ RUN pip install --no-cache-dir deepfilternet gradio soundfile
|
|
| 9 |
|
| 10 |
RUN cat <<'EOF' > /app/app.py
|
| 11 |
import sys, types
|
|
|
|
| 12 |
import soundfile as sf
|
|
|
|
| 13 |
|
| 14 |
class AudioMetaData:
|
| 15 |
pass
|
|
@@ -31,7 +32,20 @@ def _ta_info(file, **kwargs):
|
|
| 31 |
encoding="PCM_S",
|
| 32 |
)
|
| 33 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
ta.info = _ta_info
|
|
|
|
|
|
|
| 35 |
|
| 36 |
import gradio as gr
|
| 37 |
from df.enhance import enhance, init_df, load_audio, save_audio
|
|
@@ -58,8 +72,6 @@ if __name__ == "__main__":
|
|
| 58 |
demo.launch(server_name="0.0.0.0", server_port=7860)
|
| 59 |
EOF
|
| 60 |
|
| 61 |
-
RUN python -c "import runpy; runpy.run_path('/app/app.py')" --help 2>/dev/null || python -c "import sys, types, soundfile as sf; sys.modules.setdefault('torchaudio.backend', types.ModuleType('torchaudio.backend')); m=types.ModuleType('torchaudio.backend.common'); m.AudioMetaData=object; sys.modules['torchaudio.backend.common']=m; import torchaudio as ta; ta.info=lambda f,**k: types.SimpleNamespace(sample_rate=sf.info(f).samplerate, num_frames=sf.info(f).frames, num_channels=sf.info(f).channels, bits_per_sample=16, encoding='PCM_S'); from df.enhance import init_df; init_df()"
|
| 62 |
-
|
| 63 |
EXPOSE 7860
|
| 64 |
|
| 65 |
CMD ["python", "/app/app.py"]
|
|
|
|
|
|
|
| 1 |
FROM python:3.10-slim
|
| 2 |
|
| 3 |
WORKDIR /app
|
|
|
|
| 8 |
|
| 9 |
RUN cat <<'EOF' > /app/app.py
|
| 10 |
import sys, types
|
| 11 |
+
import numpy as np
|
| 12 |
import soundfile as sf
|
| 13 |
+
import torch
|
| 14 |
|
| 15 |
class AudioMetaData:
|
| 16 |
pass
|
|
|
|
| 32 |
encoding="PCM_S",
|
| 33 |
)
|
| 34 |
|
| 35 |
+
def _ta_load(filepath, **kwargs):
|
| 36 |
+
data, sr = sf.read(filepath, dtype="float32", always_2d=True)
|
| 37 |
+
tensor = torch.from_numpy(data.T)
|
| 38 |
+
return tensor, sr
|
| 39 |
+
|
| 40 |
+
def _ta_save(filepath, src, sample_rate, **kwargs):
|
| 41 |
+
arr = src.detach().cpu().numpy()
|
| 42 |
+
if arr.ndim == 2:
|
| 43 |
+
arr = arr.T
|
| 44 |
+
sf.write(filepath, arr, sample_rate)
|
| 45 |
+
|
| 46 |
ta.info = _ta_info
|
| 47 |
+
ta.load = _ta_load
|
| 48 |
+
ta.save = _ta_save
|
| 49 |
|
| 50 |
import gradio as gr
|
| 51 |
from df.enhance import enhance, init_df, load_audio, save_audio
|
|
|
|
| 72 |
demo.launch(server_name="0.0.0.0", server_port=7860)
|
| 73 |
EOF
|
| 74 |
|
|
|
|
|
|
|
| 75 |
EXPOSE 7860
|
| 76 |
|
| 77 |
CMD ["python", "/app/app.py"]
|