prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  🚀 Feature Request: Opus audio format support
  ## 🚀 Feature
  <!-- -->
  Add opus format 
  ## Motivation
  
  <!-- Please outline the motivation for the proposal. Is your feature request related to a problem? e.g., I'm always frustrated when [...]. If this is related to another GitHub issue, please link here too -->
  Opus is a good and popular lossy audio coding format. A lot of audio files are stored in opus format but it's impossible to use it with torchaudio.load(). 
  ## Pitch
  
  <!-- A clear and concise description of what you want to happen. -->
  Please, make possible to do 
  audio = torchaudio.load("my_audio.opus")
  
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `build_tools/setup_helpers/extension.py`
  Content:
  ```
  1 import os
  2 import platform
  3 import subprocess
  4 from pathlib import Path
  5 
  6 from torch.utils.cpp_extension import (
  7     CppExtension,
  8     BuildExtension as TorchBuildExtension
  9 )
  10 
  11 __all__ = [
  12     'get_ext_modules',
  13     'BuildExtension',
  14 ]
  15 
  16 _THIS_DIR = Path(__file__).parent.resolve()
  17 _ROOT_DIR = _THIS_DIR.parent.parent.resolve()
  18 _CSRC_DIR = _ROOT_DIR / 'torchaudio' / 'csrc'
  19 _TP_BASE_DIR = _ROOT_DIR / 'third_party'
  20 _TP_INSTALL_DIR = _TP_BASE_DIR / 'install'
  21 
  22 
  23 def _get_build_sox():
  24     val = os.environ.get('BUILD_SOX', '0')
  25     trues = ['1', 'true', 'TRUE', 'on', 'ON', 'yes', 'YES']
  26     falses = ['0', 'false', 'FALSE', 'off', 'OFF', 'no', 'NO']
  27     if val in trues:
  28         return True
  29     if val not in falses:
  30         print(
  31             f'WARNING: Unexpected environment variable value `BUILD_SOX={val}`. '
  32             f'Expected one of {trues + falses}')
  33     return False
  34 
  35 
  36 _BUILD_SOX = _get_build_sox()
  37 
  38 
  39 def _get_eca(debug):
  40     eca = []
  41     if debug:
  42         eca += ["-O0", "-g"]
  43     else:
  44         eca += ["-O3"]
  45     return eca
  46 
  47 
  48 def _get_ela(debug):
  49     ela = []
  50     if debug:
  51         if platform.system() == "Windows":
  52             ela += ["/DEBUG:FULL"]
  53         else:
  54             ela += ["-O0", "-g"]
  55     else:
  56         ela += ["-O3"]
  57     return ela
  58 
  59 
  60 def _get_srcs():
  61     return [str(p) for p in _CSRC_DIR.glob('**/*.cpp')]
  62 
  63 
  64 def _get_include_dirs():
  65     dirs = [
  66         str(_ROOT_DIR),
  67     ]
  68     if _BUILD_SOX:
  69         dirs.append(str(_TP_INSTALL_DIR / 'include'))
  70     return dirs
  71 
  72 
  73 def _get_extra_objects():
  74     objs = []
  75     if _BUILD_SOX:
  76         # NOTE: The order of the library listed bellow matters.
  77         #
  78         # (the most important thing is that dependencies come after a library
  79         # e.g., sox comes first, flac/vorbis comes before ogg, and
  80         # vorbisenc/vorbisfile comes before vorbis
  81         libs = [
  82             'libsox.a',
  83             'libmad.a',
  84             'libFLAC.a',
  85             'libmp3lame.a',
  86             'libvorbisenc.a',
  87             'libvorbisfile.a',
  88             'libvorbis.a',
  89             'libogg.a',
  90         ]
  91         for lib in libs:
  92             objs.append(str(_TP_INSTALL_DIR / 'lib' / lib))
  93     return objs
  94 
  95 
  96 def _get_libraries():
  97     return [] if _BUILD_SOX else ['sox']
  98 
  99 
  100 def _build_third_party():
  101     build_dir = str(_TP_BASE_DIR / 'build')
  102     os.makedirs(build_dir, exist_ok=True)
  103     subprocess.run(
  104         args=['cmake', '..'],
  105         cwd=build_dir,
  106         check=True,
  107     )
  108     subprocess.run(
  109         args=['cmake', '--build', '.'],
  110         cwd=build_dir,
  111         check=True,
  112     )
  113 
  114 
  115 _EXT_NAME = 'torchaudio._torchaudio'
  116 
  117 
  118 def get_ext_modules(debug=False):
  119     if platform.system() == 'Windows':
  120         return None
  121     return [
  122         CppExtension(
  123             _EXT_NAME,
  124             _get_srcs(),
  125             libraries=_get_libraries(),
  126             include_dirs=_get_include_dirs(),
  127             extra_compile_args=_get_eca(debug),
  128             extra_objects=_get_extra_objects(),
  129             extra_link_args=_get_ela(debug),
  130         ),
  131     ]
  132 
  133 
  134 class BuildExtension(TorchBuildExtension):
  135     def build_extension(self, ext):
  136         if ext.name == _EXT_NAME and _BUILD_SOX:
  137             _build_third_party()
  138         super().build_extension(ext)
  139
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/build_tools/setup_helpers/extension.py b/build_tools/setup_helpers/extension.py
  --- a/build_tools/setup_helpers/extension.py
  +++ b/build_tools/setup_helpers/extension.py
  @@ -83,6 +83,8 @@
               'libmad.a',
               'libFLAC.a',
               'libmp3lame.a',
  +            'libopusfile.a',
  +            'libopus.a',
               'libvorbisenc.a',
               'libvorbisfile.a',
               'libvorbis.a',
  
verification_info: {"golden_diff": "diff --git a/build_tools/setup_helpers/extension.py b/build_tools/setup_helpers/extension.py\n--- a/build_tools/setup_helpers/extension.py\n+++ b/build_tools/setup_helpers/extension.py\n@@ -83,6 +83,8 @@\n             'libmad.a',\n             'libFLAC.a',\n             'libmp3lame.a',\n+            'libopusfile.a',\n+            'libopus.a',\n             'libvorbisenc.a',\n             'libvorbisfile.a',\n             'libvorbis.a',\n", "issue": "\ud83d\ude80 Feature Request: Opus audio format support\n## \ud83d\ude80 Feature\r\n<!-- -->\r\nAdd opus format \r\n## Motivation\r\n\r\n<!-- Please outline the motivation for the proposal. Is your feature request related to a problem? e.g., I'm always frustrated when [...]. If this is related to another GitHub issue, please link here too -->\r\nOpus is a good and popular lossy audio coding format. A lot of audio files are stored in opus format but it's impossible to use it with torchaudio.load(). \r\n## Pitch\r\n\r\n<!-- A clear and concise description of what you want to happen. -->\r\nPlease, make possible to do \r\naudio = torchaudio.load(\"my_audio.opus\")\r\n\n", "before_files": [{"content": "import os\nimport platform\nimport subprocess\nfrom pathlib import Path\n\nfrom torch.utils.cpp_extension import (\n    CppExtension,\n    BuildExtension as TorchBuildExtension\n)\n\n__all__ = [\n    'get_ext_modules',\n    'BuildExtension',\n]\n\n_THIS_DIR = Path(__file__).parent.resolve()\n_ROOT_DIR = _THIS_DIR.parent.parent.resolve()\n_CSRC_DIR = _ROOT_DIR / 'torchaudio' / 'csrc'\n_TP_BASE_DIR = _ROOT_DIR / 'third_party'\n_TP_INSTALL_DIR = _TP_BASE_DIR / 'install'\n\n\ndef _get_build_sox():\n    val = os.environ.get('BUILD_SOX', '0')\n    trues = ['1', 'true', 'TRUE', 'on', 'ON', 'yes', 'YES']\n    falses = ['0', 'false', 'FALSE', 'off', 'OFF', 'no', 'NO']\n    if val in trues:\n        return True\n    if val not in falses:\n        print(\n            f'WARNING: Unexpected environment variable value `BUILD_SOX={val}`. '\n            f'Expected one of {trues + falses}')\n    return False\n\n\n_BUILD_SOX = _get_build_sox()\n\n\ndef _get_eca(debug):\n    eca = []\n    if debug:\n        eca += [\"-O0\", \"-g\"]\n    else:\n        eca += [\"-O3\"]\n    return eca\n\n\ndef _get_ela(debug):\n    ela = []\n    if debug:\n        if platform.system() == \"Windows\":\n            ela += [\"/DEBUG:FULL\"]\n        else:\n            ela += [\"-O0\", \"-g\"]\n    else:\n        ela += [\"-O3\"]\n    return ela\n\n\ndef _get_srcs():\n    return [str(p) for p in _CSRC_DIR.glob('**/*.cpp')]\n\n\ndef _get_include_dirs():\n    dirs = [\n        str(_ROOT_DIR),\n    ]\n    if _BUILD_SOX:\n        dirs.append(str(_TP_INSTALL_DIR / 'include'))\n    return dirs\n\n\ndef _get_extra_objects():\n    objs = []\n    if _BUILD_SOX:\n        # NOTE: The order of the library listed bellow matters.\n        #\n        # (the most important thing is that dependencies come after a library\n        # e.g., sox comes first, flac/vorbis comes before ogg, and\n        # vorbisenc/vorbisfile comes before vorbis\n        libs = [\n            'libsox.a',\n            'libmad.a',\n            'libFLAC.a',\n            'libmp3lame.a',\n            'libvorbisenc.a',\n            'libvorbisfile.a',\n            'libvorbis.a',\n            'libogg.a',\n        ]\n        for lib in libs:\n            objs.append(str(_TP_INSTALL_DIR / 'lib' / lib))\n    return objs\n\n\ndef _get_libraries():\n    return [] if _BUILD_SOX else ['sox']\n\n\ndef _build_third_party():\n    build_dir = str(_TP_BASE_DIR / 'build')\n    os.makedirs(build_dir, exist_ok=True)\n    subprocess.run(\n        args=['cmake', '..'],\n        cwd=build_dir,\n        check=True,\n    )\n    subprocess.run(\n        args=['cmake', '--build', '.'],\n        cwd=build_dir,\n        check=True,\n    )\n\n\n_EXT_NAME = 'torchaudio._torchaudio'\n\n\ndef get_ext_modules(debug=False):\n    if platform.system() == 'Windows':\n        return None\n    return [\n        CppExtension(\n            _EXT_NAME,\n            _get_srcs(),\n            libraries=_get_libraries(),\n            include_dirs=_get_include_dirs(),\n            extra_compile_args=_get_eca(debug),\n            extra_objects=_get_extra_objects(),\n            extra_link_args=_get_ela(debug),\n        ),\n    ]\n\n\nclass BuildExtension(TorchBuildExtension):\n    def build_extension(self, ext):\n        if ext.name == _EXT_NAME and _BUILD_SOX:\n            _build_third_party()\n        super().build_extension(ext)\n", "path": "build_tools/setup_helpers/extension.py"}], "after_files": [{"content": "import os\nimport platform\nimport subprocess\nfrom pathlib import Path\n\nfrom torch.utils.cpp_extension import (\n    CppExtension,\n    BuildExtension as TorchBuildExtension\n)\n\n__all__ = [\n    'get_ext_modules',\n    'BuildExtension',\n]\n\n_THIS_DIR = Path(__file__).parent.resolve()\n_ROOT_DIR = _THIS_DIR.parent.parent.resolve()\n_CSRC_DIR = _ROOT_DIR / 'torchaudio' / 'csrc'\n_TP_BASE_DIR = _ROOT_DIR / 'third_party'\n_TP_INSTALL_DIR = _TP_BASE_DIR / 'install'\n\n\ndef _get_build_sox():\n    val = os.environ.get('BUILD_SOX', '0')\n    trues = ['1', 'true', 'TRUE', 'on', 'ON', 'yes', 'YES']\n    falses = ['0', 'false', 'FALSE', 'off', 'OFF', 'no', 'NO']\n    if val in trues:\n        return True\n    if val not in falses:\n        print(\n            f'WARNING: Unexpected environment variable value `BUILD_SOX={val}`. '\n            f'Expected one of {trues + falses}')\n    return False\n\n\n_BUILD_SOX = _get_build_sox()\n\n\ndef _get_eca(debug):\n    eca = []\n    if debug:\n        eca += [\"-O0\", \"-g\"]\n    else:\n        eca += [\"-O3\"]\n    return eca\n\n\ndef _get_ela(debug):\n    ela = []\n    if debug:\n        if platform.system() == \"Windows\":\n            ela += [\"/DEBUG:FULL\"]\n        else:\n            ela += [\"-O0\", \"-g\"]\n    else:\n        ela += [\"-O3\"]\n    return ela\n\n\ndef _get_srcs():\n    return [str(p) for p in _CSRC_DIR.glob('**/*.cpp')]\n\n\ndef _get_include_dirs():\n    dirs = [\n        str(_ROOT_DIR),\n    ]\n    if _BUILD_SOX:\n        dirs.append(str(_TP_INSTALL_DIR / 'include'))\n    return dirs\n\n\ndef _get_extra_objects():\n    objs = []\n    if _BUILD_SOX:\n        # NOTE: The order of the library listed bellow matters.\n        #\n        # (the most important thing is that dependencies come after a library\n        # e.g., sox comes first, flac/vorbis comes before ogg, and\n        # vorbisenc/vorbisfile comes before vorbis\n        libs = [\n            'libsox.a',\n            'libmad.a',\n            'libFLAC.a',\n            'libmp3lame.a',\n            'libopusfile.a',\n            'libopus.a',\n            'libvorbisenc.a',\n            'libvorbisfile.a',\n            'libvorbis.a',\n            'libogg.a',\n        ]\n        for lib in libs:\n            objs.append(str(_TP_INSTALL_DIR / 'lib' / lib))\n    return objs\n\n\ndef _get_libraries():\n    return [] if _BUILD_SOX else ['sox']\n\n\ndef _build_third_party():\n    build_dir = str(_TP_BASE_DIR / 'build')\n    os.makedirs(build_dir, exist_ok=True)\n    subprocess.run(\n        args=['cmake', '..'],\n        cwd=build_dir,\n        check=True,\n    )\n    subprocess.run(\n        args=['cmake', '--build', '.'],\n        cwd=build_dir,\n        check=True,\n    )\n\n\n_EXT_NAME = 'torchaudio._torchaudio'\n\n\ndef get_ext_modules(debug=False):\n    if platform.system() == 'Windows':\n        return None\n    return [\n        CppExtension(\n            _EXT_NAME,\n            _get_srcs(),\n            libraries=_get_libraries(),\n            include_dirs=_get_include_dirs(),\n            extra_compile_args=_get_eca(debug),\n            extra_objects=_get_extra_objects(),\n            extra_link_args=_get_ela(debug),\n        ),\n    ]\n\n\nclass BuildExtension(TorchBuildExtension):\n    def build_extension(self, ext):\n        if ext.name == _EXT_NAME and _BUILD_SOX:\n            _build_third_party()\n        super().build_extension(ext)\n", "path": "build_tools/setup_helpers/extension.py"}]}