def test_analyze_flacfile_(self):
        dic = {
            'fingerprint':
            "b'AQAAIkqYSUoWRcKDLwmH5hqFlkR-JP2D_6isw0xIJagl4"
            "MieQ6UeBecuvNmhRT-qLcN5nMP_Qst18GGHSwtShYfzo8-D"
            "H0_koVaUEL7mouWN2AeEgDIICCKEJYwIgRAQDFgDCDAAOAM"
            "UcAgBogA'",
            'fingerprint_uuid':
            '6aaf1de2-5c42-56cf-a981-eaab1928ead6',
            'duration':
            '6.8s'
        }

        analyzer = acoustid_analyzer.SoundAnalyzer()
        uri = os.path.join(os.path.dirname(__file__),
                           '../../peragro-test-files/audio/flac/dubstep.flac')
        file_descr = analyzer.analyze(uri)
        assert file_descr, "something went wrong while analysing dubstep.flac"
        # print(file_descr)
        metadata_dic = {}
        for asset in file_descr.assets:
            for key, value in asset.metadata.items():
                ty, val = utilities.get_metadatavalue_type(value)
                metadata_dic[key] = val
        assert metadata_dic == dic, \
            "Analyzed values are not equal to the expected ones"
    def test_analyze_oggfile_(self):
        dic = {
            'fingerprint':
            "b'AQAAIkqYSUoWRcJzfEmI5hqFlkR-JP2D_2hiHU9IJagl4"
            "MieQ6UeBecuvNnR6IemLcN5nMP_orkO6WGHJ1qQjnD-oc-D"
            "H0_koVaUEL5mtDxiH6QQUAYBQYQwljAiBEJAMGANIMAAYIA"
            "CDiFAFA'",
            'fingerprint_uuid':
            'cad37087-ed51-5b4f-ad0c-76a414acf26f',
            'duration':
            '6.8s'
        }

        analyzer = acoustid_analyzer.SoundAnalyzer()
        uri = os.path.join(os.path.dirname(__file__),
                           '../../peragro-test-files/audio/ogg/dubstep.ogg')
        file_descr = analyzer.analyze(uri)
        assert file_descr, "something went wrong while analysing dubstep.ogg"
        # print(file_descr)
        metadata_dic = {}
        for asset in file_descr.assets:
            for key, value in asset.metadata.items():
                ty, val = utilities.get_metadatavalue_type(value)
                metadata_dic[key] = val
        assert metadata_dic == dic, \
            "Analyzed values are not equal to the expected ones"
    def test_analyze_wavfile_(self):
        dic = {
            'fingerprint':
            "b'AQAAZImSbZqiLXDwKDSOC2JV9LiiHEcvCIcPHHYKHcd5-"
            "Bry4UyCH4aPnhV-fMnx7EbZH1POI8d_8KaDPPOMS0YlmGlw"
            "5oQPZj4ClXfAHlqHMDi-Hd98fGjCDomi9ELIi4ErYjru6Ao"
            "6Tjv8o5KU6cJ3XD8azajMHE_-4TiO8PtgLoPyIFNRbUNv3A"
            "jXgxeuHG-OWvkx5e3x4Bd0HblQTcFL4xyND_8JdC3yQ0f-o"
            "OOJn_guC9_xo1ZOAKOcEIYBB0QRxgAAmAKEKuCAQQAwihwQ"
            "ChFCCBAMCQXAIQQIpBAwCDhAFBCecCAIo4wgAhAhgDiGiGE"
            "CMCAEI-hgBQACxhEhAA'",
            'fingerprint_uuid':
            'd6b5ffe5-a332-554c-8a68-56eae6f9fbfe',
            'duration':
            '15.0044375s'
        }

        analyzer = acoustid_analyzer.SoundAnalyzer()
        uri = os.path.join(os.path.dirname(__file__),
                           '../../peragro-test-files/audio/wav/test.wav')
        file_descr = analyzer.analyze(uri)
        assert file_descr, "something went wrong while analysing test.wav"
        # print(file_descr)
        metadata_dic = {}
        for asset in file_descr.assets:
            for key, value in asset.metadata.items():
                ty, val = utilities.get_metadatavalue_type(value)
                metadata_dic[key] = val
        assert metadata_dic == dic, \
            "Analyzed values are not equal to the expected ones"
    def test_analyze_mp3file_(self):
        dic = {'tonal_atonal': 'atonal', 'bpm': '128',
               'timbre': 'bright', 'mood_happy': 'not_happy',
               'genre_dortmund': 'electronic', 'gender': 'female',
               'mood_party': 'not_party', 'beats_count': '526.0',
               'mood_sad': 'not_sad', 'mood_aggressive': 'not_aggressive',
               'genre_electronic': 'trance', 'mood_relaxed': 'not_relaxed',
               'voice_instrumental': 'voice', 'average_loudness': '0.977689087391',
               'lossless': 'False', 'mood_acoustic': 'not_acoustic',
               'moods_mirex': 'Cluster5', 'chord': 'C major',
               'ismir04_rhythm': 'ChaChaCha', 'mood_electronic': 'electronic',
               'key': 'E major', 'genre_tzanetakis': 'jaz',
               'danceability': 'danceable', 'genre_rosamerica': 'rhy'}

        analyzer = feature_extraction.SoundAnalyzer()
        uri = os.path.join(os.path.dirname(__file__),
                           '../../peragro-test-files/audio/mp3/test.mp3')
        file_descr = analyzer.analyze(uri)
        assert file_descr, "something went wrong while analysing test.mp3"
        # metadata_dic = {}
        for asset in file_descr.assets:
            for key, value in asset.metadata.items():
                ty, val = utilities.get_metadatavalue_type(value)
                # metadata_dic[key] = val
                assert dic[key] == val, \
                    "Analyzed value for key:%s is %s which is not equal " \
                    "to the expected one (%s)" % (key, val, dic[key])
    def test_analyze_wavfile_(self):
        dic = {'beats_count': '25.0', 'mood_acoustic': 'acoustic',
               'mood_party': 'not_party', 'moods_mirex': 'Cluster3',
               'lossless': 'True', 'danceability': 'not_danceable',
               'mood_aggressive': 'not_aggressive', 'key': 'F# minor',
               'gender': 'male', 'chord': 'C# minor',
               'voice_instrumental': 'instrumental', 'genre_tzanetakis': 'hip',
               'tonal_atonal': 'tonal', 'mood_happy': 'not_happy',
               'bpm': '95', 'mood_relaxed': 'relaxed',
               'genre_electronic': 'ambient', 'average_loudness': '0.909014284611',
               'genre_dortmund': 'alternative', 'mood_sad': 'sad',
               'mood_electronic': 'not_electronic', 'ismir04_rhythm': 'Waltz',
               'genre_rosamerica': 'cla', 'timbre': 'dark'}

        analyzer = feature_extraction.SoundAnalyzer()
        uri = os.path.join(os.path.dirname(__file__),
                           '../../peragro-test-files/audio/wav/test.wav')
        file_descr = analyzer.analyze(uri)
        assert file_descr, "something went wrong while analysing test.wav"
        # metadata_dic = {}
        for asset in file_descr.assets:
            for key, value in asset.metadata.items():
                ty, val = utilities.get_metadatavalue_type(value)
                # metadata_dic[key] = val
                assert dic[key] == val, \
                    "Analyzed value for key:%s is %s which is not equal " \
                    "to the expected one (%s)" % (key, val, dic[key])
    def test_analyze_oggfile_(self):
        dic = {'tonal_atonal': 'atonal', 'bpm': '139',
               'timbre': 'dark', 'mood_happy': 'happy',
               'genre_dortmund': 'raphiphop', 'gender': 'female',
               'mood_party': 'not_party', 'beats_count': '15.0',
               'mood_sad': 'not_sad', 'mood_aggressive': 'not_aggressive',
               'genre_electronic': 'dnb', 'mood_relaxed': 'relaxed',
               'voice_instrumental': 'instrumental', 'average_loudness': '0.982675015926',
               'lossless': 'True', 'mood_acoustic': 'not_acoustic',
               'moods_mirex': 'Cluster5', 'chord': 'E major',
               'ismir04_rhythm': 'Samba', 'mood_electronic': 'electronic',
               'key': 'G# minor', 'genre_tzanetakis': 'jaz',
               'danceability': 'not_danceable', 'genre_rosamerica': 'hip'}

        analyzer = feature_extraction.SoundAnalyzer()
        uri = os.path.join(os.path.dirname(__file__),
                           '../../peragro-test-files/audio/flac/dubstep.flac')
        file_descr = analyzer.analyze(uri)
        assert file_descr, "something went wrong while analysing dubstep.flac"
        # metadata_dic = {}
        for asset in file_descr.assets:
            for key, value in asset.metadata.items():
                ty, val = utilities.get_metadatavalue_type(value)
                # metadata_dic[key] = val
                assert dic[key] == val, \
                    "Analyzed value for key:%s is %s which is not equal " \
                    "to the expected one (%s)" % (key, val, dic[key])
Exemple #7
0
    def test_analyze_plain_text(self):
        dic = {'charset': "us-ascii", 'lines': '6'}

        uri = os.path.join(os.path.dirname(__file__),
                           '../../peragro-test-files/text/plain/test.txt')
        analyzer = analyzertext.GenericTextAnalyzer()
        file_descr = analyzer.analyze(uri)
        assert file_descr, "something went wrong while analysing test.test"
        # print(file_descr)
        metadata_dic = {}
        for asset in file_descr.assets:
            for key, value in asset.metadata.items():
                ty, val = utilities.get_metadatavalue_type(value)
                metadata_dic[key] = val
        assert metadata_dic == dic, \
            "Analyzed values are not equal to the expected ones"