diff --git a/.gitignore b/.gitignore index 06b7abc..ca64584 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,6 @@ venv/ # Ignore VSCode config .vscode/ + +# Ignore output folders +separated_output/ diff --git a/requirements.txt b/requirements.txt index ac44dc3..27debed 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,16 +1,23 @@ absl-py==2.1.0 +antlr4-python3-runtime==4.9.3 asttokens==3.0.0 astunparse==1.6.3 audioread==3.0.1 certifi==2024.12.14 cffi==1.17.1 charset-normalizer==3.4.0 +cloudpickle==3.1.0 contourpy==1.3.1 cycler==0.12.1 decorator==5.1.1 +demucs==4.0.1 +dora_search==0.1.12 +einops==0.8.0 executing==2.1.0 +filelock==3.16.1 flatbuffers==24.12.23 fonttools==4.55.3 +fsspec==2024.12.0 gast==0.6.0 google-pasta==0.2.0 grpcio==1.68.1 @@ -18,9 +25,12 @@ h5py==3.12.1 idna==3.10 iniconfig==2.0.0 jedi==0.19.2 +Jinja2==3.1.5 joblib==1.4.2 +julius==0.2.7 keras==3.7.0 kiwisolver==1.4.8 +lameenc==1.7.0 lazy_loader==0.4 libclang==18.1.1 librosa==0.10.2.post1 @@ -31,10 +41,26 @@ MarkupSafe==3.0.2 matplotlib-inline==0.1.7 mdurl==0.1.2 ml-dtypes==0.4.1 +mpmath==1.3.0 msgpack==1.1.0 namex==0.0.8 +networkx==3.4.2 numba==0.60.0 numpy==2.0.2 +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.13.1 packaging==24.2 @@ -53,7 +79,9 @@ Pygments==2.18.0 pyparsing==3.2.0 pytest==8.3.4 python-dateutil==2.9.0.post0 +PyYAML==6.0.2 requests==2.32.3 +retrying==1.3.4 rich==13.9.4 scikit-learn==1.6.0 scipy==1.14.1 @@ -62,6 +90,8 @@ six==1.17.0 soundfile==0.12.1 soxr==0.5.0.post1 stack-data==0.6.3 +submitit==1.5.2 +sympy==1.13.1 tensorboard==2.18.0 tensorboard-data-server==0.7.2 tensorflow==2.18.0 @@ -69,7 +99,12 @@ tensorflow-hub==0.16.1 termcolor==2.5.0 tf_keras==2.18.0 threadpoolctl==3.5.0 +torch==2.5.1 +torchaudio==2.5.1 +tqdm==4.67.1 traitlets==5.14.3 +treetable==0.2.5 +triton==3.1.0 typing_extensions==4.12.2 urllib3==2.3.0 wcwidth==0.2.13 diff --git a/samples/am_contra_heart_peripheral.wav b/samples/am_contra_heart_peripheral.wav new file mode 100644 index 0000000..aa28b77 Binary files /dev/null and b/samples/am_contra_heart_peripheral.wav differ diff --git a/src/separation/demucs_wrapper.py b/src/separation/demucs_wrapper.py new file mode 100644 index 0000000..165b0c1 --- /dev/null +++ b/src/separation/demucs_wrapper.py @@ -0,0 +1,36 @@ +import subprocess +import os + +def separate_audio_with_demucs(input_file: str, output_dir: str = './separated_output'): + """ + Use subprocess to run Demucs separation on an input audio file. + + Parameters: + input_file (str): Path to the input audio file to be separated. + output_dir (str): Directory where the separated output will be saved. + """ + # Create the output directory if it does not exist + os.makedirs(output_dir, exist_ok=True) + + # Demucs command to separate the audio file + # --out: specifies output directory + command = [ + 'demucs', + '--out', output_dir, # Output directory for separated tracks + input_file # Input file + ] + + try: + # Run the command as a subprocess + subprocess.run(command, check=True) + print(f"Separation completed. Output saved to {output_dir}") + except subprocess.CalledProcessError as e: + print(f"An error occurred while running Demucs: {e}") + except FileNotFoundError: + print("Demucs is not installed or not found in the system PATH.") + +if __name__ == "__main__": + # Example usage + input_audio_path = 'samples/pancakes_for_dinner.wav' # Path to your audio file + output_folder = './separated_output' # Where the separated files will be stored + separate_audio_with_demucs(input_audio_path, output_folder)