@@ -18,3 +18,7 @@ envs/
|
|||||||
|
|
||||||
# site-packages.pth
|
# site-packages.pth
|
||||||
site-packages.pth
|
site-packages.pth
|
||||||
|
|
||||||
|
# Ignore egg-info directory
|
||||||
|
src/freqsplit.egg-info/
|
||||||
|
|
||||||
|
|||||||
+29
-26
@@ -1,31 +1,34 @@
|
|||||||
from django.shortcuts import render
|
|
||||||
from django.http import JsonResponse
|
|
||||||
from .tasks import process_uploaded_file
|
|
||||||
from .forms import UploadFileForm
|
|
||||||
import os
|
import os
|
||||||
|
from rest_framework.decorators import api_view
|
||||||
|
from rest_framework.response import Response
|
||||||
|
from rest_framework import status
|
||||||
|
from freqsplit.preprocessing.classify import classify_audio
|
||||||
|
|
||||||
# Create your views here.
|
UPLOAD_DIR = "/tmp/freq-split-enhance"
|
||||||
def handle_uploaded_file(f, file_path):
|
|
||||||
with open(file_path, 'wb+') as destination:
|
# Ensure the temp directory exists
|
||||||
for chunk in f.chunks():
|
os.makedirs(UPLOAD_DIR, exist_ok=True)
|
||||||
|
|
||||||
|
@api_view(['POST'])
|
||||||
|
def upload_audio(request):
|
||||||
|
"""Handles audio file upload and saves it to /tmp/freq-split-enhance"""
|
||||||
|
if 'file' not in request.FILES:
|
||||||
|
return Response({"Error: No file provided"}, status=status.HTTP_400_BAD_REQUEST)
|
||||||
|
|
||||||
|
audio_file = request.FILES['file']
|
||||||
|
file_path = os.path.join(UPLOAD_DIR, audio_file.name)
|
||||||
|
|
||||||
|
# Save the uploaded file
|
||||||
|
with open(file_path, 'wb') as destination:
|
||||||
|
for chunk in audio_file.chunks():
|
||||||
destination.write(chunk)
|
destination.write(chunk)
|
||||||
|
|
||||||
def upload(request):
|
audio_class = classify_audio(file_path)
|
||||||
if request.method == 'POST':
|
|
||||||
form = UploadFileForm(request.POST, request.FILES)
|
|
||||||
if form.is_valid():
|
|
||||||
file = form.cleaned_data['file']
|
|
||||||
file_path = os.path.join('uploads', file.name) # Change 'uploads' to your desired directory
|
|
||||||
handle_uploaded_file(file, file_path)
|
|
||||||
task = process_uploaded_file.delay(file_path)
|
|
||||||
return JsonResponse({'task_id': task.id})
|
|
||||||
|
|
||||||
else:
|
return Response(
|
||||||
form = UploadFileForm()
|
{
|
||||||
return render(request, 'upload.html', {'form': form})
|
"Status": "File uploaded successfully",
|
||||||
|
"file_path": file_path,
|
||||||
from celery.result import AsyncResult
|
"audio_class": audio_class
|
||||||
|
}, status=status.HTTP_201_CREATED,
|
||||||
def check_task_status(request, task_id):
|
)
|
||||||
task_result = AsyncResult(task_id)
|
|
||||||
return JsonResponse({'status': task_result.status, 'result': task_result.result})
|
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ INSTALLED_APPS = [
|
|||||||
'django.contrib.sessions',
|
'django.contrib.sessions',
|
||||||
'django.contrib.messages',
|
'django.contrib.messages',
|
||||||
'django.contrib.staticfiles',
|
'django.contrib.staticfiles',
|
||||||
|
'rest_framework',
|
||||||
'api'
|
'api'
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -16,9 +16,9 @@ Including another URLconf
|
|||||||
"""
|
"""
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
from django.urls import path
|
from django.urls import path
|
||||||
from api.views import upload
|
from api.views import upload_audio
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path('admin/', admin.site.urls),
|
path('admin/', admin.site.urls),
|
||||||
path('upload/',upload)
|
path('api/upload', upload_audio, name='upload_audio')
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -0,0 +1,148 @@
|
|||||||
|
absl-py==2.1.0
|
||||||
|
aiohappyeyeballs==2.4.4
|
||||||
|
aiohttp==3.11.11
|
||||||
|
aiosignal==1.3.2
|
||||||
|
amqp==5.3.1
|
||||||
|
antlr4-python3-runtime==4.9.3
|
||||||
|
appdirs==1.4.4
|
||||||
|
asgiref==3.8.1
|
||||||
|
asteroid==0.7.0
|
||||||
|
asteroid-filterbanks==0.4.0
|
||||||
|
astunparse==1.6.3
|
||||||
|
attrs==25.1.0
|
||||||
|
audioread==3.0.1
|
||||||
|
billiard==4.2.1
|
||||||
|
cached-property==2.0.1
|
||||||
|
celery==5.4.0
|
||||||
|
certifi==2024.12.14
|
||||||
|
cffi==1.17.1
|
||||||
|
charset-normalizer==3.4.1
|
||||||
|
click==8.1.8
|
||||||
|
click-didyoumean==0.3.1
|
||||||
|
click-plugins==1.1.1
|
||||||
|
click-repl==0.3.0
|
||||||
|
cloudpickle==3.1.1
|
||||||
|
contourpy==1.3.1
|
||||||
|
cycler==0.12.1
|
||||||
|
decorator==5.1.1
|
||||||
|
DeepFilterLib==0.5.6
|
||||||
|
DeepFilterNet==0.5.6
|
||||||
|
demucs==4.0.1
|
||||||
|
Django==5.1.6
|
||||||
|
djangorestframework==3.15.2
|
||||||
|
dora_search==0.1.12
|
||||||
|
einops==0.8.0
|
||||||
|
filelock==3.17.0
|
||||||
|
flatbuffers==25.2.10
|
||||||
|
fonttools==4.55.6
|
||||||
|
frozenlist==1.5.0
|
||||||
|
fsspec==2024.12.0
|
||||||
|
future==1.0.0
|
||||||
|
gast==0.6.0
|
||||||
|
google-pasta==0.2.0
|
||||||
|
grpcio==1.70.0
|
||||||
|
h5py==3.13.0
|
||||||
|
huggingface-hub==0.28.0
|
||||||
|
idna==3.10
|
||||||
|
iniconfig==2.0.0
|
||||||
|
Jinja2==3.1.5
|
||||||
|
joblib==1.4.2
|
||||||
|
julius==0.2.7
|
||||||
|
keras==3.8.0
|
||||||
|
kiwisolver==1.4.8
|
||||||
|
kombu==5.4.2
|
||||||
|
lameenc==1.8.1
|
||||||
|
lazy_loader==0.4
|
||||||
|
libclang==18.1.1
|
||||||
|
librosa==0.10.2.post1
|
||||||
|
lightning-utilities==0.11.9
|
||||||
|
llvmlite==0.44.0
|
||||||
|
loguru==0.7.3
|
||||||
|
Markdown==3.7
|
||||||
|
markdown-it-py==3.0.0
|
||||||
|
MarkupSafe==3.0.2
|
||||||
|
matplotlib==3.10.0
|
||||||
|
mdurl==0.1.2
|
||||||
|
mir_eval==0.7
|
||||||
|
ml-dtypes==0.4.1
|
||||||
|
mpmath==1.3.0
|
||||||
|
msgpack==1.1.0
|
||||||
|
multidict==6.1.0
|
||||||
|
namex==0.0.8
|
||||||
|
networkx==3.4.2
|
||||||
|
numba==0.61.0
|
||||||
|
numpy==1.26.4
|
||||||
|
nvidia-cublas-cu12==12.4.5.8
|
||||||
|
nvidia-cuda-cupti-cu12==12.4.127
|
||||||
|
nvidia-cuda-nvrtc-cu12==12.4.127
|
||||||
|
nvidia-cuda-runtime-cu12==12.4.127
|
||||||
|
nvidia-cudnn-cu12==9.1.0.70
|
||||||
|
nvidia-cufft-cu12==11.2.1.3
|
||||||
|
nvidia-curand-cu12==10.3.5.147
|
||||||
|
nvidia-cusolver-cu12==11.6.1.9
|
||||||
|
nvidia-cusparse-cu12==12.3.1.170
|
||||||
|
nvidia-nccl-cu12==2.21.5
|
||||||
|
nvidia-nvjitlink-cu12==12.4.127
|
||||||
|
nvidia-nvtx-cu12==12.4.127
|
||||||
|
omegaconf==2.3.0
|
||||||
|
openunmix==1.3.0
|
||||||
|
opt_einsum==3.4.0
|
||||||
|
optree==0.14.0
|
||||||
|
packaging==23.2
|
||||||
|
pandas==2.2.3
|
||||||
|
pb-bss-eval==0.0.2
|
||||||
|
pesq==0.0.4
|
||||||
|
pillow==11.1.0
|
||||||
|
platformdirs==4.3.6
|
||||||
|
pluggy==1.5.0
|
||||||
|
pooch==1.8.2
|
||||||
|
prompt_toolkit==3.0.50
|
||||||
|
propcache==0.2.1
|
||||||
|
protobuf==5.29.3
|
||||||
|
pycparser==2.22
|
||||||
|
Pygments==2.19.1
|
||||||
|
pyparsing==3.2.1
|
||||||
|
pystoi==0.4.1
|
||||||
|
pytest==8.3.4
|
||||||
|
python-dateutil==2.9.0.post0
|
||||||
|
pytorch-lightning==2.5.0.post0
|
||||||
|
pytorch-ranger==0.1.1
|
||||||
|
pytz==2024.2
|
||||||
|
PyYAML==6.0.2
|
||||||
|
redis==5.2.1
|
||||||
|
requests==2.32.3
|
||||||
|
retrying==1.3.4
|
||||||
|
rich==13.9.4
|
||||||
|
scikit-learn==1.6.1
|
||||||
|
scipy==1.15.1
|
||||||
|
setuptools==75.8.0
|
||||||
|
six==1.17.0
|
||||||
|
soundfile==0.13.1
|
||||||
|
soxr==0.5.0.post1
|
||||||
|
sqlparse==0.5.3
|
||||||
|
submitit==1.5.2
|
||||||
|
sympy==1.13.1
|
||||||
|
tensorboard==2.18.0
|
||||||
|
tensorboard-data-server==0.7.2
|
||||||
|
tensorflow==2.18.0
|
||||||
|
tensorflow-hub==0.16.1
|
||||||
|
termcolor==2.5.0
|
||||||
|
tf_keras==2.18.0
|
||||||
|
threadpoolctl==3.5.0
|
||||||
|
torch==2.5.1
|
||||||
|
torch-optimizer==0.1.0
|
||||||
|
torch-stoi==0.2.3
|
||||||
|
torchaudio==2.5.1
|
||||||
|
torchmetrics==0.11.4
|
||||||
|
tqdm==4.67.1
|
||||||
|
treetable==0.2.5
|
||||||
|
triton==3.1.0
|
||||||
|
typing_extensions==4.12.2
|
||||||
|
tzdata==2025.1
|
||||||
|
urllib3==2.3.0
|
||||||
|
vine==5.1.0
|
||||||
|
wcwidth==0.2.13
|
||||||
|
Werkzeug==3.1.3
|
||||||
|
wheel==0.45.1
|
||||||
|
wrapt==1.17.2
|
||||||
|
yarl==1.18.3
|
||||||
+159
@@ -0,0 +1,159 @@
|
|||||||
|
[build-system]
|
||||||
|
requires = ["setuptools>=64"]
|
||||||
|
build-backend = "setuptools.build_meta"
|
||||||
|
|
||||||
|
[project]
|
||||||
|
name = "freqsplit"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"absl-py==2.1.0",
|
||||||
|
"aiohappyeyeballs==2.4.4",
|
||||||
|
"aiohttp==3.11.11",
|
||||||
|
"aiosignal==1.3.2",
|
||||||
|
"amqp==5.3.1",
|
||||||
|
"antlr4-python3-runtime==4.9.3",
|
||||||
|
"appdirs==1.4.4",
|
||||||
|
"asgiref==3.8.1",
|
||||||
|
"asteroid==0.7.0",
|
||||||
|
"asteroid-filterbanks==0.4.0",
|
||||||
|
"astunparse==1.6.3",
|
||||||
|
"attrs==25.1.0",
|
||||||
|
"audioread==3.0.1",
|
||||||
|
"billiard==4.2.1",
|
||||||
|
"cached-property==2.0.1",
|
||||||
|
"celery==5.4.0",
|
||||||
|
"certifi==2024.12.14",
|
||||||
|
"cffi==1.17.1",
|
||||||
|
"charset-normalizer==3.4.1",
|
||||||
|
"click==8.1.8",
|
||||||
|
"click-didyoumean==0.3.1",
|
||||||
|
"click-plugins==1.1.1",
|
||||||
|
"click-repl==0.3.0",
|
||||||
|
"cloudpickle==3.1.1",
|
||||||
|
"contourpy==1.3.1",
|
||||||
|
"cycler==0.12.1",
|
||||||
|
"decorator==5.1.1",
|
||||||
|
"DeepFilterLib==0.5.6",
|
||||||
|
"DeepFilterNet==0.5.6",
|
||||||
|
"demucs==4.0.1",
|
||||||
|
"Django==5.1.6",
|
||||||
|
"dora_search==0.1.12",
|
||||||
|
"einops==0.8.0",
|
||||||
|
"filelock==3.17.0",
|
||||||
|
"flatbuffers==25.2.10",
|
||||||
|
"fonttools==4.55.6",
|
||||||
|
"frozenlist==1.5.0",
|
||||||
|
"fsspec==2024.12.0",
|
||||||
|
"future==1.0.0",
|
||||||
|
"gast==0.6.0",
|
||||||
|
"google-pasta==0.2.0",
|
||||||
|
"grpcio==1.70.0",
|
||||||
|
"h5py==3.13.0",
|
||||||
|
"huggingface-hub==0.28.0",
|
||||||
|
"idna==3.10",
|
||||||
|
"iniconfig==2.0.0",
|
||||||
|
"Jinja2==3.1.5",
|
||||||
|
"joblib==1.4.2",
|
||||||
|
"julius==0.2.7",
|
||||||
|
"keras==3.8.0",
|
||||||
|
"kiwisolver==1.4.8",
|
||||||
|
"kombu==5.4.2",
|
||||||
|
"lameenc==1.8.1",
|
||||||
|
"lazy_loader==0.4",
|
||||||
|
"libclang==18.1.1",
|
||||||
|
"librosa==0.10.2.post1",
|
||||||
|
"lightning-utilities==0.11.9",
|
||||||
|
"llvmlite==0.44.0",
|
||||||
|
"loguru==0.7.3",
|
||||||
|
"Markdown==3.7",
|
||||||
|
"markdown-it-py==3.0.0",
|
||||||
|
"MarkupSafe==3.0.2",
|
||||||
|
"matplotlib==3.10.0",
|
||||||
|
"mdurl==0.1.2",
|
||||||
|
"mir_eval==0.7",
|
||||||
|
"ml-dtypes==0.4.1",
|
||||||
|
"mpmath==1.3.0",
|
||||||
|
"msgpack==1.1.0",
|
||||||
|
"multidict==6.1.0",
|
||||||
|
"namex==0.0.8",
|
||||||
|
"networkx==3.4.2",
|
||||||
|
"numba==0.61.0",
|
||||||
|
"numpy==1.26.4",
|
||||||
|
"nvidia-cublas-cu12==12.4.5.8",
|
||||||
|
"nvidia-cuda-cupti-cu12==12.4.127",
|
||||||
|
"nvidia-cuda-nvrtc-cu12==12.4.127",
|
||||||
|
"nvidia-cuda-runtime-cu12==12.4.127",
|
||||||
|
"nvidia-cudnn-cu12==9.1.0.70",
|
||||||
|
"nvidia-cufft-cu12==11.2.1.3",
|
||||||
|
"nvidia-curand-cu12==10.3.5.147",
|
||||||
|
"nvidia-cusolver-cu12==11.6.1.9",
|
||||||
|
"nvidia-cusparse-cu12==12.3.1.170",
|
||||||
|
"nvidia-nccl-cu12==2.21.5",
|
||||||
|
"nvidia-nvjitlink-cu12==12.4.127",
|
||||||
|
"nvidia-nvtx-cu12==12.4.127",
|
||||||
|
"omegaconf==2.3.0",
|
||||||
|
"openunmix==1.3.0",
|
||||||
|
"opt_einsum==3.4.0",
|
||||||
|
"optree==0.14.0",
|
||||||
|
"packaging==23.2",
|
||||||
|
"pandas==2.2.3",
|
||||||
|
"pb-bss-eval==0.0.2",
|
||||||
|
"pesq==0.0.4",
|
||||||
|
"pillow==11.1.0",
|
||||||
|
"platformdirs==4.3.6",
|
||||||
|
"pluggy==1.5.0",
|
||||||
|
"pooch==1.8.2",
|
||||||
|
"prompt_toolkit==3.0.50",
|
||||||
|
"propcache==0.2.1",
|
||||||
|
"protobuf==5.29.3",
|
||||||
|
"pycparser==2.22",
|
||||||
|
"Pygments==2.19.1",
|
||||||
|
"pyparsing==3.2.1",
|
||||||
|
"pystoi==0.4.1",
|
||||||
|
"pytest==8.3.4",
|
||||||
|
"python-dateutil==2.9.0.post0",
|
||||||
|
"pytorch-lightning==2.5.0.post0",
|
||||||
|
"pytorch-ranger==0.1.1",
|
||||||
|
"pytz==2024.2",
|
||||||
|
"PyYAML==6.0.2",
|
||||||
|
"redis==5.2.1",
|
||||||
|
"requests==2.32.3",
|
||||||
|
"retrying==1.3.4",
|
||||||
|
"rich==13.9.4",
|
||||||
|
"scikit-learn==1.6.1",
|
||||||
|
"scipy==1.15.1",
|
||||||
|
"setuptools==75.8.0",
|
||||||
|
"six==1.17.0",
|
||||||
|
"soundfile==0.13.1",
|
||||||
|
"soxr==0.5.0.post1",
|
||||||
|
"sqlparse==0.5.3",
|
||||||
|
"submitit==1.5.2",
|
||||||
|
"sympy==1.13.1",
|
||||||
|
"tensorboard==2.18.0",
|
||||||
|
"tensorboard-data-server==0.7.2",
|
||||||
|
"tensorflow==2.18.0",
|
||||||
|
"tensorflow-hub==0.16.1",
|
||||||
|
"termcolor==2.5.0",
|
||||||
|
"tf_keras==2.18.0",
|
||||||
|
"threadpoolctl==3.5.0",
|
||||||
|
"torch==2.5.1",
|
||||||
|
"torch-optimizer==0.1.0",
|
||||||
|
"torch-stoi==0.2.3",
|
||||||
|
"torchaudio==2.5.1",
|
||||||
|
"torchmetrics==0.11.4",
|
||||||
|
"tqdm==4.67.1",
|
||||||
|
"treetable==0.2.5",
|
||||||
|
"triton==3.1.0",
|
||||||
|
"typing_extensions==4.12.2",
|
||||||
|
"tzdata==2025.1",
|
||||||
|
"urllib3==2.3.0",
|
||||||
|
"vine==5.1.0",
|
||||||
|
"wcwidth==0.2.13",
|
||||||
|
"Werkzeug==3.1.3",
|
||||||
|
"wheel==0.45.1",
|
||||||
|
"wrapt==1.17.2",
|
||||||
|
"yarl==1.18.3",
|
||||||
|
]
|
||||||
|
|
||||||
|
[tool.setuptools]
|
||||||
|
packages = { find = { where = ["src"] } }
|
||||||
@@ -29,6 +29,7 @@ DeepFilterLib==0.5.6
|
|||||||
DeepFilterNet==0.5.6
|
DeepFilterNet==0.5.6
|
||||||
demucs==4.0.1
|
demucs==4.0.1
|
||||||
Django==5.1.6
|
Django==5.1.6
|
||||||
|
djangorestframework==3.15.2
|
||||||
dora_search==0.1.12
|
dora_search==0.1.12
|
||||||
einops==0.8.0
|
einops==0.8.0
|
||||||
filelock==3.17.0
|
filelock==3.17.0
|
||||||
|
|||||||
+2
-2
@@ -1,6 +1,6 @@
|
|||||||
import pytest
|
import pytest
|
||||||
from src.input.file_reader import read_audio
|
from freqsplit.input.file_reader import read_audio
|
||||||
from src.input.format_checker import is_supported_format
|
from freqsplit.input.format_checker import is_supported_format
|
||||||
|
|
||||||
def test_read_audio():
|
def test_read_audio():
|
||||||
file_path = "tests/test_audio/cafe_crowd_talk.aiff"
|
file_path = "tests/test_audio/cafe_crowd_talk.aiff"
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
import pytest
|
import pytest
|
||||||
import librosa
|
import librosa
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from src.preprocessing.normalize import normalize_audio
|
from freqsplit.preprocessing.normalize import normalize_audio
|
||||||
from src.preprocessing.trim import trim_audio
|
from freqsplit.preprocessing.trim import trim_audio
|
||||||
from src.preprocessing.classify import classify_audio
|
from freqsplit.preprocessing.classify import classify_audio
|
||||||
from src.input.file_reader import read_audio
|
from freqsplit.input.file_reader import read_audio
|
||||||
from src.preprocessing.resample import resample
|
from freqsplit.preprocessing.resample import resample
|
||||||
|
|
||||||
def test_normalize_audio():
|
def test_normalize_audio():
|
||||||
file_path = "tests/test_audio/cafe_crowd_talk.aiff"
|
file_path = "tests/test_audio/cafe_crowd_talk.aiff"
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import os
|
import os
|
||||||
import pytest
|
import pytest
|
||||||
import soundfile as sf
|
import soundfile as sf
|
||||||
from src.refinement.deepfilternet_wrapper import noisereduce
|
from freqsplit.refinement.deepfilternet_wrapper import noisereduce
|
||||||
|
|
||||||
def test_noisereduce():
|
def test_noisereduce():
|
||||||
"""Test noise reduction function to ensure output is valid."""
|
"""Test noise reduction function to ensure output is valid."""
|
||||||
|
|||||||
@@ -3,12 +3,12 @@ import pytest
|
|||||||
import tempfile
|
import tempfile
|
||||||
import soundfile as sf
|
import soundfile as sf
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from src.input.file_reader import read_audio
|
from freqsplit.input.file_reader import read_audio
|
||||||
from src.preprocessing.trim import trim_audio
|
from freqsplit.preprocessing.trim import trim_audio
|
||||||
from src.preprocessing.resample import resample
|
from freqsplit.preprocessing.resample import resample
|
||||||
from src.separation.demucs_wrapper import separate_audio_with_demucs
|
from freqsplit.separation.demucs_wrapper import separate_audio_with_demucs
|
||||||
from src.separation.convtasnet_wrapper import separate
|
from freqsplit.separation.convtasnet_wrapper import separate
|
||||||
from src.postprocessing.audio_writer import export_audio
|
from freqsplit.postprocessing.audio_writer import export_audio
|
||||||
|
|
||||||
|
|
||||||
def test_demucs_separation_with_preprocessing():
|
def test_demucs_separation_with_preprocessing():
|
||||||
|
|||||||
Reference in New Issue
Block a user