예제 #1
0
def test_process_track():
    @raises(AssertionError)
    def __process_track_wrong_names(file_struct):
        E.process_track(file_struct, None, None, None)

    @raises(NoReferencesError)
    def __process_track_no_refs(file_struct):
        E.process_track(file_struct, None, None, None)

    def __process_track_correct(file_struct, bounds_id, labels_id, config):
        res = E.process_track(file_struct, bounds_id, labels_id, config)
        assert "HitRate_3F" in res.keys()

    # Wrong match
    no_match_fs = FileStruct("udontexist.mp3")
    no_match_fs.ref_file = "idontexist.mp3"
    yield (__process_track_wrong_names, no_match_fs)

    # No References
    no_ref_fs = FileStruct("udontexist.mp3")
    no_ref_fs.ref_file = "udontexist.jams"
    yield (__process_track_no_refs, no_ref_fs)

    # Correct
    audio_path = "fixtures/Sargon_test/audio/Mindless_cut.mp3"
    correct_fs = FileStruct(audio_path)
    config = {"hier": False}
    yield (__process_track_correct, correct_fs, "sf", None, config)
    yield (__process_track_correct, audio_path, "sf", None, config)
예제 #2
0
파일: test_eval.py 프로젝트: wangsix/msaf
def test_process_track():
    @raises(AssertionError)
    def __process_track_wrong_names(file_struct):
        E.process_track(file_struct, None, None, None)

    @raises(NoReferencesError)
    def __process_track_no_refs(file_struct):
        E.process_track(file_struct, None, None, None)

    def __process_track_correct(file_struct, bounds_id, labels_id, config):
        res = E.process_track(file_struct, bounds_id, labels_id, config)
        assert "HitRate_3F" in res.keys()

    # Wrong match
    no_match_fs = FileStruct("udontexist.mp3")
    no_match_fs.ref_file = "idontexist.mp3"
    yield (__process_track_wrong_names, no_match_fs)

    # No References
    no_ref_fs = FileStruct("udontexist.mp3")
    no_ref_fs.ref_file = "udontexist.jams"
    yield (__process_track_no_refs, no_ref_fs)

    # Correct
    audio_path = "fixtures/Sargon_test/audio/Mindless_cut.mp3"
    correct_fs = FileStruct(audio_path)
    config = {"hier": False}
    yield (__process_track_correct, correct_fs, "sf", None, config)
    yield (__process_track_correct, audio_path, "sf", None, config)
예제 #3
0
def test_read_ann_beats_old_jams():
    """Trying to read an old jams file."""
    my_file_struct = FileStruct(os.path.join("fixtures", "chirp.mp3"))
    my_file_struct.ref_file = os.path.join("fixtures", "old_jams.jams")
    pcp = PCP(my_file_struct, FeatureTypes.ann_beatsync, sr=11025)
    times, frames = pcp.read_ann_beats()
    assert times is None
    assert frames is None
예제 #4
0
def test_read_ann_beats_old_jams():
    """Trying to read an old jams file."""
    my_file_struct = FileStruct(os.path.join("fixtures", "chirp.mp3"))
    my_file_struct.ref_file = os.path.join("fixtures", "old_jams.jams")
    pcp = PCP(my_file_struct, FeatureTypes.ann_beatsync, sr=11025)
    times, frames = pcp.read_ann_beats()
    assert times is None
    assert frames is None
예제 #5
0
from nose.tools import raises
import numpy as np
import os

# Msaf imports
import msaf
from msaf.base import FeatureTypes
from msaf.exceptions import (NoAudioFileError, FeatureParamsError,
                             FeatureTypeNotFound)
from msaf.features import CQT, PCP, Tonnetz, MFCC, Tempogram
from msaf.input_output import FileStruct

# Global vars
audio_file = os.path.join("fixtures", "chirp.mp3")
file_struct = FileStruct(audio_file)
file_struct.ref_file = os.path.join("fixtures", "chirp.jams")
msaf.utils.ensure_dir("features")
features_file = os.path.join("features", "chirp.json")
file_struct.features_file = features_file
try:
    os.remove(features_file)
except OSError:
    pass


def test_registry():
    """All the features should be in the features register."""
    assert(CQT.get_id() in msaf.base.features_registry.keys())
    assert(PCP.get_id() in msaf.base.features_registry.keys())
    assert(Tonnetz.get_id() in msaf.base.features_registry.keys())
    assert(MFCC.get_id() in msaf.base.features_registry.keys())
예제 #6
0
def test_frame_times_no_annotations():
    """Checking frame times when there are no beat annotations."""
    my_file_struct = FileStruct(os.path.join("fixtures", "chirp.mp3"))
    my_file_struct.ref_file = os.path.join("fixtures", "old_jams.jams")
    pcp = PCP(my_file_struct, FeatureTypes.ann_beatsync, sr=11025)
    pcp.frame_times
예제 #7
0
def test_frame_times_old_jams():
    """Trying to use invalid jams file."""
    my_file_struct = FileStruct(os.path.join("fixtures", "chirp.mp3"))
    my_file_struct.ref_file = os.path.join("fixtures", "old_jams.jams")
    pcp = PCP(my_file_struct, FeatureTypes.ann_beatsync, sr=11025)
    pcp.frame_times
예제 #8
0
def test_frame_times_no_annotations():
    """Checking frame times when there are no beat annotations."""
    my_file_struct = FileStruct(os.path.join("fixtures", "chirp.mp3"))
    my_file_struct.ref_file = os.path.join("fixtures", "old_jams.jams")
    pcp = PCP(my_file_struct, FeatureTypes.ann_beatsync, sr=11025)
    pcp.frame_times
예제 #9
0
def test_frame_times_old_jams():
    """Trying to use invalid jams file."""
    my_file_struct = FileStruct(os.path.join("fixtures", "chirp.mp3"))
    my_file_struct.ref_file = os.path.join("fixtures", "old_jams.jams")
    pcp = PCP(my_file_struct, FeatureTypes.ann_beatsync, sr=11025)
    pcp.frame_times
예제 #10
0
from nose.tools import raises
import numpy as np
import os

# Msaf imports
import msaf
from msaf.base import FeatureTypes
from msaf.exceptions import (NoAudioFileError, FeatureParamsError,
                             FeatureTypeNotFound)
from msaf.features import CQT, PCP, Tonnetz, MFCC, Tempogram, Features
from msaf.input_output import FileStruct

# Global vars
audio_file = os.path.join("fixtures", "chirp.mp3")
file_struct = FileStruct(audio_file)
file_struct.ref_file = os.path.join("fixtures", "chirp.jams")
msaf.utils.ensure_dir("features")
features_file = os.path.join("features", "chirp.json")
file_struct.features_file = features_file
try:
    os.remove(features_file)
except OSError:
    pass


def test_registry():
    """All the features should be in the features register."""
    assert(CQT.get_id() in msaf.base.features_registry.keys())
    assert(PCP.get_id() in msaf.base.features_registry.keys())
    assert(Tonnetz.get_id() in msaf.base.features_registry.keys())
    assert(MFCC.get_id() in msaf.base.features_registry.keys())