示例#1
0
def test_metadata():
    metadata_1 = {
        'duration': 1.5,
        'artist': 'Meatloaf',
        'title': 'Le ciel est blue',
        'favourite_color': 'rainbow',
    }

    jam_1 = jams_utils.jams_converter(lyrics_data=[(None, None)], metadata=metadata_1)

    assert jam_1['file_metadata']['title'] == 'Le ciel est blue'
    assert jam_1['file_metadata']['artist'] == 'Meatloaf'
    assert jam_1['file_metadata']['duration'] == 1.5
    assert jam_1['sandbox']['favourite_color'] == 'rainbow'

    # test meatadata value None
    metadata_2 = {
        'duration': 1.5,
        'artist': 'breakmaster cylinder',
        'title': None,
        'extra': None,
    }
    jam2 = jams_utils.jams_converter(metadata=metadata_2)
    assert jam2.validate()
    assert jam2['file_metadata']['duration'] == 1.5
    assert jam2['file_metadata']['artist'] == 'breakmaster cylinder'
    assert jam2['file_metadata']['title'] == ''
    assert 'extra' not in jam2['sandbox']
示例#2
0
def test_metadata():
    metadata_1 = {
        "duration": 1.5,
        "artist": "Meatloaf",
        "title": "Le ciel est blue",
        "favourite_color": "rainbow",
    }

    jam_1 = jams_utils.jams_converter(lyrics_data=[(None, None)], metadata=metadata_1)

    assert jam_1["file_metadata"]["title"] == "Le ciel est blue"
    assert jam_1["file_metadata"]["artist"] == "Meatloaf"
    assert jam_1["file_metadata"]["duration"] == 1.5
    assert jam_1["sandbox"]["favourite_color"] == "rainbow"

    # test meatadata value None
    metadata_2 = {
        "duration": 1.5,
        "artist": "breakmaster cylinder",
        "title": None,
        "extra": None,
    }
    jam2 = jams_utils.jams_converter(metadata=metadata_2)
    assert jam2.validate()
    assert jam2["file_metadata"]["duration"] == 1.5
    assert jam2["file_metadata"]["artist"] == "breakmaster cylinder"
    assert jam2["file_metadata"]["title"] == ""
    assert "extra" not in jam2["sandbox"]
示例#3
0
def test_tags():
    tag_data1 = [('blues', 'I am a description')]
    tag_data2 = [('disco', 'tag 1'), ('rock', 'tag 2')]
    tag_data3 = [('invalid', 'asdf')]
    tag_data4 = ('jazz', 'wrong format')
    tag_data5 = ['wrong format too']
    tag_data6 = [(123, 'asdf')]
    jam1 = jams_utils.jams_converter(
        tags_gtzan_data=tag_data1, metadata={'duration': 10.0}
    )
    assert jam1.validate()
    jam2 = jams_utils.jams_converter(
        tags_gtzan_data=tag_data2, metadata={'duration': 10.0}
    )
    assert jam2.validate()
    jam3 = jams_utils.jams_converter(
        tags_gtzan_data=tag_data3, metadata={'duration': 10.0}
    )
    with pytest.raises(jams.SchemaError):
        assert jam3.validate()
    with pytest.raises(TypeError):
        jams_utils.jams_converter(tags_gtzan_data=tag_data4)
    with pytest.raises(TypeError):
        jams_utils.jams_converter(tags_gtzan_data=tag_data5)
    with pytest.raises(TypeError):
        jams_utils.jams_converter(tags_gtzan_data=tag_data6)
示例#4
0
def test_tempos():
    tempo_data1 = [(120, "I am a description")]
    tempo_data2 = [(120.0, "tempo 1"), (240, "tempo 2")]
    tempo_data3 = [(-1, "asdf")]
    tempo_data4 = (120.5, "wrong format")
    tempo_data5 = ["wrong format too"]
    tempo_data6 = [("string!", "string!")]
    jam1 = jams_utils.jams_converter(
        tempo_data=tempo_data1, metadata={"duration": 10.0}
    )
    assert jam1.validate()
    jam2 = jams_utils.jams_converter(
        tempo_data=tempo_data2, metadata={"duration": 10.0}
    )
    assert jam2.validate()
    jam3 = jams_utils.jams_converter(
        tempo_data=tempo_data3, metadata={"duration": 10.0}
    )
    with pytest.raises(jams.SchemaError):
        assert jam3.validate()
    with pytest.raises(TypeError):
        jams_utils.jams_converter(tempo_data=tempo_data4)
    with pytest.raises(TypeError):
        jams_utils.jams_converter(tempo_data=tempo_data5)
    with pytest.raises(TypeError):
        jams_utils.jams_converter(tempo_data=tempo_data6)
示例#5
0
def test_tempos():
    tempo_data1 = [(120, 'I am a description')]
    tempo_data2 = [(120.0, 'tempo 1'), (240, 'tempo 2')]
    tempo_data3 = [(-1, 'asdf')]
    tempo_data4 = (120.5, 'wrong format')
    tempo_data5 = ['wrong format too']
    tempo_data6 = [('string!', 'string!')]
    jam1 = jams_utils.jams_converter(
        tempo_data=tempo_data1, metadata={'duration': 10.0}
    )
    assert jam1.validate()
    jam2 = jams_utils.jams_converter(
        tempo_data=tempo_data2, metadata={'duration': 10.0}
    )
    assert jam2.validate()
    jam3 = jams_utils.jams_converter(
        tempo_data=tempo_data3, metadata={'duration': 10.0}
    )
    with pytest.raises(jams.SchemaError):
        assert jam3.validate()
    with pytest.raises(TypeError):
        jams_utils.jams_converter(tempo_data=tempo_data4)
    with pytest.raises(TypeError):
        jams_utils.jams_converter(tempo_data=tempo_data5)
    with pytest.raises(TypeError):
        jams_utils.jams_converter(tempo_data=tempo_data6)
示例#6
0
def test_tags():
    tag_data1 = [("blues", "I am a description")]
    tag_data2 = [("disco", "tag 1"), ("rock", "tag 2")]
    tag_data3 = [("invalid", "asdf")]
    tag_data4 = ("jazz", "wrong format")
    tag_data5 = ["wrong format too"]
    tag_data6 = [(123, "asdf")]
    jam1 = jams_utils.jams_converter(
        tags_gtzan_data=tag_data1, metadata={"duration": 10.0}
    )
    assert jam1.validate()
    jam2 = jams_utils.jams_converter(
        tags_gtzan_data=tag_data2, metadata={"duration": 10.0}
    )
    assert jam2.validate()
    jam3 = jams_utils.jams_converter(
        tags_gtzan_data=tag_data3, metadata={"duration": 10.0}
    )
    with pytest.raises(jams.SchemaError):
        assert jam3.validate()
    with pytest.raises(TypeError):
        jams_utils.jams_converter(tags_gtzan_data=tag_data4)
    with pytest.raises(TypeError):
        jams_utils.jams_converter(tags_gtzan_data=tag_data5)
    with pytest.raises(TypeError):
        jams_utils.jams_converter(tags_gtzan_data=tag_data6)
示例#7
0
def test_events():
    event_data1 = [
        (
            utils.EventData(
                np.array([0.2, 0.3]),
                np.array([0.3, 0.4]),
                np.array(["event A", "event B"]),
            ),
            "I am a description",
        )
    ]
    event_data2 = [
        (
            utils.EventData(
                np.array([0.2, 0.3]), np.array([0.4, 0.5]), np.array([2, "event B"])
            ),
            "events 1",
        ),
        (
            utils.EventData(
                np.array([0.2, 0.3]),
                np.array([0.3, 0.4]),
                np.array([{"a": 1, 2: "b"}, "a great label"]),
            ),
            "events 2",
        ),
    ]
    event_data3 = [
        (
            utils.EventData(
                np.array([20, 30]),  # invalid because > duration
                np.array([0.3, 0.4]),
                np.array([{"a": 1, 2: "b"}, "a great label"]),
            ),
            "asdf",
        )
    ]
    event_data4 = ("jazz", "wrong format")
    event_data5 = ["wrong format too"]
    event_data6 = [("wrong", "description")]
    jam1 = jams_utils.jams_converter(
        event_data=event_data1, metadata={"duration": 10.0}
    )
    assert jam1.validate()
    jam2 = jams_utils.jams_converter(
        event_data=event_data2, metadata={"duration": 10.0}
    )
    assert jam2.validate()
    jam3 = jams_utils.jams_converter(
        event_data=event_data3, metadata={"duration": 10.0}
    )
    with pytest.raises(jams.SchemaError):
        assert jam3.validate()
    with pytest.raises(TypeError):
        jams_utils.jams_converter(event_data=event_data4)
    with pytest.raises(TypeError):
        jams_utils.jams_converter(event_data=event_data5)
    with pytest.raises(TypeError):
        jams_utils.jams_converter(event_data=event_data6)
示例#8
0
def test_events():
    event_data1 = [
        (
            utils.EventData(
                np.array([0.2, 0.3]),
                np.array([0.3, 0.4]),
                np.array(['event A', 'event B']),
            ),
            'I am a description',
        )
    ]
    event_data2 = [
        (
            utils.EventData(
                np.array([0.2, 0.3]), np.array([0.4, 0.5]), np.array([2, 'event B'])
            ),
            'events 1',
        ),
        (
            utils.EventData(
                np.array([0.2, 0.3]),
                np.array([0.3, 0.4]),
                np.array([{'a': 1, 2: 'b'}, 'a great label']),
            ),
            'events 2',
        ),
    ]
    event_data3 = [
        (
            utils.EventData(
                np.array([20, 30]),  # invalid because > duration
                np.array([0.3, 0.4]),
                np.array([{'a': 1, 2: 'b'}, 'a great label']),
            ),
            'asdf',
        )
    ]
    event_data4 = ('jazz', 'wrong format')
    event_data5 = ['wrong format too']
    event_data6 = [('wrong', 'description')]
    jam1 = jams_utils.jams_converter(
        event_data=event_data1, metadata={'duration': 10.0}
    )
    assert jam1.validate()
    jam2 = jams_utils.jams_converter(
        event_data=event_data2, metadata={'duration': 10.0}
    )
    assert jam2.validate()
    jam3 = jams_utils.jams_converter(
        event_data=event_data3, metadata={'duration': 10.0}
    )
    with pytest.raises(jams.SchemaError):
        assert jam3.validate()
    with pytest.raises(TypeError):
        jams_utils.jams_converter(event_data=event_data4)
    with pytest.raises(TypeError):
        jams_utils.jams_converter(event_data=event_data5)
    with pytest.raises(TypeError):
        jams_utils.jams_converter(event_data=event_data6)
示例#9
0
def test_events():
    event_data1 = [
        (
            annotations.EventData(
                np.array([[0.2, 0.3], [0.3, 0.4]]),
                ["event A", "event B"],
            ),
            "I am a description",
        )
    ]
    event_data2 = [
        (
            annotations.EventData(np.array([[0.2, 0.3], [0.3, 0.4]]), ["2", "event B"]),
            "events 1",
        ),
        (
            annotations.EventData(
                np.array([[0.2, 0.3], [0.3, 0.4]]),
                ["", "a great label"],
            ),
            "events 2",
        ),
    ]
    event_data3 = [
        (
            annotations.EventData(
                np.array([[0.2, 0.3], [0.3, 20.0]]),  # invalid because > duration
                ["", "a great label"],
            ),
            "asdf",
        )
    ]
    event_data4 = ("jazz", "wrong format")
    event_data5 = ["wrong format too"]
    event_data6 = [("wrong", "description")]
    jam1 = jams_utils.jams_converter(
        event_data=event_data1, metadata={"duration": 10.0}
    )
    assert jam1.validate()
    jam2 = jams_utils.jams_converter(
        event_data=event_data2, metadata={"duration": 10.0}
    )

    jam3 = jams_utils.jams_converter(
        event_data=event_data3, metadata={"duration": 10.0}
    )

    with pytest.raises(TypeError):
        jams_utils.jams_converter(event_data=event_data4)
    with pytest.raises(TypeError):
        jams_utils.jams_converter(event_data=event_data5)
    with pytest.raises(TypeError):
        jams_utils.jams_converter(event_data=event_data6)
示例#10
0
 def to_jams(self):
     """Jams: the track's data in jams format"""
     return jams_utils.jams_converter(
         audio_path=self.audio_path,
         tags_open_data=[(self.stroke_name, "stroke_name")],
         metadata={"tonic": self.tonic},
     )
示例#11
0
 def to_jams(self):
     """Jams: the track's data in jams format"""
     return jams_utils.jams_converter(
         audio_path=self.audio_path,
         annotation_data=[(self.annotation, None)],
         metadata=self._metadata,
     )
示例#12
0
 def to_jams(self):
     return jams_utils.jams_converter(
         beat_data=[(self.beats, None)],
         section_data=[(self.sections, None)],
         chord_data=[(self.chords, None)],
         metadata=self._track_metadata,
     )
示例#13
0
    def to_jams(self):
        """Get the track's data in jams format

        Returns:
            jams.JAMS: the track's data in jams format

        """
        return jams_utils.jams_converter(
            audio_path=self.audio_path,
            multi_section_data=[
                (
                    [
                        (self.sections_annotator_1_uppercase, 0),
                        (self.sections_annotator_1_lowercase, 1),
                    ],
                    "annotator_1",
                ),
                (
                    [
                        (self.sections_annotator_2_uppercase, 0),
                        (self.sections_annotator_2_lowercase, 1),
                    ],
                    "annotator_2",
                ),
            ],
            metadata=self._track_metadata,
        )
示例#14
0
 def to_jams(self):
     """Jams: the track's data in jams format"""
     return jams_utils.jams_converter(
         audio_path=self.audio_path_mono,
         f0_data=[(self.melody, "annotated melody")],
         metadata=self._track_metadata,
     )
示例#15
0
 def to_jams(self):
     """Jams: the track's data in jams format"""
     return jams_utils.jams_converter(
         beat_data=[(self.beats, None)],
         section_data=[(self.sections, None)],
         metadata=self._track_metadata,
     )
示例#16
0
 def to_jams(self):
     """Jams: the track's data in jams format"""
     return jams_utils.jams_converter(
         audio_path=self.audio_path,
         f0_data=[(self.pitch, 'annotated pitch')],
         metadata=self._track_metadata,
     )
    def to_jams(self):
        """Jams: the track's data in jams format"""

        f0_data = [
            (self.f0_crepe_dyn, "crepe - DYN"),
            (self.f0_crepe_hsm, "crepe - HSM"),
            (self.f0_crepe_lrx, "crepe - LRX"),
            (self.f0_pyin_dyn, "pyin - DYN"),
            (self.f0_pyin_hsm, "pyin - HSM"),
            (self.f0_pyin_lrx, "pyin - LRX"),
            (self.f0_manual_lrx, "manual - LRX"),
        ]
        # remove missing annotations from the list
        f0_data = [tup for tup in f0_data if tup[1]]
        score_data = [(self.score, "score")] if self.score else None

        if self.audio_hsm_path:
            audio_path = self.audio_hsm_path
        elif self.audio_dyn_path:
            audio_path = self.audio_dyn_path
        else:
            audio_path = self.audio_lrx_path

        return jams_utils.jams_converter(
            audio_path=audio_path,
            f0_data=f0_data,
            note_data=score_data,
        )
示例#18
0
 def to_jams(self):
     """Jams: the track's data in jams format"""
     # jams does not support multipitch, so we skip melody3
     return jams_utils.jams_converter(
         f0_data=[(self.melody1, 'melody1'), (self.melody2, 'melody2')],
         metadata=self._track_metadata,
     )
示例#19
0
 def to_jams(self):
     # Initialize top-level JAMS container
     return jams_utils.jams_converter(
         beat_data=[(self.beats, "midi beats")],
         tempo_data=[(self.tempo, "midi tempo")],
         event_data=[(self.drum_events, "annotated drum patterns")],
         metadata=self._track_metadata,
     )
示例#20
0
 def to_jams(self):
     """Jams: the track's data in jams format"""
     # jams does not support multipitch, so we skip melody3
     return jams_utils.jams_converter(
         audio_path=self.audio_path,
         f0_data=[(self.melody1, "melody1"), (self.melody2, "melody2")],
         metadata=self._track_metadata,
     )
    def to_jams(self):
        """Jams: the track's data in jams format"""

        beat_data = [(self.beat, "beat")] if self.beat else None

        return jams_utils.jams_converter(
            audio_path=self.audio_stm_path, beat_data=beat_data
        )
示例#22
0
文件: beatles.py 项目: wangyu/mirdata
 def to_jams(self):
     return jams_utils.jams_converter(
         beat_data=[(self.beats, None)],
         section_data=[(self.sections, None)],
         chord_data=[(self.chords, None)],
         key_data=[(self.key, None)],
         metadata={'artist': 'The Beatles', 'title': self.title},
     )
示例#23
0
    def to_jams(self):
        """Get the track's data in jams format

        Returns:
            jams.JAMS: the track's data in jams format

        """
        return jams_utils.jams_converter(audio_path=self.audio_path,
                                         metadata=self._track_metadata)
示例#24
0
 def to_jams(self):
     return jams_utils.jams_converter(
         f0_data=[
             (self.melody1, 'melody1'),
             (self.melody2, 'melody2'),
             (self.melody3, 'melody3'),
         ],
         metadata=self._track_metadata,
     )
示例#25
0
文件: cante100.py 项目: MTG/mirdata
 def to_jams(self):
     """Jams: the track's data in jams format"""
     return jams_utils.jams_converter(
         audio_path=self.audio_path,
         spectrogram_path=self.spectrogram_path,
         f0_data=[(self.melody, 'pitch_contour')],
         note_data=[(self.notes, 'note_hz')],
         metadata=self._track_metadata,
     )
    def to_jams(self):
        """Get the track's data in jams format

        Returns:
            jams.JAMS: the track's data in jams format

        """
        return jams_utils.jams_converter(audio_path=self.audio_paths[0],
                                         note_data=[(self.notes,
                                                     "aligned notes")])
示例#27
0
文件: irmas.py 项目: MTG/mirdata
 def to_jams(self):
     """Jams: the track's data in jams format"""
     return jams_utils.jams_converter(
         audio_path=self.audio_path,
         metadata={
             'instrument': self.instrument,
             'genre': self.genre,
             'drum': self.drum,
             'train': self.train,
         },
     )
示例#28
0
文件: ikala.py 项目: wangyu/mirdata
 def to_jams(self):
     return jams_utils.jams_converter(
         f0_data=[(self.f0, None)],
         lyrics_data=[(self.lyrics, None)],
         metadata={
             'section': self.section,
             'singer_id': self.singer_id,
             'track_id': self.track_id,
             'song_id': self.song_id,
         },
     )
示例#29
0
 def to_jams(self):
     """Jams: the track's data in jams format"""
     return jams_utils.jams_converter(
         audio_path=self.audio_path,
         metadata={
             'artists': self.artists,
             'genres': self.genres,
             'tempo': self.tempo,
             'title': self.title,
             'key': self.key,
         },
     )
示例#30
0
    def to_jams(self):
        """Get the track's data in jams format

        Returns:
            jams.JAMS: the track's data in jams format

        """
        return jams_utils.jams_converter(
            audio_path=self.audio_path,
            f0_data=[(self.pitch, "annotated pitch")],
            metadata=self._track_metadata,
        )