# Path: bob/bio/spear/test/test_preprocessors.py
# def _wav(filename="data/sample.wav"):
#     path = pkg_resources.resource_filename("bob.bio.spear.test", filename)
#     path, ext = os.path.splitext(path)
#     directory, path = os.path.split(path)
#     base_audiobiofile = bob.bio.spear.database.AudioBioFile(
#         "client_id", path, "file_id"
#     )
#     return base_audiobiofile.load(directory, ext)


import numpy
import pkg_resources
import bob.bio.base
import bob.bio.spear
from .test_preprocessors import _wav
    if regenerate_refs:
        write_function(data, reference)

    # compare reference
    reference = read_function(reference)
    assert numpy.allclose(data, reference, atol=1e-5)


def test_mfcc():
    # read input wave file
    wav = _wav()

    extractor = bob.bio.base.load_resource("mfcc-60", "extractor")
    assert isinstance(extractor, bob.bio.spear.extractor.Cepstral)

    # test the Cepstral extractor
    extractor = bob.bio.spear.extractor.Cepstral()
    # but we need to apply VAD first
    preprocessor = bob.bio.spear.preprocessor.Energy_2Gauss()
    preprocessed_data = preprocessor(wav)
    _compare(
        extractor(preprocessed_data),
        pkg_resources.resource_filename("bob.bio.spear.test", "data/mfcc_60.hdf5"),
        extractor.write_feature,
        extractor.read_feature,
    )


def test_lfcc():
    # read input wave file

# Path: bob/bio/spear/test/test_preprocessors.py
# def _wav(filename="data/sample.wav"):
#     path = pkg_resources.resource_filename("bob.bio.spear.test", filename)
#     path, ext = os.path.splitext(path)
#     directory, path = os.path.split(path)
#     base_audiobiofile = bob.bio.spear.database.AudioBioFile(
#         "client_id", path, "file_id"
#     )
#     return base_audiobiofile.load(directory, ext)


# Path: bob/bio/spear/test/test_extractors.py
import numpy
import pkg_resources
import bob.bio.base
import bob.bio.spear
from .test_preprocessors import _wav

    if regenerate_refs:
        write_function(data, reference)

    # compare reference
    reference = read_function(reference)
    assert numpy.allclose(data, reference, atol=1e-5)


def test_mfcc():
    # read input wave file
    wav = _wav()

    extractor = bob.bio.base.load_resource("mfcc-60", "extractor")
    assert isinstance(extractor, bob.bio.spear.extractor.Cepstral)

    # test the Cepstral extractor
    extractor = bob.bio.spear.extractor.Cepstral()
    # but we need to apply VAD first
    preprocessor = bob.bio.spear.preprocessor.Energy_2Gauss()
    preprocessed_data = preprocessor(wav)
    _compare(
        extractor(preprocessed_data),
        pkg_resources.resource_filename("bob.bio.spear.test", "data/mfcc_60.hdf5"),
        extractor.write_feature,
        extractor.read_feature,
    )


def test_lfcc():
    # read input wave file

    wav = _wav()