Commit 1706a72f authored by moto's avatar moto Committed by Facebook GitHub Bot
Browse files

Extract libsox integration from libtorchaudio (#2929)

Summary:
This commit makes the following changes to the C++ library organization
- Move sox-related feature implementations from `libtorchaudio` to `libtorchaudio_sox`.
- Remove C++ implementation of `is_sox_available` and `is_ffmpeg_available` as it is now sufficient to check the existence of `libtorchaudio_sox` and `libtorchaudio_ffmpeg` to check the availability. This makes `libtorchaudio_sox` and `libtorchaudio_ffmpeg` independent from `libtorchaudio`.
- Move PyBind11-based bindings (`_torchaudio_sox`, `_torchaudio_ffmpeg`) into `torchaudio.lib` so that the built library structure is less cluttered.

Background:
Originally, when the `libsox` was the only C++ extension and `libtorchaudio` was supposed to contain all the C++ code.
The things are different now. We have a bunch of C++ extensions and we need to make the code/build structure more modular.

The new `libtorchaudio_sox` contains the implementations and `_torchaudio_sox` contains the PyBin11-based bindings.

Pull Request resolved: https://github.com/pytorch/audio/pull/2929

Reviewed By: hwangjeff

Differential Revision: D42159594

Pulled By: mthrok

fbshipit-source-id: 1a0fbca9e4143137f6363fc001b2378ce6029aa7
parent c6bc65fd
...@@ -52,8 +52,8 @@ if (BUILD_TORCHAUDIO_PYTHON_EXTENSION) ...@@ -52,8 +52,8 @@ if (BUILD_TORCHAUDIO_PYTHON_EXTENSION)
endif() endif()
install( install(
TARGETS ${name} TARGETS ${name}
LIBRARY DESTINATION . LIBRARY DESTINATION lib
RUNTIME DESTINATION . # For Windows RUNTIME DESTINATION lib # For Windows
) )
endfunction() endfunction()
endif() endif()
...@@ -325,7 +325,7 @@ class TestLoadParams(TempDirMixin, PytorchTestCase): ...@@ -325,7 +325,7 @@ class TestLoadParams(TempDirMixin, PytorchTestCase):
# test file-like obj # test file-like obj
def func(path, *args): def func(path, *args):
with open(path, "rb") as fileobj: with open(path, "rb") as fileobj:
return torchaudio._torchaudio.load_audio_fileobj(fileobj, *args) return torchaudio.lib._torchaudio_sox.load_audio_fileobj(fileobj, *args)
self._test(func, frame_offset, num_frames, channels_first, normalize) self._test(func, frame_offset, num_frames, channels_first, normalize)
......
...@@ -47,21 +47,28 @@ _TORCH_CUDA_ARCH_LIST = os.environ.get("TORCH_CUDA_ARCH_LIST", None) ...@@ -47,21 +47,28 @@ _TORCH_CUDA_ARCH_LIST = os.environ.get("TORCH_CUDA_ARCH_LIST", None)
def get_ext_modules(): def get_ext_modules():
modules = [ modules = [
Extension(name="torchaudio.lib.libtorchaudio", sources=[]), Extension(name="torchaudio.lib.libtorchaudio", sources=[]),
Extension(name="torchaudio._torchaudio", sources=[]), Extension(name="torchaudio.lib._torchaudio", sources=[]),
] ]
if _BUILD_SOX:
modules.extend(
[
Extension(name="torchaudio.lib.libtorchaudio_sox", sources=[]),
Extension(name="torchaudio.lib._torchaudio_sox", sources=[]),
]
)
if _BUILD_CTC_DECODER: if _BUILD_CTC_DECODER:
modules.extend( modules.extend(
[ [
Extension(name="torchaudio.lib.libflashlight-text", sources=[]), Extension(name="torchaudio.lib.libflashlight-text", sources=[]),
Extension(name="torchaudio.flashlight_lib_text_decoder", sources=[]), Extension(name="torchaudio.lib.flashlight_lib_text_decoder", sources=[]),
Extension(name="torchaudio.flashlight_lib_text_dictionary", sources=[]), Extension(name="torchaudio.lib.flashlight_lib_text_dictionary", sources=[]),
] ]
) )
if _USE_FFMPEG: if _USE_FFMPEG:
modules.extend( modules.extend(
[ [
Extension(name="torchaudio.lib.libtorchaudio_ffmpeg", sources=[]), Extension(name="torchaudio.lib.libtorchaudio_ffmpeg", sources=[]),
Extension(name="torchaudio._torchaudio_ffmpeg", sources=[]), Extension(name="torchaudio.lib._torchaudio_ffmpeg", sources=[]),
] ]
) )
return modules return modules
...@@ -84,10 +91,16 @@ class CMakeBuild(build_ext): ...@@ -84,10 +91,16 @@ class CMakeBuild(build_ext):
# However, the following `cmake` command will build all of them at the same time, # However, the following `cmake` command will build all of them at the same time,
# so, we do not need to perform `cmake` twice. # so, we do not need to perform `cmake` twice.
# Therefore we call `cmake` only for `torchaudio._torchaudio`. # Therefore we call `cmake` only for `torchaudio._torchaudio`.
if ext.name != "torchaudio._torchaudio": if ext.name != "torchaudio.lib.libtorchaudio":
return return
extdir = os.path.abspath(os.path.dirname(self.get_ext_fullpath(ext.name))) # Note:
# the last part "lib" does not really matter. We want to get the full path of
# the root build directory. Passing "torchaudio" will be interpreted as
# `torchaudio.[so|dylib|pyd]`, so we need something `torchaudio.foo`, that is
# interpreted as `torchaudio/foo.so` then use dirname to get the `torchaudio`
# directory.
extdir = os.path.abspath(os.path.dirname(self.get_ext_fullpath("torchaudio.lib")))
# required for auto-detection of auxiliary "native" libs # required for auto-detection of auxiliary "native" libs
if not extdir.endswith(os.path.sep): if not extdir.endswith(os.path.sep):
......
import logging
import os import os
import sys import sys
import warnings
from pathlib import Path from pathlib import Path
import torch import torch
from torchaudio._internal import module_utils as _mod_utils # noqa: F401
from torchaudio._internal.module_utils import is_module_available
_LIB_DIR = Path(__file__).parent / "lib" _LIB_DIR = Path(__file__).parent / "lib"
_LG = logging.getLogger(__name__)
def _get_lib_path(lib: str): def _get_lib_path(lib: str):
suffix = "pyd" if os.name == "nt" else "so" suffix = "pyd" if os.name == "nt" else "so"
...@@ -62,7 +65,7 @@ def _init_ffmpeg(): ...@@ -62,7 +65,7 @@ def _init_ffmpeg():
if _FFMPEG_INITIALIZED: if _FFMPEG_INITIALIZED:
return return
if not torch.ops.torchaudio.is_ffmpeg_available(): if not is_module_available("torchaudio.lib._torchaudio_ffmpeg"):
raise RuntimeError( raise RuntimeError(
"torchaudio is not compiled with FFmpeg integration. Please set USE_FFMPEG=1 when compiling torchaudio." "torchaudio is not compiled with FFmpeg integration. Please set USE_FFMPEG=1 when compiling torchaudio."
) )
...@@ -72,7 +75,7 @@ def _init_ffmpeg(): ...@@ -72,7 +75,7 @@ def _init_ffmpeg():
except OSError as err: except OSError as err:
raise ImportError("FFmpeg libraries are not found. Please install FFmpeg.") from err raise ImportError("FFmpeg libraries are not found. Please install FFmpeg.") from err
import torchaudio._torchaudio_ffmpeg # noqa import torchaudio.lib._torchaudio_ffmpeg # noqa
torch.ops.torchaudio.ffmpeg_init() torch.ops.torchaudio.ffmpeg_init()
if torch.ops.torchaudio.ffmpeg_get_log_level() > 8: if torch.ops.torchaudio.ffmpeg_get_log_level() > 8:
...@@ -82,10 +85,6 @@ def _init_ffmpeg(): ...@@ -82,10 +85,6 @@ def _init_ffmpeg():
def _init_extension(): def _init_extension():
if not _mod_utils.is_module_available("torchaudio._torchaudio"):
warnings.warn("torchaudio C++ extension is not available.")
return
# On Windows Python-3.8+ has `os.add_dll_directory` call, # On Windows Python-3.8+ has `os.add_dll_directory` call,
# which is called to configure dll search path. # which is called to configure dll search path.
# To find cuda related dlls we need to make sure the # To find cuda related dlls we need to make sure the
...@@ -102,19 +101,27 @@ def _init_extension(): ...@@ -102,19 +101,27 @@ def _init_extension():
except Exception: except Exception:
pass pass
_load_lib("libtorchaudio") if is_module_available("torchaudio.lib._torchaudio"):
# This import is for initializing the methods registered via PyBind11 try:
# This has to happen after the base library is loaded _load_lib("libtorchaudio")
from torchaudio import _torchaudio # noqa import torchaudio.lib._torchaudio # noqa
except Exception:
_LG.debug("Failed to initialize libtorchaudio", exc_info=True)
if is_module_available("torchaudio.lib._torchaudio_sox"):
try:
_load_lib("libtorchaudio_sox")
import torchaudio.lib._torchaudio_sox # noqa
except Exception:
_LG.debug("Failed to initialize libsox bindings", exc_info=True)
# Because this part is executed as part of `import torchaudio`, we ignore the
# initialization failure.
# If the FFmpeg integration is not properly initialized, then detailed error # If the FFmpeg integration is not properly initialized, then detailed error
# will be raised when client code attempts to import the dedicated feature. # will be raised when client code attempts to import the dedicated feature.
try: if is_module_available("torchaudio.lib._torchaudio_ffmpeg"):
_init_ffmpeg() try:
except Exception: _init_ffmpeg()
pass except Exception:
_LG.debug("Failed to initialize ffmpeg bindings", exc_info=True)
def _check_cuda_version(): def _check_cuda_version():
......
...@@ -67,7 +67,10 @@ def deprecated(direction: str, version: Optional[str] = None): ...@@ -67,7 +67,10 @@ def deprecated(direction: str, version: Optional[str] = None):
def is_kaldi_available(): def is_kaldi_available():
return is_module_available("torchaudio._torchaudio") and torch.ops.torchaudio.is_kaldi_available() try:
return torch.ops.torchaudio.is_kaldi_available()
except Exception:
return False
def requires_kaldi(): def requires_kaldi():
...@@ -126,7 +129,7 @@ def requires_soundfile(): ...@@ -126,7 +129,7 @@ def requires_soundfile():
def is_sox_available(): def is_sox_available():
return is_module_available("torchaudio._torchaudio") and torch.ops.torchaudio.is_sox_available() return is_module_available("torchaudio.lib._torchaudio_sox")
def requires_sox(): def requires_sox():
......
...@@ -95,7 +95,7 @@ def info( ...@@ -95,7 +95,7 @@ def info(
buffer_size = get_buffer_size() buffer_size = get_buffer_size()
if format == "mp3": if format == "mp3":
return _fallback_info_fileobj(filepath, format, buffer_size) return _fallback_info_fileobj(filepath, format, buffer_size)
sinfo = torchaudio._torchaudio.get_info_fileobj(filepath, format) sinfo = torchaudio.lib._torchaudio_sox.get_info_fileobj(filepath, format)
if sinfo is not None: if sinfo is not None:
return AudioMetaData(*sinfo) return AudioMetaData(*sinfo)
return _fallback_info_fileobj(filepath, format, buffer_size) return _fallback_info_fileobj(filepath, format, buffer_size)
...@@ -223,7 +223,7 @@ def load( ...@@ -223,7 +223,7 @@ def load(
format, format,
buffer_size, buffer_size,
) )
ret = torchaudio._torchaudio.load_audio_fileobj( ret = torchaudio.lib._torchaudio_sox.load_audio_fileobj(
filepath, frame_offset, num_frames, normalize, channels_first, format filepath, frame_offset, num_frames, normalize, channels_first, format
) )
if ret is not None: if ret is not None:
...@@ -403,7 +403,7 @@ def save( ...@@ -403,7 +403,7 @@ def save(
""" """
if not torch.jit.is_scripting(): if not torch.jit.is_scripting():
if hasattr(filepath, "write"): if hasattr(filepath, "write"):
torchaudio._torchaudio.save_audio_fileobj( torchaudio.lib._torchaudio_sox.save_audio_fileobj(
filepath, filepath,
src, src,
sample_rate, sample_rate,
......
...@@ -78,28 +78,6 @@ if(BUILD_KALDI) ...@@ -78,28 +78,6 @@ if(BUILD_KALDI)
list(APPEND LIBTORCHAUDIO_COMPILE_DEFINITIONS INCLUDE_KALDI) list(APPEND LIBTORCHAUDIO_COMPILE_DEFINITIONS INCLUDE_KALDI)
endif() endif()
if(BUILD_SOX)
list(
APPEND
LIBTORCHAUDIO_LINK_LIBRARIES
libsox
)
list(
APPEND
LIBTORCHAUDIO_SOURCES
sox/io.cpp
sox/utils.cpp
sox/effects.cpp
sox/effects_chain.cpp
sox/types.cpp
)
list(
APPEND
LIBTORCHAUDIO_COMPILE_DEFINITIONS
INCLUDE_SOX
)
endif()
if(OpenMP_CXX_FOUND) if(OpenMP_CXX_FOUND)
list( list(
APPEND APPEND
...@@ -108,14 +86,6 @@ if(OpenMP_CXX_FOUND) ...@@ -108,14 +86,6 @@ if(OpenMP_CXX_FOUND)
) )
endif() endif()
if(USE_FFMPEG)
list(
APPEND
LIBTORCHAUDIO_COMPILE_DEFINITIONS
USE_FFMPEG
)
endif()
#------------------------------------------------------------------------------# #------------------------------------------------------------------------------#
# END OF CUSTOMIZATION LOGICS # END OF CUSTOMIZATION LOGICS
#------------------------------------------------------------------------------# #------------------------------------------------------------------------------#
...@@ -134,6 +104,27 @@ else() ...@@ -134,6 +104,27 @@ else()
set(TORCHAUDIO_LIBRARY -Wl,--no-as-needed libtorchaudio -Wl,--as-needed CACHE INTERNAL "") set(TORCHAUDIO_LIBRARY -Wl,--no-as-needed libtorchaudio -Wl,--as-needed CACHE INTERNAL "")
endif() endif()
################################################################################
# libtorchaudio_sox
################################################################################
if (BUILD_SOX)
set(
libtorchaudio_sox_sources
sox/io.cpp
sox/utils.cpp
sox/effects.cpp
sox/effects_chain.cpp
sox/types.cpp
)
torchaudio_library(
libtorchaudio_sox
"${libtorchaudio_sox_sources}"
"${LIBTORCHAUDIO_INCLUDE_DIRS}"
"torch;libsox"
"${LIBTORCHAUDIO_COMPILE_DEFINITIONS}"
)
endif()
################################################################################ ################################################################################
# libtorchaudio_ffmpeg # libtorchaudio_ffmpeg
################################################################################ ################################################################################
...@@ -167,37 +158,37 @@ if(USE_FFMPEG) ...@@ -167,37 +158,37 @@ if(USE_FFMPEG)
endif() endif()
################################################################################ ################################################################################
# TODO: Rename this to _torchaudio_sox.so # Python extensions
# _torchaudio.so
################################################################################ ################################################################################
if (BUILD_TORCHAUDIO_PYTHON_EXTENSION) if (BUILD_TORCHAUDIO_PYTHON_EXTENSION)
set( set(
EXTENSION_SOURCES extension_sources
sox/pybind/pybind.cpp pybind/pybind.cpp
)
torchaudio_extension(
_torchaudio
"${extension_sources}"
""
"libtorchaudio"
""
) )
#----------------------------------------------------------------------------#
# START OF CUSTOMIZATION LOGICS
#----------------------------------------------------------------------------#
if(BUILD_SOX) if(BUILD_SOX)
list( set(
APPEND sox_extension_sources
EXTENSION_SOURCES sox/pybind/pybind.cpp
sox/pybind/effects.cpp sox/pybind/effects.cpp
sox/pybind/effects_chain.cpp sox/pybind/effects_chain.cpp
sox/pybind/io.cpp sox/pybind/io.cpp
sox/pybind/utils.cpp sox/pybind/utils.cpp
) )
torchaudio_extension(
_torchaudio_sox
"${sox_extension_sources}"
""
"libtorchaudio_sox"
""
)
endif() endif()
#----------------------------------------------------------------------------#
# END OF CUSTOMIZATION LOGICS
#----------------------------------------------------------------------------#
torchaudio_extension(
_torchaudio
"${EXTENSION_SOURCES}"
""
libtorchaudio
"${LIBTORCHAUDIO_COMPILE_DEFINITIONS}"
)
if(USE_FFMPEG) if(USE_FFMPEG)
set( set(
FFMPEG_EXTENSION_SOURCES FFMPEG_EXTENSION_SOURCES
......
#include <torch/extension.h>
#include <torchaudio/csrc/utils.h>
namespace torchaudio {
namespace {
// Note
// These functions are not intended for a real usecase.
// They are accessible via TorchBind.
// It is beneficial to have _torchaudio that is linked to libtorchaudio,
// when torchaudio is deployed with PEX format, where the library location
// is not in torchaudio/lib. But somewhere in LD_LIBRARY_PATH.
// In this case, attempt to import _torchaudio will automatically resolves
// libtorchaudio, if _torchaudio is linked to libtorchaudio.
PYBIND11_MODULE(_torchaudio, m) {
m.def("is_kaldi_available", &is_kaldi_available, "");
m.def("cuda_version", &cuda_version, "");
}
} // namespace
} // namespace torchaudio
#include <torch/extension.h> #include <torch/extension.h>
#ifdef INCLUDE_SOX
#include <torchaudio/csrc/sox/pybind/effects.h> #include <torchaudio/csrc/sox/pybind/effects.h>
#include <torchaudio/csrc/sox/pybind/io.h> #include <torchaudio/csrc/sox/pybind/io.h>
#endif
PYBIND11_MODULE(_torchaudio, m) { PYBIND11_MODULE(_torchaudio_sox, m) {
#ifdef INCLUDE_SOX
m.def( m.def(
"get_info_fileobj", "get_info_fileobj",
&torchaudio::sox_io::get_info_fileobj, &torchaudio::sox_io::get_info_fileobj,
...@@ -23,5 +20,4 @@ PYBIND11_MODULE(_torchaudio, m) { ...@@ -23,5 +20,4 @@ PYBIND11_MODULE(_torchaudio, m) {
"apply_effects_fileobj", "apply_effects_fileobj",
&torchaudio::sox_effects::apply_effects_fileobj, &torchaudio::sox_effects::apply_effects_fileobj,
"Decode audio data from file-like obj and apply effects."); "Decode audio data from file-like obj and apply effects.");
#endif
} }
#include <torch/script.h> #include <torch/script.h>
#include <torchaudio/csrc/utils.h>
#ifdef USE_CUDA #ifdef USE_CUDA
#include <cuda.h> #include <cuda.h>
...@@ -6,16 +7,6 @@ ...@@ -6,16 +7,6 @@
namespace torchaudio { namespace torchaudio {
namespace {
bool is_sox_available() {
#ifdef INCLUDE_SOX
return true;
#else
return false;
#endif
}
bool is_kaldi_available() { bool is_kaldi_available() {
#ifdef INCLUDE_KALDI #ifdef INCLUDE_KALDI
return true; return true;
...@@ -24,16 +15,6 @@ bool is_kaldi_available() { ...@@ -24,16 +15,6 @@ bool is_kaldi_available() {
#endif #endif
} }
// It tells whether torchaudio was compiled with ffmpeg
// not the runtime availability.
bool is_ffmpeg_available() {
#ifdef USE_FFMPEG
return true;
#else
return false;
#endif
}
c10::optional<int64_t> cuda_version() { c10::optional<int64_t> cuda_version() {
#ifdef USE_CUDA #ifdef USE_CUDA
return CUDA_VERSION; return CUDA_VERSION;
...@@ -41,14 +22,11 @@ c10::optional<int64_t> cuda_version() { ...@@ -41,14 +22,11 @@ c10::optional<int64_t> cuda_version() {
return {}; return {};
#endif #endif
} }
namespace {
} // namespace
TORCH_LIBRARY_FRAGMENT(torchaudio, m) { TORCH_LIBRARY_FRAGMENT(torchaudio, m) {
m.def("torchaudio::is_sox_available", &is_sox_available);
m.def("torchaudio::is_kaldi_available", &is_kaldi_available); m.def("torchaudio::is_kaldi_available", &is_kaldi_available);
m.def("torchaudio::is_ffmpeg_available", &is_ffmpeg_available);
m.def("torchaudio::cuda_version", &cuda_version); m.def("torchaudio::cuda_version", &cuda_version);
} }
} // namespace
} // namespace torchaudio } // namespace torchaudio
#pragma once
#include <torch/torch.h>
namespace torchaudio {
bool is_kaldi_available();
c10::optional<int64_t> cuda_version();
} // namespace torchaudio
...@@ -38,7 +38,7 @@ def info_audio_fileobj( ...@@ -38,7 +38,7 @@ def info_audio_fileobj(
format: Optional[str], format: Optional[str],
buffer_size: int = 4096, buffer_size: int = 4096,
) -> AudioMetaData: ) -> AudioMetaData:
s = torchaudio._torchaudio_ffmpeg.StreamReaderFileObj(src, format, None, buffer_size) s = torchaudio.lib._torchaudio_ffmpeg.StreamReaderFileObj(src, format, None, buffer_size)
return _info_audio(s) return _info_audio(s)
...@@ -113,5 +113,5 @@ def load_audio_fileobj( ...@@ -113,5 +113,5 @@ def load_audio_fileobj(
format: Optional[str] = None, format: Optional[str] = None,
buffer_size: int = 4096, buffer_size: int = 4096,
) -> Tuple[torch.Tensor, int]: ) -> Tuple[torch.Tensor, int]:
s = torchaudio._torchaudio_ffmpeg.StreamReaderFileObj(src, format, None, buffer_size) s = torchaudio.lib._torchaudio_ffmpeg.StreamReaderFileObj(src, format, None, buffer_size)
return _load_audio(s, frame_offset, num_frames, convert, channels_first) return _load_audio(s, frame_offset, num_frames, convert, channels_first)
...@@ -361,7 +361,7 @@ class StreamReader: ...@@ -361,7 +361,7 @@ class StreamReader:
elif isinstance(src, torch.Tensor): elif isinstance(src, torch.Tensor):
self._be = torch.classes.torchaudio.ffmpeg_StreamReaderTensor(src, format, option, buffer_size) self._be = torch.classes.torchaudio.ffmpeg_StreamReaderTensor(src, format, option, buffer_size)
elif hasattr(src, "read"): elif hasattr(src, "read"):
self._be = torchaudio._torchaudio_ffmpeg.StreamReaderFileObj(src, format, option, buffer_size) self._be = torchaudio.lib._torchaudio_ffmpeg.StreamReaderFileObj(src, format, option, buffer_size)
else: else:
raise ValueError("`src` must be either string, Tensor or file-like object.") raise ValueError("`src` must be either string, Tensor or file-like object.")
......
...@@ -108,7 +108,7 @@ class StreamWriter: ...@@ -108,7 +108,7 @@ class StreamWriter:
if isinstance(dst, str): if isinstance(dst, str):
self._s = torch.classes.torchaudio.ffmpeg_StreamWriter(dst, format) self._s = torch.classes.torchaudio.ffmpeg_StreamWriter(dst, format)
elif hasattr(dst, "write"): elif hasattr(dst, "write"):
self._s = torchaudio._torchaudio_ffmpeg.StreamWriterFileObj(dst, format, buffer_size) self._s = torchaudio.lib._torchaudio_ffmpeg.StreamWriterFileObj(dst, format, buffer_size)
else: else:
raise ValueError("`dst` must be either a string or a file-like object.") raise ValueError("`dst` must be either a string or a file-like object.")
self._is_open = False self._is_open = False
......
...@@ -33,7 +33,7 @@ try: ...@@ -33,7 +33,7 @@ try:
) )
except Exception: except Exception:
torchaudio._extension._load_lib("libflashlight-text") torchaudio._extension._load_lib("libflashlight-text")
from torchaudio.flashlight_lib_text_decoder import ( from torchaudio.lib.flashlight_lib_text_decoder import (
CriterionType as _CriterionType, CriterionType as _CriterionType,
KenLM as _KenLM, KenLM as _KenLM,
LexiconDecoder as _LexiconDecoder, LexiconDecoder as _LexiconDecoder,
...@@ -46,7 +46,7 @@ except Exception: ...@@ -46,7 +46,7 @@ except Exception:
Trie as _Trie, Trie as _Trie,
ZeroLM as _ZeroLM, ZeroLM as _ZeroLM,
) )
from torchaudio.flashlight_lib_text_dictionary import ( from torchaudio.lib.flashlight_lib_text_dictionary import (
create_word_dict as _create_word_dict, create_word_dict as _create_word_dict,
Dictionary as _Dictionary, Dictionary as _Dictionary,
load_words as _load_words, load_words as _load_words,
......
...@@ -274,7 +274,7 @@ def apply_effects_file( ...@@ -274,7 +274,7 @@ def apply_effects_file(
""" """
if not torch.jit.is_scripting(): if not torch.jit.is_scripting():
if hasattr(path, "read"): if hasattr(path, "read"):
ret = torchaudio._torchaudio.apply_effects_fileobj(path, effects, normalize, channels_first, format) ret = torchaudio.lib._torchaudio_sox.apply_effects_fileobj(path, effects, normalize, channels_first, format)
if ret is None: if ret is None:
raise RuntimeError("Failed to load audio from {}".format(path)) raise RuntimeError("Failed to load audio from {}".format(path))
return ret return ret
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment