<commit_before>"""Testing module for the DSP package, preferably run with py.test."""
import logging

import librosa as lr
import soundfile as sf

from pysndfx.dsp import AudioEffectsChain

logger = logging.getLogger('pysndfx')
logger.setLevel(logging.DEBUG)

apply_audio_effects = \
    (AudioEffectsChain()
     .highshelf()
     .reverb()
     .phaser()
     .delay()
     .lowshelf())

infile = lr.util.example_audio_file()
mono, sr = lr.load(infile, sr=None)
stereo, _ = lr.load(infile, sr=None, mono=False)
outfile = 'test_output.ogg'


def test_file_to_file():
    apply_audio_effects(infile, outfile)
    y = lr.load(outfile, sr=None, mono=False)[0]
    sf.write('test_file_to_file.wav', y.T, sr)
    assert lr.util.valid_audio(y, mono=False)


def test_ndarray_to_ndarray():
    y = apply_audio_effects(mono)
    sf.write('test_ndarray_to_ndarray_mono.wav', y, sr)<commit_msg>Update test_dsp.py (#39)<commit_after>"""Testing module for the DSP package, preferably run with py.test."""
import logging

import librosa as lr
import soundfile as sf

from pysndfx.dsp import AudioEffectsChain

logger = logging.getLogger('pysndfx')
logger.setLevel(logging.DEBUG)

apply_audio_effects = \
    (AudioEffectsChain()
     .highshelf()
     .reverb()
     .phaser()
     .delay()
     .lowshelf())

infile = lr.util.example("brahms")
mono, sr = lr.load(infile, sr=None)
stereo, _ = lr.load(infile, sr=None, mono=False)
outfile = 'test_output.ogg'


def test_file_to_file():
    apply_audio_effects(infile, outfile)
    y = lr.load(outfile, sr=None, mono=False)[0]
    sf.write('test_file_to_file.wav', y.T, sr)
    assert lr.util.valid_audio(y, mono=False)


def test_ndarray_to_ndarray():
    y = apply_audio_effects(mono)
    sf.write('test_ndarray_to_ndarray_mono.wav', y, sr)
{'fraction_non_alphanumeric': 0.13160854893138357, 'fraction_numerical': 0.0022497187851518562, 'mean_word_length': 4.390909090909091, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '1022782', 'n_tokens_mistral': 716, 'n_tokens_neox': 675, 'n_words': 135}