diff --git a/.circleci/config.yml b/.circleci/config.yml index 209663e8405..33e40df2e8c 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -241,6 +241,66 @@ jobs: paths: - ffmpeg + build_sox_linux: + <<: *binary_common + docker: + - image: << parameters.wheel_docker_image >> + resource_class: 2xlarge+ + steps: + - checkout + - generate_cache_key + - restore_cache: + + keys: + - sox-linux-v0-{{ checksum ".cachekey" }} + + - run: + command: | + export SOX_ROOT=${PWD}/third_party/sox + if [[ ! -d ${SOX_ROOT} ]]; then + packaging/sox/build.sh + fi + - save_cache: + + key: sox-linux-v0-{{ checksum ".cachekey" }} + + paths: + - third_party/sox + - persist_to_workspace: + root: third_party + paths: + - sox + + build_sox_macos: + <<: *binary_common + macos: + xcode: "14.0" + steps: + - checkout + - generate_cache_key + - restore_cache: + + keys: + - sox-macos-v0-{{ checksum ".cachekey" }} + + - run: + command: | + export SOX_ROOT=${PWD}/third_party/sox + if [[ ! -d ${SOX_ROOT} ]]; then + brew install wget + packaging/sox/build.sh + fi + - save_cache: + + key: sox-macos-v0-{{ checksum ".cachekey" }} + + paths: + - third_party/sox + - persist_to_workspace: + root: third_party + paths: + - sox + binary_linux_wheel: <<: *binary_common docker: @@ -253,6 +313,7 @@ jobs: - run: command: | export FFMPEG_ROOT=${PWD}/third_party/ffmpeg + export SOX_ROOT=${PWD}/third_party/sox packaging/build_wheel.sh environment: USE_FFMPEG: true @@ -278,6 +339,7 @@ jobs: no_output_timeout: 30m command: | export FFMPEG_ROOT=${PWD}/third_party/ffmpeg + export SOX_ROOT=${PWD}/third_party/sox packaging/build_conda.sh environment: USE_FFMPEG: true @@ -306,6 +368,7 @@ jobs: sh conda.sh -b source $HOME/miniconda3/bin/activate export FFMPEG_ROOT="${PWD}/third_party/ffmpeg" + export SOX_ROOT="${PWD}/third_party/sox" packaging/build_wheel.sh environment: USE_FFMPEG: true @@ -333,6 +396,7 @@ jobs: source $HOME/miniconda3/bin/activate conda install -yq conda-build export FFMPEG_ROOT="${PWD}/third_party/ffmpeg" + export SOX_ROOT="${PWD}/third_party/sox" packaging/build_conda.sh environment: USE_FFMPEG: true @@ -362,6 +426,7 @@ jobs: eval "$('/C/tools/miniconda3/Scripts/conda.exe' 'shell.bash' 'hook')" conda activate base export FFMPEG_ROOT="${PWD}/third_party/ffmpeg" + export SOX_ROOT="${PWD}/third_party/sox" bash packaging/build_wheel.sh environment: USE_FFMPEG: true @@ -391,6 +456,7 @@ jobs: conda activate base conda install -yq conda-build "conda-package-handling!=1.5.0" export FFMPEG_ROOT="${PWD}/third_party/ffmpeg" + export SOX_ROOT="${PWD}/third_party/sox" bash packaging/build_conda.sh environment: USE_FFMPEG: true @@ -929,12 +995,23 @@ workflows: python_version: foo requires: - download_third_parties + - build_sox_linux: + name: build_sox_linux + python_version: foo + requires: + - download_third_parties + - build_sox_macos: + name: build_sox_macos + python_version: foo + requires: + - download_third_parties - binary_linux_wheel: cuda_version: cpu name: binary_linux_wheel_py3.7_cpu python_version: '3.7' requires: - build_ffmpeg_linux + - build_sox_linux - smoke_test_linux_pip: cuda_version: cpu name: binary_linux_wheel_py3.7_cpu_smoke_test_pip @@ -947,6 +1024,7 @@ workflows: python_version: '3.7' requires: - build_ffmpeg_linux + - build_sox_linux wheel_docker_image: pytorch/manylinux-cuda116 - smoke_test_linux_pip: cuda_version: cu116 @@ -960,6 +1038,7 @@ workflows: python_version: '3.7' requires: - build_ffmpeg_linux + - build_sox_linux wheel_docker_image: pytorch/manylinux-cuda117 - smoke_test_linux_pip: cuda_version: cu117 @@ -973,6 +1052,7 @@ workflows: python_version: '3.7' requires: - build_ffmpeg_linux + - build_sox_linux wheel_docker_image: pytorch/manylinux-rocm:5.1.1 - smoke_test_linux_pip: cuda_version: rocm5.1.1 @@ -986,6 +1066,7 @@ workflows: python_version: '3.7' requires: - build_ffmpeg_linux + - build_sox_linux wheel_docker_image: pytorch/manylinux-rocm:5.2 - smoke_test_linux_pip: cuda_version: rocm5.2 @@ -1005,6 +1086,7 @@ workflows: python_version: '3.8' requires: - build_ffmpeg_linux + - build_sox_linux - smoke_test_linux_pip: cuda_version: cpu filters: @@ -1023,6 +1105,7 @@ workflows: python_version: '3.8' requires: - build_ffmpeg_linux + - build_sox_linux wheel_docker_image: pytorch/manylinux-cuda116 - smoke_test_linux_pip: cuda_version: cu116 @@ -1036,6 +1119,7 @@ workflows: python_version: '3.8' requires: - build_ffmpeg_linux + - build_sox_linux wheel_docker_image: pytorch/manylinux-cuda117 - smoke_test_linux_pip: cuda_version: cu117 @@ -1049,6 +1133,7 @@ workflows: python_version: '3.8' requires: - build_ffmpeg_linux + - build_sox_linux wheel_docker_image: pytorch/manylinux-rocm:5.1.1 - smoke_test_linux_pip: cuda_version: rocm5.1.1 @@ -1062,6 +1147,7 @@ workflows: python_version: '3.8' requires: - build_ffmpeg_linux + - build_sox_linux wheel_docker_image: pytorch/manylinux-rocm:5.2 - smoke_test_linux_pip: cuda_version: rocm5.2 @@ -1075,6 +1161,7 @@ workflows: python_version: '3.9' requires: - build_ffmpeg_linux + - build_sox_linux - smoke_test_linux_pip: cuda_version: cpu name: binary_linux_wheel_py3.9_cpu_smoke_test_pip @@ -1087,6 +1174,7 @@ workflows: python_version: '3.9' requires: - build_ffmpeg_linux + - build_sox_linux wheel_docker_image: pytorch/manylinux-cuda116 - smoke_test_linux_pip: cuda_version: cu116 @@ -1100,6 +1188,7 @@ workflows: python_version: '3.9' requires: - build_ffmpeg_linux + - build_sox_linux wheel_docker_image: pytorch/manylinux-cuda117 - smoke_test_linux_pip: cuda_version: cu117 @@ -1113,6 +1202,7 @@ workflows: python_version: '3.9' requires: - build_ffmpeg_linux + - build_sox_linux wheel_docker_image: pytorch/manylinux-rocm:5.1.1 - smoke_test_linux_pip: cuda_version: rocm5.1.1 @@ -1126,6 +1216,7 @@ workflows: python_version: '3.9' requires: - build_ffmpeg_linux + - build_sox_linux wheel_docker_image: pytorch/manylinux-rocm:5.2 - smoke_test_linux_pip: cuda_version: rocm5.2 @@ -1139,6 +1230,7 @@ workflows: python_version: '3.10' requires: - build_ffmpeg_linux + - build_sox_linux - smoke_test_linux_pip: cuda_version: cpu name: binary_linux_wheel_py3.10_cpu_smoke_test_pip @@ -1151,6 +1243,7 @@ workflows: python_version: '3.10' requires: - build_ffmpeg_linux + - build_sox_linux wheel_docker_image: pytorch/manylinux-cuda116 - smoke_test_linux_pip: cuda_version: cu116 @@ -1164,6 +1257,7 @@ workflows: python_version: '3.10' requires: - build_ffmpeg_linux + - build_sox_linux wheel_docker_image: pytorch/manylinux-cuda117 - smoke_test_linux_pip: cuda_version: cu117 @@ -1177,6 +1271,7 @@ workflows: python_version: '3.10' requires: - build_ffmpeg_linux + - build_sox_linux wheel_docker_image: pytorch/manylinux-rocm:5.1.1 - smoke_test_linux_pip: cuda_version: rocm5.1.1 @@ -1190,6 +1285,7 @@ workflows: python_version: '3.10' requires: - build_ffmpeg_linux + - build_sox_linux wheel_docker_image: pytorch/manylinux-rocm:5.2 - smoke_test_linux_pip: cuda_version: rocm5.2 @@ -1203,24 +1299,28 @@ workflows: python_version: '3.7' requires: - build_ffmpeg_macos + - build_sox_macos - binary_macos_wheel: cuda_version: cpu name: binary_macos_wheel_py3.8_cpu python_version: '3.8' requires: - build_ffmpeg_macos + - build_sox_macos - binary_macos_wheel: cuda_version: cpu name: binary_macos_wheel_py3.9_cpu python_version: '3.9' requires: - build_ffmpeg_macos + - build_sox_macos - binary_macos_wheel: cuda_version: cpu name: binary_macos_wheel_py3.10_cpu python_version: '3.10' requires: - build_ffmpeg_macos + - build_sox_macos - binary_windows_wheel: cuda_version: cpu name: binary_windows_wheel_py3.7_cpu @@ -1380,6 +1480,7 @@ workflows: python_version: '3.7' requires: - build_ffmpeg_linux + - build_sox_linux - smoke_test_linux_conda: cuda_version: cpu name: binary_linux_conda_py3.7_cpu_smoke_test_conda @@ -1393,6 +1494,7 @@ workflows: python_version: '3.7' requires: - build_ffmpeg_linux + - build_sox_linux - smoke_test_linux_conda_gpu: cuda_version: cu116 name: binary_linux_conda_py3.7_cu116_smoke_test_conda @@ -1406,6 +1508,7 @@ workflows: python_version: '3.7' requires: - build_ffmpeg_linux + - build_sox_linux - smoke_test_linux_conda_gpu: cuda_version: cu117 name: binary_linux_conda_py3.7_cu117_smoke_test_conda @@ -1419,6 +1522,7 @@ workflows: python_version: '3.8' requires: - build_ffmpeg_linux + - build_sox_linux - smoke_test_linux_conda: cuda_version: cpu name: binary_linux_conda_py3.8_cpu_smoke_test_conda @@ -1432,6 +1536,7 @@ workflows: python_version: '3.8' requires: - build_ffmpeg_linux + - build_sox_linux - smoke_test_linux_conda_gpu: cuda_version: cu116 name: binary_linux_conda_py3.8_cu116_smoke_test_conda @@ -1445,6 +1550,7 @@ workflows: python_version: '3.8' requires: - build_ffmpeg_linux + - build_sox_linux - smoke_test_linux_conda_gpu: cuda_version: cu117 name: binary_linux_conda_py3.8_cu117_smoke_test_conda @@ -1458,6 +1564,7 @@ workflows: python_version: '3.9' requires: - build_ffmpeg_linux + - build_sox_linux - smoke_test_linux_conda: cuda_version: cpu name: binary_linux_conda_py3.9_cpu_smoke_test_conda @@ -1471,6 +1578,7 @@ workflows: python_version: '3.9' requires: - build_ffmpeg_linux + - build_sox_linux - smoke_test_linux_conda_gpu: cuda_version: cu116 name: binary_linux_conda_py3.9_cu116_smoke_test_conda @@ -1484,6 +1592,7 @@ workflows: python_version: '3.9' requires: - build_ffmpeg_linux + - build_sox_linux - smoke_test_linux_conda_gpu: cuda_version: cu117 name: binary_linux_conda_py3.9_cu117_smoke_test_conda @@ -1497,6 +1606,7 @@ workflows: python_version: '3.10' requires: - build_ffmpeg_linux + - build_sox_linux - smoke_test_linux_conda: cuda_version: cpu name: binary_linux_conda_py3.10_cpu_smoke_test_conda @@ -1510,6 +1620,7 @@ workflows: python_version: '3.10' requires: - build_ffmpeg_linux + - build_sox_linux - smoke_test_linux_conda_gpu: cuda_version: cu116 name: binary_linux_conda_py3.10_cu116_smoke_test_conda @@ -1523,6 +1634,7 @@ workflows: python_version: '3.10' requires: - build_ffmpeg_linux + - build_sox_linux - smoke_test_linux_conda_gpu: cuda_version: cu117 name: binary_linux_conda_py3.10_cu117_smoke_test_conda @@ -1536,6 +1648,7 @@ workflows: python_version: '3.7' requires: - build_ffmpeg_macos + - build_sox_macos - binary_macos_conda: conda_docker_image: pytorch/conda-builder:cpu cuda_version: cpu @@ -1543,6 +1656,7 @@ workflows: python_version: '3.8' requires: - build_ffmpeg_macos + - build_sox_macos - binary_macos_conda: conda_docker_image: pytorch/conda-builder:cpu cuda_version: cpu @@ -1550,6 +1664,7 @@ workflows: python_version: '3.9' requires: - build_ffmpeg_macos + - build_sox_macos - binary_macos_conda: conda_docker_image: pytorch/conda-builder:cpu cuda_version: cpu @@ -1557,6 +1672,7 @@ workflows: python_version: '3.10' requires: - build_ffmpeg_macos + - build_sox_macos - binary_windows_conda: conda_docker_image: pytorch/conda-builder:cpu cuda_version: cpu @@ -1863,6 +1979,28 @@ workflows: python_version: foo requires: - download_third_parties + - build_sox_linux: + filters: + branches: + only: + - nightly + tags: + only: /v[0-9]+(\.[0-9]+)*-rc[0-9]+/ + name: build_sox_linux + python_version: foo + requires: + - download_third_parties + - build_sox_macos: + filters: + branches: + only: + - nightly + tags: + only: /v[0-9]+(\.[0-9]+)*-rc[0-9]+/ + name: build_sox_macos + python_version: foo + requires: + - download_third_parties - binary_linux_wheel: cuda_version: cpu filters: @@ -1875,6 +2013,7 @@ workflows: python_version: '3.7' requires: - build_ffmpeg_linux + - build_sox_linux - binary_wheel_upload: context: org-member filters: @@ -1911,6 +2050,7 @@ workflows: python_version: '3.7' requires: - build_ffmpeg_linux + - build_sox_linux wheel_docker_image: pytorch/manylinux-cuda116 - binary_wheel_upload: context: org-member @@ -1948,6 +2088,7 @@ workflows: python_version: '3.7' requires: - build_ffmpeg_linux + - build_sox_linux wheel_docker_image: pytorch/manylinux-cuda117 - binary_wheel_upload: context: org-member @@ -1985,6 +2126,7 @@ workflows: python_version: '3.7' requires: - build_ffmpeg_linux + - build_sox_linux wheel_docker_image: pytorch/manylinux-rocm:5.1.1 - binary_wheel_upload: context: org-member @@ -2022,6 +2164,7 @@ workflows: python_version: '3.7' requires: - build_ffmpeg_linux + - build_sox_linux wheel_docker_image: pytorch/manylinux-rocm:5.2 - binary_wheel_upload: context: org-member @@ -2059,6 +2202,7 @@ workflows: python_version: '3.8' requires: - build_ffmpeg_linux + - build_sox_linux - binary_wheel_upload: context: org-member filters: @@ -2095,6 +2239,7 @@ workflows: python_version: '3.8' requires: - build_ffmpeg_linux + - build_sox_linux wheel_docker_image: pytorch/manylinux-cuda116 - binary_wheel_upload: context: org-member @@ -2132,6 +2277,7 @@ workflows: python_version: '3.8' requires: - build_ffmpeg_linux + - build_sox_linux wheel_docker_image: pytorch/manylinux-cuda117 - binary_wheel_upload: context: org-member @@ -2169,6 +2315,7 @@ workflows: python_version: '3.8' requires: - build_ffmpeg_linux + - build_sox_linux wheel_docker_image: pytorch/manylinux-rocm:5.1.1 - binary_wheel_upload: context: org-member @@ -2206,6 +2353,7 @@ workflows: python_version: '3.8' requires: - build_ffmpeg_linux + - build_sox_linux wheel_docker_image: pytorch/manylinux-rocm:5.2 - binary_wheel_upload: context: org-member @@ -2243,6 +2391,7 @@ workflows: python_version: '3.9' requires: - build_ffmpeg_linux + - build_sox_linux - binary_wheel_upload: context: org-member filters: @@ -2279,6 +2428,7 @@ workflows: python_version: '3.9' requires: - build_ffmpeg_linux + - build_sox_linux wheel_docker_image: pytorch/manylinux-cuda116 - binary_wheel_upload: context: org-member @@ -2316,6 +2466,7 @@ workflows: python_version: '3.9' requires: - build_ffmpeg_linux + - build_sox_linux wheel_docker_image: pytorch/manylinux-cuda117 - binary_wheel_upload: context: org-member @@ -2353,6 +2504,7 @@ workflows: python_version: '3.9' requires: - build_ffmpeg_linux + - build_sox_linux wheel_docker_image: pytorch/manylinux-rocm:5.1.1 - binary_wheel_upload: context: org-member @@ -2390,6 +2542,7 @@ workflows: python_version: '3.9' requires: - build_ffmpeg_linux + - build_sox_linux wheel_docker_image: pytorch/manylinux-rocm:5.2 - binary_wheel_upload: context: org-member @@ -2427,6 +2580,7 @@ workflows: python_version: '3.10' requires: - build_ffmpeg_linux + - build_sox_linux - binary_wheel_upload: context: org-member filters: @@ -2463,6 +2617,7 @@ workflows: python_version: '3.10' requires: - build_ffmpeg_linux + - build_sox_linux wheel_docker_image: pytorch/manylinux-cuda116 - binary_wheel_upload: context: org-member @@ -2500,6 +2655,7 @@ workflows: python_version: '3.10' requires: - build_ffmpeg_linux + - build_sox_linux wheel_docker_image: pytorch/manylinux-cuda117 - binary_wheel_upload: context: org-member @@ -2537,6 +2693,7 @@ workflows: python_version: '3.10' requires: - build_ffmpeg_linux + - build_sox_linux wheel_docker_image: pytorch/manylinux-rocm:5.1.1 - binary_wheel_upload: context: org-member @@ -2574,6 +2731,7 @@ workflows: python_version: '3.10' requires: - build_ffmpeg_linux + - build_sox_linux wheel_docker_image: pytorch/manylinux-rocm:5.2 - binary_wheel_upload: context: org-member @@ -2611,6 +2769,7 @@ workflows: python_version: '3.7' requires: - build_ffmpeg_macos + - build_sox_macos - binary_wheel_upload: context: org-member filters: @@ -2635,6 +2794,7 @@ workflows: python_version: '3.8' requires: - build_ffmpeg_macos + - build_sox_macos - binary_wheel_upload: context: org-member filters: @@ -2659,6 +2819,7 @@ workflows: python_version: '3.9' requires: - build_ffmpeg_macos + - build_sox_macos - binary_wheel_upload: context: org-member filters: @@ -2683,6 +2844,7 @@ workflows: python_version: '3.10' requires: - build_ffmpeg_macos + - build_sox_macos - binary_wheel_upload: context: org-member filters: @@ -3148,6 +3310,7 @@ workflows: python_version: '3.7' requires: - build_ffmpeg_linux + - build_sox_linux - binary_conda_upload: context: org-member filters: @@ -3184,6 +3347,7 @@ workflows: python_version: '3.7' requires: - build_ffmpeg_linux + - build_sox_linux - binary_conda_upload: context: org-member filters: @@ -3220,6 +3384,7 @@ workflows: python_version: '3.7' requires: - build_ffmpeg_linux + - build_sox_linux - binary_conda_upload: context: org-member filters: @@ -3256,6 +3421,7 @@ workflows: python_version: '3.8' requires: - build_ffmpeg_linux + - build_sox_linux - binary_conda_upload: context: org-member filters: @@ -3292,6 +3458,7 @@ workflows: python_version: '3.8' requires: - build_ffmpeg_linux + - build_sox_linux - binary_conda_upload: context: org-member filters: @@ -3328,6 +3495,7 @@ workflows: python_version: '3.8' requires: - build_ffmpeg_linux + - build_sox_linux - binary_conda_upload: context: org-member filters: @@ -3364,6 +3532,7 @@ workflows: python_version: '3.9' requires: - build_ffmpeg_linux + - build_sox_linux - binary_conda_upload: context: org-member filters: @@ -3400,6 +3569,7 @@ workflows: python_version: '3.9' requires: - build_ffmpeg_linux + - build_sox_linux - binary_conda_upload: context: org-member filters: @@ -3436,6 +3606,7 @@ workflows: python_version: '3.9' requires: - build_ffmpeg_linux + - build_sox_linux - binary_conda_upload: context: org-member filters: @@ -3472,6 +3643,7 @@ workflows: python_version: '3.10' requires: - build_ffmpeg_linux + - build_sox_linux - binary_conda_upload: context: org-member filters: @@ -3508,6 +3680,7 @@ workflows: python_version: '3.10' requires: - build_ffmpeg_linux + - build_sox_linux - binary_conda_upload: context: org-member filters: @@ -3544,6 +3717,7 @@ workflows: python_version: '3.10' requires: - build_ffmpeg_linux + - build_sox_linux - binary_conda_upload: context: org-member filters: @@ -3580,6 +3754,7 @@ workflows: python_version: '3.7' requires: - build_ffmpeg_macos + - build_sox_macos - binary_conda_upload: context: org-member filters: @@ -3604,6 +3779,7 @@ workflows: python_version: '3.8' requires: - build_ffmpeg_macos + - build_sox_macos - binary_conda_upload: context: org-member filters: @@ -3628,6 +3804,7 @@ workflows: python_version: '3.9' requires: - build_ffmpeg_macos + - build_sox_macos - binary_conda_upload: context: org-member filters: @@ -3652,6 +3829,7 @@ workflows: python_version: '3.10' requires: - build_ffmpeg_macos + - build_sox_macos - binary_conda_upload: context: org-member filters: diff --git a/.circleci/config.yml.in b/.circleci/config.yml.in index c6777a3b619..d63644ba95f 100644 --- a/.circleci/config.yml.in +++ b/.circleci/config.yml.in @@ -241,6 +241,66 @@ jobs: paths: - ffmpeg + build_sox_linux: + <<: *binary_common + docker: + - image: << parameters.wheel_docker_image >> + resource_class: 2xlarge+ + steps: + - checkout + - generate_cache_key + - restore_cache: + {% raw %} + keys: + - sox-linux-v0-{{ checksum ".cachekey" }} + {% endraw %} + - run: + command: | + export SOX_ROOT=${PWD}/third_party/sox + if [[ ! -d ${SOX_ROOT} ]]; then + packaging/sox/build.sh + fi + - save_cache: + {% raw %} + key: sox-linux-v0-{{ checksum ".cachekey" }} + {% endraw %} + paths: + - third_party/sox + - persist_to_workspace: + root: third_party + paths: + - sox + + build_sox_macos: + <<: *binary_common + macos: + xcode: "14.0" + steps: + - checkout + - generate_cache_key + - restore_cache: + {% raw %} + keys: + - sox-macos-v0-{{ checksum ".cachekey" }} + {% endraw %} + - run: + command: | + export SOX_ROOT=${PWD}/third_party/sox + if [[ ! -d ${SOX_ROOT} ]]; then + brew install wget + packaging/sox/build.sh + fi + - save_cache: + {% raw %} + key: sox-macos-v0-{{ checksum ".cachekey" }} + {% endraw %} + paths: + - third_party/sox + - persist_to_workspace: + root: third_party + paths: + - sox + binary_linux_wheel: <<: *binary_common docker: @@ -253,6 +313,7 @@ jobs: - run: command: | export FFMPEG_ROOT=${PWD}/third_party/ffmpeg + export SOX_ROOT=${PWD}/third_party/sox packaging/build_wheel.sh environment: USE_FFMPEG: true @@ -278,6 +339,7 @@ jobs: no_output_timeout: 30m command: | export FFMPEG_ROOT=${PWD}/third_party/ffmpeg + export SOX_ROOT=${PWD}/third_party/sox packaging/build_conda.sh environment: USE_FFMPEG: true @@ -306,6 +368,7 @@ jobs: sh conda.sh -b source $HOME/miniconda3/bin/activate export FFMPEG_ROOT="${PWD}/third_party/ffmpeg" + export SOX_ROOT="${PWD}/third_party/sox" packaging/build_wheel.sh environment: USE_FFMPEG: true @@ -333,6 +396,7 @@ jobs: source $HOME/miniconda3/bin/activate conda install -yq conda-build export FFMPEG_ROOT="${PWD}/third_party/ffmpeg" + export SOX_ROOT="${PWD}/third_party/sox" packaging/build_conda.sh environment: USE_FFMPEG: true @@ -362,6 +426,7 @@ jobs: eval "$('/C/tools/miniconda3/Scripts/conda.exe' 'shell.bash' 'hook')" conda activate base export FFMPEG_ROOT="${PWD}/third_party/ffmpeg" + export SOX_ROOT="${PWD}/third_party/sox" bash packaging/build_wheel.sh environment: USE_FFMPEG: true @@ -391,6 +456,7 @@ jobs: conda activate base conda install -yq conda-build "conda-package-handling!=1.5.0" export FFMPEG_ROOT="${PWD}/third_party/ffmpeg" + export SOX_ROOT="${PWD}/third_party/sox" bash packaging/build_conda.sh environment: USE_FFMPEG: true diff --git a/.circleci/regenerate.py b/.circleci/regenerate.py index 97c825efc85..70e37af5ef6 100755 --- a/.circleci/regenerate.py +++ b/.circleci/regenerate.py @@ -37,6 +37,8 @@ def build_workflows(prefix="", upload=False, filter_branch=None, indentation=6): w += build_download_job(filter_branch) for os_type in ["linux", "macos", "windows"]: w += build_ffmpeg_job(os_type, filter_branch) + for os_type in ["linux", "macos"]: + w += build_sox_job(os_type, filter_branch) for btype in ["wheel", "conda"]: for os_type in ["linux", "macos", "windows"]: for python_version in PYTHON_VERSIONS: @@ -82,6 +84,18 @@ def build_ffmpeg_job(os_type, filter_branch): return [{f"build_ffmpeg_{os_type}": job}] +def build_sox_job(os_type, filter_branch): + job = { + "name": f"build_sox_{os_type}", + "requires": ["download_third_parties"], + } + + if filter_branch: + job["filters"] = gen_filter_branch_tree(filter_branch) + job["python_version"] = "foo" + return [{f"build_sox_{os_type}": job}] + + def build_workflow_pair(btype, os_type, python_version, cu_version, filter_branch, prefix="", upload=False): w = [] @@ -156,6 +170,9 @@ def generate_base_workflow(base_workflow_name, python_version, cu_version, filte "requires": [f"build_ffmpeg_{os_type}"], } + if os_type in ["linux", "macos"]: + d["requires"].append(f"build_sox_{os_type}") + if btype == "conda": d["conda_docker_image"] = f'pytorch/conda-builder:{cu_version.replace("cu1","cuda1")}' elif cu_version.startswith("cu"): diff --git a/.circleci/unittest/linux/scripts/install.sh b/.circleci/unittest/linux/scripts/install.sh index 2a9c41f073a..e5da01ff599 100755 --- a/.circleci/unittest/linux/scripts/install.sh +++ b/.circleci/unittest/linux/scripts/install.sh @@ -18,6 +18,58 @@ case "$(uname -s)" in *) os=Linux esac + +if [ "${os}" != MacOSX ] ; then + apt-key adv --keyserver keyserver.ubuntu.com --recv-keys A4B469963BF863CC + apt-get -qq update + apt-get -y install libopencore-amrnb-dev libopencore-amrwb-dev libflac-dev libvorbis-dev libmp3lame-dev opus-tools + + wget https://ftp.osuosl.org/pub/xiph/releases/opus/opus-1.3.1.tar.gz + tar -xf opus-1.3.1.tar.gz + cd opus-1.3.1 + ./configure + make install + cd .. + + wget https://ftp.osuosl.org/pub/xiph/releases/opus/opusfile-0.12.tar.gz + tar -xf opusfile-0.12.tar.gz + cd opusfile-0.12 + ./configure --disable-http + make install + cd .. + + wget https://downloads.sourceforge.net/project/sox/sox/14.4.2/sox-14.4.2.tar.bz2 + tar -xf sox-14.4.2.tar.bz2 + cd sox-14.4.2 + ./configure \ + --disable-openmp \ + --with-amrnb \ + --with-amrwb \ + --with-flac \ + --with-lame \ + --with-oggvorbis \ + --with-opus \ + --without-alsa \ + --without-ao \ + --without-coreaudio \ + --without-oss \ + --without-id3tag \ + --without-ladspa \ + --without-mad \ + --without-magic \ + --without-png \ + --without-pulseaudio \ + --without-sndfile \ + --without-sndio \ + --without-sunaudio \ + --without-waveaudio \ + --without-wavpack \ + --without-twolame + make install + cd .. + export LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:/usr/local/lib" +fi + # 0. Activate conda env eval "$("${conda_dir}/bin/conda" shell.bash hook)" conda activate "${env_dir}" diff --git a/.circleci/unittest/linux/scripts/run_test.sh b/.circleci/unittest/linux/scripts/run_test.sh index 83a9196d7e5..d1eea43ccc1 100755 --- a/.circleci/unittest/linux/scripts/run_test.sh +++ b/.circleci/unittest/linux/scripts/run_test.sh @@ -2,6 +2,94 @@ set -e + +if [ "${os}" != MacOSX ] ; then + # apt-key adv --keyserver keyserver.ubuntu.com --recv-keys A4B469963BF863CC + # apt-get -qq update + + # apt-get -y install libopencore-amrnb-dev libopencore-amrwb-dev libflac-dev libvorbis-dev libmp3lame-dev opus-tools + + wget https://sourceforge.net/projects/opencore-amr/files/opencore-amr/opencore-amr-0.1.5.tar.gz + tar -xf opencore-amr-0.1.5.tar.gz + cd opencore-amr-0.1.5 + ./configure + make install + cd .. + + wget https://downloads.sourceforge.net/project/lame/lame/3.99/lame-3.99.5.tar.gz + tar -xf lame-3.99.5.tar.gz + cd lame-3.99.5 + ./configure + make install + cd .. + + wget https://ftp.osuosl.org/pub/xiph/releases/ogg/libogg-1.3.3.tar.gz + tar -xf libogg-1.3.3.tar.gz + cd libogg-1.3.3 + ./configure + make install + cd .. + + wget https://ftp.osuosl.org/pub/xiph/releases/flac/flac-1.3.2.tar.xz + tar -xf flac-1.3.2.tar.xz + cd flac-1.3.2 + ./configure --with-ogg --disable-cpplibs + make install + cd .. + + wget https://ftp.osuosl.org/pub/xiph/releases/vorbis/libvorbis-1.3.6.tar.gz + tar -xf libvorbis-1.3.6.tar.gz + cd libvorbis-1.3.6 + ./configure --with-ogg + make install + cd .. + + wget https://ftp.osuosl.org/pub/xiph/releases/opus/opus-1.3.1.tar.gz + tar -xf opus-1.3.1.tar.gz + cd opus-1.3.1 + ./configure + make install + cd .. + + wget https://ftp.osuosl.org/pub/xiph/releases/opus/opusfile-0.12.tar.gz + tar -xf opusfile-0.12.tar.gz + cd opusfile-0.12 + ./configure --disable-http + make install + cd .. + + wget https://downloads.sourceforge.net/project/sox/sox/14.4.2/sox-14.4.2.tar.bz2 + tar -xf sox-14.4.2.tar.bz2 + cd sox-14.4.2 + ./configure \ + --disable-openmp \ + --with-amrnb \ + --with-amrwb \ + --with-flac \ + --with-lame \ + --with-oggvorbis \ + --with-opus \ + --without-alsa \ + --without-ao \ + --without-coreaudio \ + --without-oss \ + --without-id3tag \ + --without-ladspa \ + --without-mad \ + --without-magic \ + --without-png \ + --without-pulseaudio \ + --without-sndfile \ + --without-sndio \ + --without-sunaudio \ + --without-waveaudio \ + --without-wavpack \ + --without-twolame + make install + cd .. + export LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:/usr/local/lib" +fi + eval "$(./conda/bin/conda shell.bash hook)" conda activate ./env diff --git a/.github/workflows/integration-test.yml b/.github/workflows/integration-test.yml index 4eef95dddb4..d7c46d1fb5d 100644 --- a/.github/workflows/integration-test.yml +++ b/.github/workflows/integration-test.yml @@ -24,7 +24,7 @@ jobs: - name: Install dependencies run: | sudo add-apt-repository -y ppa:jonathonf/ffmpeg-4 - sudo apt install -y -qq pkg-config libavfilter-dev libavdevice-dev + sudo apt install -y -qq pkg-config libavfilter-dev libavdevice-dev sox libsox-dev libsox-fmt-all - name: Install packages run: | python -m pip install --quiet --upgrade pip diff --git a/CMakeLists.txt b/CMakeLists.txt index 696a736a787..a8da1400bbc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -56,7 +56,7 @@ endif() # Options -option(BUILD_SOX "Build libsox statically" ON) +option(USE_SOX "Enable SoX features" ON) option(BUILD_KALDI "Build kaldi statically" ON) option(BUILD_RNNT "Enable RNN transducer" ON) option(BUILD_CTC_DECODER "Build Flashlight CTC decoder" ON) diff --git a/cmake/FindSOX.cmake b/cmake/FindSOX.cmake new file mode 100644 index 00000000000..e2aa19a389f --- /dev/null +++ b/cmake/FindSOX.cmake @@ -0,0 +1,40 @@ +if (NOT SOX_FOUND) + find_package(PkgConfig) + if (PKG_CONFIG_FOUND) + pkg_check_modules(SOX sox) + if (SOX_FOUND) + message(STATUS "PkgConfig found sox (include: ${SOX_INCLUDE_DIRS}, link libraries: ${SOX_LINK_LIBRARIES})") + endif() + endif() + + if (NOT SOX_FOUND) + set(SOX_ROOT $ENV{SOX_ROOT} CACHE PATH "Folder contains the sox library") + + find_path(SOX_INCLUDE_DIRS + NAMES sox.h + PATHS ${SOX_INCLUDE_DIR} ${SOX_ROOT} + PATH_SUFFIXES "include" "include/sox/" + ) + + if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin") + set(SOX_LIBNAME "libsox.dylib") + else() + SET(SOX_LIBNAME "libsox${CMAKE_SHARED_LIBRARY_SUFFIX}") + endif() + + find_library(SOX_LINK_LIBRARIES + NAMES ${SOX_LIBNAME} + PATHS ${SOX_LIB_DIR} ${SOX_ROOT} + PATH_SUFFIXES "lib" "lib64" + ) + + include(FindPackageHandleStandardArgs) + find_package_handle_standard_args(SOX DEFAULT_MSG SOX_INCLUDE_DIRS SOX_LINK_LIBRARIES) + + if(SOX_FOUND) + set (SOX_HEADER_FILE "${SOX_INCLUDE_DIRS}/sox.h") + message(STATUS "Found SOX (include: ${SOX_INCLUDE_DIRS}, library: ${SOX_LINK_LIBRARIES})") + mark_as_advanced(SOX_ROOT SOX_INCLUDE_DIRS SOX_LINK_LIBRARIES) + endif() + endif() +endif() diff --git a/packaging/sox/build.sh b/packaging/sox/build.sh new file mode 100755 index 00000000000..0c2e69a7400 --- /dev/null +++ b/packaging/sox/build.sh @@ -0,0 +1,100 @@ +#!/usr/bin/env bash + + +prefix="${SOX_ROOT}" +echo ${prefix} + +build_dir=$(mktemp -d -t sox-build.XXXXXXXXXX) +cleanup() { + rm -rf "${build_dir}" +} +trap 'cleanup $?' EXIT +cd "${build_dir}" + +# yum -y install lame lame-devel +# yum -y install libvorbis-devel +# yum -y install opus opus-devel +# yum -y install opusfile opusfile-devel +# yum -y install flac-devel +# yum -y install libopencore-amr libopencore-amr-devel + +wget https://sourceforge.net/projects/opencore-amr/files/opencore-amr/opencore-amr-0.1.5.tar.gz +tar -xf opencore-amr-0.1.5.tar.gz +cd opencore-amr-0.1.5 +./configure --prefix="${prefix}" +make install +cd .. + +wget https://downloads.sourceforge.net/project/lame/lame/3.99/lame-3.99.5.tar.gz +tar -xf lame-3.99.5.tar.gz +cd lame-3.99.5 +./configure --prefix="${prefix}" +make install +cd .. + +wget https://ftp.osuosl.org/pub/xiph/releases/ogg/libogg-1.3.3.tar.gz +tar -xf libogg-1.3.3.tar.gz +cd libogg-1.3.3 +./configure --prefix="${prefix}" +make install +cd .. + +wget https://ftp.osuosl.org/pub/xiph/releases/flac/flac-1.3.2.tar.xz +tar -xf flac-1.3.2.tar.xz +cd flac-1.3.2 +./configure --prefix="${prefix}" --with-ogg --disable-cpplibs +make install +cd .. + +wget https://ftp.osuosl.org/pub/xiph/releases/vorbis/libvorbis-1.3.6.tar.gz +tar -xf libvorbis-1.3.6.tar.gz +cd libvorbis-1.3.6 +./configure --prefix="${prefix}" --with-ogg +make install +cd .. + +wget https://ftp.osuosl.org/pub/xiph/releases/opus/opus-1.3.1.tar.gz +tar -xf opus-1.3.1.tar.gz +cd opus-1.3.1 +./configure --prefix="${prefix}" --with-ogg +make install +cd .. + +wget https://ftp.osuosl.org/pub/xiph/releases/opus/opusfile-0.12.tar.gz +tar -xf opusfile-0.12.tar.gz +cd opusfile-0.12 +./configure --prefix="${prefix}" --disable-http +make install +cd .. + +wget https://downloads.sourceforge.net/project/sox/sox/14.4.2/sox-14.4.2.tar.bz2 +tar -xf sox-14.4.2.tar.bz2 # --strip-components 1 +cd sox-14.4.2 +./configure --prefix="${prefix}" \ +# ./configure \ + --disable-openmp \ + --with-amrnb \ + --with-amrwb \ + --with-flac \ + --with-lame \ + --with-oggvorbis \ + --with-opus \ + --without-alsa \ + --without-ao \ + --without-coreaudio \ + --without-oss \ + --without-id3tag \ + --without-ladspa \ + --without-mad \ + --without-magic \ + --without-png \ + --without-pulseaudio \ + --without-sndfile \ + --without-sndio \ + --without-sunaudio \ + --without-waveaudio \ + --without-wavpack \ + --without-twolame + +make install +cd .. diff --git a/packaging/torchaudio/meta.yaml b/packaging/torchaudio/meta.yaml index 344ef0a2b7c..ae60c9bdf8e 100644 --- a/packaging/torchaudio/meta.yaml +++ b/packaging/torchaudio/meta.yaml @@ -49,7 +49,9 @@ build: - TORCH_CUDA_ARCH_LIST - USE_FFMPEG - USE_OPENMP + - USE_SOX - FFMPEG_ROOT + - SOX_ROOT - MACOSX_DEPLOYMENT_TARGET test: diff --git a/setup.py b/setup.py index 3c9b2712e0a..f5d17f05bc7 100644 --- a/setup.py +++ b/setup.py @@ -106,7 +106,7 @@ def _parse_url(path): def _parse_sources(): third_party_dir = ROOT_DIR / "third_party" - libs = ["zlib", "bzip2", "lzma", "sox"] + libs = ["zlib", "bzip2", "lzma"] archive_dir = third_party_dir / "archives" archive_dir.mkdir(exist_ok=True) for lib in libs: diff --git a/third_party/CMakeLists.txt b/third_party/CMakeLists.txt index f2b82966626..2e555152808 100644 --- a/third_party/CMakeLists.txt +++ b/third_party/CMakeLists.txt @@ -3,12 +3,6 @@ set(CMAKE_CXX_VISIBILITY_PRESET hidden) file(MAKE_DIRECTORY install/include) file(MAKE_DIRECTORY install/lib) -################################################################################ -# sox -################################################################################ -if (BUILD_SOX) - add_subdirectory(sox) -endif() ################################################################################ # kaldi diff --git a/third_party/sox/CMakeLists.txt b/third_party/sox/CMakeLists.txt deleted file mode 100644 index 50e5cc91565..00000000000 --- a/third_party/sox/CMakeLists.txt +++ /dev/null @@ -1,212 +0,0 @@ -find_package(PkgConfig REQUIRED) - -include(ExternalProject) - -set(INSTALL_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../install) -set(ARCHIVE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../archives) -set(patch_dir ${PROJECT_SOURCE_DIR}/third_party/patches) -set(COMMON_ARGS --quiet --disable-shared --enable-static --prefix=${INSTALL_DIR} --with-pic --disable-dependency-tracking --disable-debug --disable-examples --disable-doc) - -# To pass custom environment variables to ExternalProject_Add command, -# we need to do `${CMAKE_COMMAND} -E env ${envs} `. -# https://stackoverflow.com/a/62437353 -# We constrcut the custom environment variables here -set(envs - "PKG_CONFIG_PATH=${INSTALL_DIR}/lib/pkgconfig" - "LDFLAGS=-L${INSTALL_DIR}/lib $ENV{LDFLAGS}" - "CFLAGS=-I${INSTALL_DIR}/include -fvisibility=hidden $ENV{CFLAGS}" -) - -ExternalProject_Add(amr - PREFIX ${CMAKE_CURRENT_BINARY_DIR} - DOWNLOAD_DIR ${ARCHIVE_DIR} - URL https://sourceforge.net/projects/opencore-amr/files/opencore-amr/opencore-amr-0.1.5.tar.gz - URL_HASH SHA256=2c006cb9d5f651bfb5e60156dbff6af3c9d35c7bbcc9015308c0aff1e14cd341 - PATCH_COMMAND cp ${patch_dir}/config.guess ${patch_dir}/config.sub ${CMAKE_CURRENT_BINARY_DIR}/src/amr/ - CONFIGURE_COMMAND ${CMAKE_COMMAND} -E env ${envs} ${CMAKE_CURRENT_BINARY_DIR}/src/amr/configure ${COMMON_ARGS} - DOWNLOAD_NO_PROGRESS ON - LOG_DOWNLOAD ON - LOG_UPDATE ON - LOG_CONFIGURE ON - LOG_BUILD ON - LOG_INSTALL ON - LOG_MERGED_STDOUTERR ON - LOG_OUTPUT_ON_FAILURE ON -) - -ExternalProject_Add(lame - PREFIX ${CMAKE_CURRENT_BINARY_DIR} - DOWNLOAD_DIR ${ARCHIVE_DIR} - URL https://downloads.sourceforge.net/project/lame/lame/3.99/lame-3.99.5.tar.gz - URL_HASH SHA256=24346b4158e4af3bd9f2e194bb23eb473c75fb7377011523353196b19b9a23ff - PATCH_COMMAND cp ${patch_dir}/config.guess ${patch_dir}/config.sub ${CMAKE_CURRENT_BINARY_DIR}/src/lame/ - CONFIGURE_COMMAND ${CMAKE_COMMAND} -E env ${envs} ${CMAKE_CURRENT_BINARY_DIR}/src/lame/configure ${COMMON_ARGS} --enable-nasm - DOWNLOAD_NO_PROGRESS ON - LOG_DOWNLOAD ON - LOG_UPDATE ON - LOG_CONFIGURE ON - LOG_BUILD ON - LOG_INSTALL ON - LOG_MERGED_STDOUTERR ON - LOG_OUTPUT_ON_FAILURE ON -) - -ExternalProject_Add(ogg - PREFIX ${CMAKE_CURRENT_BINARY_DIR} - DOWNLOAD_DIR ${ARCHIVE_DIR} - URL https://ftp.osuosl.org/pub/xiph/releases/ogg/libogg-1.3.3.tar.gz - URL_HASH SHA256=c2e8a485110b97550f453226ec644ebac6cb29d1caef2902c007edab4308d985 - PATCH_COMMAND cp ${patch_dir}/config.guess ${patch_dir}/config.sub ${CMAKE_CURRENT_BINARY_DIR}/src/ogg/ - CONFIGURE_COMMAND ${CMAKE_COMMAND} -E env ${envs} ${CMAKE_CURRENT_BINARY_DIR}/src/ogg/configure ${COMMON_ARGS} - DOWNLOAD_NO_PROGRESS ON - LOG_DOWNLOAD ON - LOG_UPDATE ON - LOG_CONFIGURE ON - LOG_BUILD ON - LOG_INSTALL ON - LOG_MERGED_STDOUTERR ON - LOG_OUTPUT_ON_FAILURE ON -) - -ExternalProject_Add(flac - PREFIX ${CMAKE_CURRENT_BINARY_DIR} - DEPENDS ogg - DOWNLOAD_DIR ${ARCHIVE_DIR} - URL https://ftp.osuosl.org/pub/xiph/releases/flac/flac-1.3.2.tar.xz - URL_HASH SHA256=91cfc3ed61dc40f47f050a109b08610667d73477af6ef36dcad31c31a4a8d53f - PATCH_COMMAND cp ${patch_dir}/config.guess ${patch_dir}/config.sub ${CMAKE_CURRENT_BINARY_DIR}/src/flac/ - CONFIGURE_COMMAND ${CMAKE_COMMAND} -E env ${envs} ${CMAKE_CURRENT_BINARY_DIR}/src/flac/configure ${COMMON_ARGS} --with-ogg --disable-cpplibs - DOWNLOAD_NO_PROGRESS ON - LOG_DOWNLOAD ON - LOG_UPDATE ON - LOG_CONFIGURE ON - LOG_BUILD ON - LOG_INSTALL ON - LOG_MERGED_STDOUTERR ON - LOG_OUTPUT_ON_FAILURE ON -) - -ExternalProject_Add(vorbis - PREFIX ${CMAKE_CURRENT_BINARY_DIR} - DEPENDS ogg - DOWNLOAD_DIR ${ARCHIVE_DIR} - URL https://ftp.osuosl.org/pub/xiph/releases/vorbis/libvorbis-1.3.6.tar.gz - URL_HASH SHA256=6ed40e0241089a42c48604dc00e362beee00036af2d8b3f46338031c9e0351cb - PATCH_COMMAND cp ${patch_dir}/config.guess ${patch_dir}/config.sub ${CMAKE_CURRENT_BINARY_DIR}/src/vorbis/ - CONFIGURE_COMMAND ${CMAKE_COMMAND} -E env ${envs} ${CMAKE_CURRENT_BINARY_DIR}/src/vorbis/configure ${COMMON_ARGS} --with-ogg - DOWNLOAD_NO_PROGRESS ON - LOG_DOWNLOAD ON - LOG_UPDATE ON - LOG_CONFIGURE ON - LOG_BUILD ON - LOG_INSTALL ON - LOG_MERGED_STDOUTERR ON - LOG_OUTPUT_ON_FAILURE ON -) - -ExternalProject_Add(opus - PREFIX ${CMAKE_CURRENT_BINARY_DIR} - DEPENDS ogg - DOWNLOAD_DIR ${ARCHIVE_DIR} - URL https://ftp.osuosl.org/pub/xiph/releases/opus/opus-1.3.1.tar.gz - URL_HASH SHA256=65b58e1e25b2a114157014736a3d9dfeaad8d41be1c8179866f144a2fb44ff9d - PATCH_COMMAND cp ${patch_dir}/config.guess ${patch_dir}/config.sub ${CMAKE_CURRENT_BINARY_DIR}/src/opus/ - CONFIGURE_COMMAND ${CMAKE_COMMAND} -E env ${envs} ${CMAKE_CURRENT_BINARY_DIR}/src/opus/configure ${COMMON_ARGS} --with-ogg - DOWNLOAD_NO_PROGRESS ON - LOG_DOWNLOAD ON - LOG_UPDATE ON - LOG_CONFIGURE ON - LOG_BUILD ON - LOG_INSTALL ON - LOG_MERGED_STDOUTERR ON - LOG_OUTPUT_ON_FAILURE ON -) - -ExternalProject_Add(opusfile - PREFIX ${CMAKE_CURRENT_BINARY_DIR} - DEPENDS opus - DOWNLOAD_DIR ${ARCHIVE_DIR} - URL https://ftp.osuosl.org/pub/xiph/releases/opus/opusfile-0.12.tar.gz - URL_HASH SHA256=118d8601c12dd6a44f52423e68ca9083cc9f2bfe72da7a8c1acb22a80ae3550b - PATCH_COMMAND cp ${patch_dir}/config.guess ${patch_dir}/config.sub ${CMAKE_CURRENT_BINARY_DIR}/src/opusfile/ - CONFIGURE_COMMAND ${CMAKE_COMMAND} -E env ${envs} ${CMAKE_CURRENT_BINARY_DIR}/src/opusfile/configure ${COMMON_ARGS} --disable-http - DOWNLOAD_NO_PROGRESS ON - LOG_DOWNLOAD ON - LOG_UPDATE ON - LOG_CONFIGURE ON - LOG_BUILD ON - LOG_INSTALL ON - LOG_MERGED_STDOUTERR ON - LOG_OUTPUT_ON_FAILURE ON -) - -# OpenMP is by default compiled against GNU OpenMP, which conflicts with the version of OpenMP that PyTorch uses. -# See https://github.com/pytorch/audio/pull/1026 -# TODO: Add flags like https://github.com/suphoff/pytorch_parallel_extension_cpp/blob/master/setup.py -set(SOX_OPTIONS - --disable-openmp - --with-amrnb - --with-amrwb - --with-flac - --with-lame - --with-oggvorbis - --with-opus - --without-alsa - --without-ao - --without-coreaudio - --without-oss - --without-id3tag - --without-ladspa - --without-mad - --without-magic - --without-png - --without-pulseaudio - --without-sndfile - --without-sndio - --without-sunaudio - --without-waveaudio - --without-wavpack - --without-twolame - ) - -set(SOX_LIBRARIES - ${INSTALL_DIR}/lib/libsox.a - ${INSTALL_DIR}/lib/libopencore-amrnb.a - ${INSTALL_DIR}/lib/libopencore-amrwb.a - ${INSTALL_DIR}/lib/libmp3lame.a - ${INSTALL_DIR}/lib/libFLAC.a - ${INSTALL_DIR}/lib/libopusfile.a - ${INSTALL_DIR}/lib/libopus.a - ${INSTALL_DIR}/lib/libvorbisenc.a - ${INSTALL_DIR}/lib/libvorbisfile.a - ${INSTALL_DIR}/lib/libvorbis.a - ${INSTALL_DIR}/lib/libogg.a - ) - -set(sox_depends - ogg flac vorbis opusfile lame amr - ) - -ExternalProject_Add(sox - PREFIX ${CMAKE_CURRENT_BINARY_DIR} - DEPENDS ${sox_depends} - DOWNLOAD_DIR ${ARCHIVE_DIR} - URL https://downloads.sourceforge.net/project/sox/sox/14.4.2/sox-14.4.2.tar.bz2 - URL_HASH SHA256=81a6956d4330e75b5827316e44ae381e6f1e8928003c6aa45896da9041ea149c - PATCH_COMMAND patch -p1 < ${patch_dir}/sox.patch && cp ${patch_dir}/config.guess ${patch_dir}/config.sub ${CMAKE_CURRENT_BINARY_DIR}/src/sox/ - CONFIGURE_COMMAND ${CMAKE_COMMAND} -E env ${envs} ${CMAKE_CURRENT_BINARY_DIR}/src/sox/configure ${COMMON_ARGS} ${SOX_OPTIONS} - BUILD_BYPRODUCTS ${SOX_LIBRARIES} - DOWNLOAD_NO_PROGRESS ON - LOG_DOWNLOAD ON - LOG_UPDATE ON - LOG_CONFIGURE ON - LOG_BUILD ON - LOG_INSTALL ON - LOG_MERGED_STDOUTERR ON - LOG_OUTPUT_ON_FAILURE ON -) - -add_library(libsox INTERFACE) -add_dependencies(libsox sox) -target_include_directories(libsox INTERFACE ${INSTALL_DIR}/include) -target_link_libraries(libsox INTERFACE ${SOX_LIBRARIES}) diff --git a/tools/setup_helpers/extension.py b/tools/setup_helpers/extension.py index 3eddef379cc..a37307b62fa 100644 --- a/tools/setup_helpers/extension.py +++ b/tools/setup_helpers/extension.py @@ -33,7 +33,7 @@ def _get_build(var, default=False): return False -_BUILD_SOX = False if platform.system() == "Windows" else _get_build("BUILD_SOX", True) +_USE_SOX = False if platform.system() == "Windows" else _get_build("USE_SOX", True) _BUILD_KALDI = False if platform.system() == "Windows" else _get_build("BUILD_KALDI", True) _BUILD_RNNT = _get_build("BUILD_RNNT", True) _BUILD_CTC_DECODER = _get_build("BUILD_CTC_DECODER", True) @@ -101,7 +101,7 @@ def build_extension(self, ext): f"-DCMAKE_INSTALL_PREFIX={extdir}", "-DCMAKE_VERBOSE_MAKEFILE=ON", f"-DPython_INCLUDE_DIR={distutils.sysconfig.get_python_inc()}", - f"-DBUILD_SOX:BOOL={'ON' if _BUILD_SOX else 'OFF'}", + f"-DUSE_SOX:BOOL={'ON' if _USE_SOX else 'OFF'}", f"-DBUILD_KALDI:BOOL={'ON' if _BUILD_KALDI else 'OFF'}", f"-DBUILD_RNNT:BOOL={'ON' if _BUILD_RNNT else 'OFF'}", f"-DBUILD_CTC_DECODER:BOOL={'ON' if _BUILD_CTC_DECODER else 'OFF'}", diff --git a/torchaudio/csrc/CMakeLists.txt b/torchaudio/csrc/CMakeLists.txt index ef8e9f0a7a1..ecd7570f60a 100644 --- a/torchaudio/csrc/CMakeLists.txt +++ b/torchaudio/csrc/CMakeLists.txt @@ -78,12 +78,8 @@ if(BUILD_KALDI) list(APPEND LIBTORCHAUDIO_COMPILE_DEFINITIONS INCLUDE_KALDI) endif() -if(BUILD_SOX) - list( - APPEND - LIBTORCHAUDIO_LINK_LIBRARIES - libsox - ) +if(USE_SOX) + find_package(SOX REQUIRED COMPONENTS sox) list( APPEND LIBTORCHAUDIO_SOURCES @@ -119,12 +115,11 @@ endif() #------------------------------------------------------------------------------# # END OF CUSTOMIZATION LOGICS #------------------------------------------------------------------------------# - torchaudio_library( libtorchaudio "${LIBTORCHAUDIO_SOURCES}" - "${LIBTORCHAUDIO_INCLUDE_DIRS}" - "${LIBTORCHAUDIO_LINK_LIBRARIES}" + "${LIBTORCHAUDIO_INCLUDE_DIRS};${SOX_INCLUDE_DIRS}" + "${LIBTORCHAUDIO_LINK_LIBRARIES};${SOX_LINK_LIBRARIES}" "${LIBTORCHAUDIO_COMPILE_DEFINITIONS}" ) @@ -178,7 +173,7 @@ if (BUILD_TORCHAUDIO_PYTHON_EXTENSION) #----------------------------------------------------------------------------# # START OF CUSTOMIZATION LOGICS #----------------------------------------------------------------------------# - if(BUILD_SOX) + if(USE_SOX) list( APPEND EXTENSION_SOURCES @@ -194,7 +189,7 @@ if (BUILD_TORCHAUDIO_PYTHON_EXTENSION) torchaudio_extension( _torchaudio "${EXTENSION_SOURCES}" - "" + "${SOX_INCLUDE_DIRS}" libtorchaudio "${LIBTORCHAUDIO_COMPILE_DEFINITIONS}" )