Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 3 additions & 9 deletions torchaudio/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,17 @@
SignalInfo,
EncodingInfo,
)
from torchaudio._internal import (
module_utils as _mod_utils,
misc_ops as _misc_ops,
from torchaudio.sox_effects import (
init_sox_effects as initialize_sox,
shutdown_sox_effects as shutdown_sox,
)
from torchaudio.sox_effects import initialize_sox, shutdown_sox

try:
from .version import __version__, git_version # noqa: F401
except ImportError:
pass


if _mod_utils.is_module_available('torchaudio._torchaudio'):
from . import _torchaudio
initialize_sox()


def load(filepath: Union[str, Path],
out: Optional[Tensor] = None,
normalization: Union[bool, float, Callable] = True,
Expand Down
12 changes: 12 additions & 0 deletions torchaudio/sox_effects/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from torchaudio._internal import module_utils as _mod_utils
from .sox_effects import (
init_sox_effects,
shutdown_sox_effects,
effect_names,
SoxEffect,
SoxEffectsChain,
)


if _mod_utils.is_module_available('torchaudio._torchaudio'):
init_sox_effects()
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from typing import Any, Callable, List, Optional, Tuple, Union

import torch
import torchaudio
from torch import Tensor

from torchaudio._internal import (
Expand All @@ -11,7 +10,7 @@
)

if _mod_utils.is_module_available('torchaudio._torchaudio'):
from . import _torchaudio
from torchaudio import _torchaudio
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: that's a separate issue :)



_SOX_INITIALIZED: Optional[bool] = False
Expand All @@ -26,7 +25,7 @@


@_mod_utils.requires_module('torchaudio._torchaudio')
def initialize_sox() -> int:
def init_sox_effects() -> int:
"""Initialize sox for use with effects chains.

You only need to call this function once to use SoX effects chains multiple times.
Expand All @@ -48,13 +47,13 @@ def initialize_sox() -> int:
code = _torchaudio.initialize_sox()
if code == _SOX_SUCCESS_CODE:
_SOX_INITIALIZED = True
atexit.register(shutdown_sox)
atexit.register(shutdown_sox_effects)
return code
return _SOX_SUCCESS_CODE


@_mod_utils.requires_module("torchaudio._torchaudio")
def shutdown_sox() -> int:
def shutdown_sox_effects() -> int:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's BC breaking, no? torchaudio.sox_effects.initialize_sox()

Copy link
Contributor

@vincentqb vincentqb Jun 10, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I saw that torchaudio.shutdown_sox() still works as you re-import correctly above. However, users could have been doing torchaudio.sox_effects.shutdown_sox() which would now be torchaudio.sox_effects.shutdown_sox_effects(), right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah if the user adopts torchaudio.sox_effects.shutdown_sox() which introduced only a couple of days ago.
I do not see that a problem but if you insist, I can simply add [BC braking] tag to commit.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh right, since it wasn't part of a release, we don't need to worry about this then.

"""Showdown sox for effects chain.

You do not need to call this function as it will be called automatically
Expand Down