<commit_before>"""
The effect functions do not augment an AudioSignal object, but rather 
return a FFmpegFilter or a SoXFilter, which may be called on either a sox.transform.Transformer
or a python-ffmpeg stream, depending on the specific effect. To apply the effect on an AudioSignal, 
apply_effect_sox or apply_effect_ffmpeg must be called with the AudioSignal, and a list of
SoXFilters or FFmpegFilters, respectively. 

>>> import nussl.effects
>>> tremolo_filter = effects.tremolo(5, .7)
>>> new_signal = effects.apply_effect_ffmpeg(audio_signal, [tremolo_filter])

Because of this schema, and the requirement that caller must know which effect is a SoX effect
or a FFmpeg effect, we recommend that all users use the AudioSignal hooks for applying effects
rather than calling any functions in this library. 

This line is equivalent to the above snippet

>>> new_signal = audio_signal.tremolo(5, .7).apply_effect()

See also: the associated data augmentation tutorial.
"""

import numpy as np
import warnings
import ffmpeg
import tempfile
import soxbindings as sox

from .constants import LEVEL_MIN, LEVEL_MAX
from .utils import _close_temp_files

class FilterFunction:
    """
    The FilterFunction class is an abstract class for functions that take 
    audio processing streams, such as ffmpeg-python and pysndfx
    """

    def __call__(self, stream):
        return self.func(stream)
<commit_msg>optional sox import<commit_after>"""
The effect functions do not augment an AudioSignal object, but rather 
return a FFmpegFilter or a SoXFilter, which may be called on either a sox.transform.Transformer
or a python-ffmpeg stream, depending on the specific effect. To apply the effect on an AudioSignal, 
apply_effect_sox or apply_effect_ffmpeg must be called with the AudioSignal, and a list of
SoXFilters or FFmpegFilters, respectively. 

>>> import nussl.effects
>>> tremolo_filter = effects.tremolo(5, .7)
>>> new_signal = effects.apply_effect_ffmpeg(audio_signal, [tremolo_filter])

Because of this schema, and the requirement that caller must know which effect is a SoX effect
or a FFmpeg effect, we recommend that all users use the AudioSignal hooks for applying effects
rather than calling any functions in this library. 

This line is equivalent to the above snippet

>>> new_signal = audio_signal.tremolo(5, .7).apply_effect()

See also: the associated data augmentation tutorial.
"""

import numpy as np
import warnings
import ffmpeg
import tempfile
try:
    import soxbindings as sox
except ImportError:
    import sox

from .constants import LEVEL_MIN, LEVEL_MAX
from .utils import _close_temp_files

class FilterFunction:
    """
    The FilterFunction class is an abstract class for functions that take 
    audio processing streams, such as ffmpeg-python and pysndfx
    """

    def __call__(self, stream):
        return self.func(stream)

{'fraction_non_alphanumeric': 0.055865921787709494, 'fraction_numerical': 0.002793296089385475, 'mean_word_length': 4.66205533596838, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4700390', 'n_tokens_mistral': 816, 'n_tokens_neox': 799, 'n_words': 357}