當前位置: 首頁>>代碼示例>>Python>>正文


Python jams.JAMS屬性代碼示例

本文整理匯總了Python中jams.JAMS屬性的典型用法代碼示例。如果您正苦於以下問題:Python jams.JAMS屬性的具體用法?Python jams.JAMS怎麽用?Python jams.JAMS使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在jams的用法示例。


在下文中一共展示了jams.JAMS屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: import_chord_jams

# 需要導入模塊: import jams [as 別名]
# 或者: from jams import JAMS [as 別名]
def import_chord_jams(infile, outfile):

    # import_lab returns a new jams object,
    # and a handle to the newly created annotation
    chords = jams.util.import_lab('chord', infile)

    # Infer the track duration from the end of the last annotation
    duration = max([obs.time + obs.duration for obs in chords])

    chords.time = 0
    chords.duration = duration

    # Create a jams object
    jam = jams.JAMS()
    jam.file_metadata.duration = duration
    jam.annotations.append(chords)

    # save to disk
    jam.save(outfile) 
開發者ID:marl,項目名稱:jams,代碼行數:21,代碼來源:example_chord_import.py

示例2: test_task_simple_chord_absent

# 需要導入模塊: import jams [as 別名]
# 或者: from jams import JAMS [as 別名]
def test_task_simple_chord_absent(SR, HOP_LENGTH):

    jam = jams.JAMS(file_metadata=dict(duration=4.0))
    trans = pumpp.task.SimpleChordTransformer(name='chord_s')

    output = trans.transform(jam)

    # Mask should be false since we have no matching namespace
    assert not np.any(output['chord_s/_valid'])

    # Check the shape
    assert output['chord_s/pitch'].shape == (1, 4 * (SR // HOP_LENGTH), 12)

    # Make sure it's empty
    assert not np.any(output['chord_s/pitch'])

    for key in trans.fields:
        assert shape_match(output[key].shape[1:], trans.fields[key].shape)
        assert type_match(output[key].dtype, trans.fields[key].dtype) 
開發者ID:bmcfee,項目名稱:pumpp,代碼行數:21,代碼來源:test_task.py

示例3: test_task_dlabel_absent

# 需要導入模塊: import jams [as 別名]
# 或者: from jams import JAMS [as 別名]
def test_task_dlabel_absent(SR, HOP_LENGTH):
    labels = ['alpha', 'beta', 'psycho', 'aqua', 'disco']

    jam = jams.JAMS(file_metadata=dict(duration=4.0))
    trans = pumpp.task.DynamicLabelTransformer(name='madeup',
                                               namespace='tag_open',
                                               labels=labels)

    output = trans.transform(jam)

    # Mask should be false since we have no matching namespace
    assert not np.any(output['madeup/_valid'])

    y = output['madeup/tags']

    # Check the shape
    assert y.shape == (1, 4 * (SR // HOP_LENGTH), len(labels))

    # Make sure it's empty
    assert not np.any(y)
    for key in trans.fields:
        assert shape_match(output[key].shape[1:], trans.fields[key].shape)
        assert type_match(output[key].dtype, trans.fields[key].dtype) 
開發者ID:bmcfee,項目名稱:pumpp,代碼行數:25,代碼來源:test_task.py

示例4: test_task_dlabel_auto

# 需要導入模塊: import jams [as 別名]
# 或者: from jams import JAMS [as 別名]
def test_task_dlabel_auto(SR, HOP_LENGTH):
    jam = jams.JAMS(file_metadata=dict(duration=4.0))
    trans = pumpp.task.DynamicLabelTransformer(name='genre',
                                               namespace='tag_gtzan')

    output = trans.transform(jam)

    # Mask should be false since we have no matching namespace
    assert not np.any(output['genre/_valid'])

    y = output['genre/tags']

    # Check the shape
    assert y.shape == (1, 4 * (SR // HOP_LENGTH), 10)

    # Make sure it's empty
    assert not np.any(y)
    for key in trans.fields:
        assert shape_match(output[key].shape[1:], trans.fields[key].shape)
        assert type_match(output[key].dtype, trans.fields[key].dtype) 
開發者ID:bmcfee,項目名稱:pumpp,代碼行數:22,代碼來源:test_task.py

示例5: test_task_slabel_absent

# 需要導入模塊: import jams [as 別名]
# 或者: from jams import JAMS [as 別名]
def test_task_slabel_absent():
    labels = ['alpha', 'beta', 'psycho', 'aqua', 'disco']

    jam = jams.JAMS(file_metadata=dict(duration=4.0))
    trans = pumpp.task.StaticLabelTransformer(name='madeup',
                                              namespace='tag_open',
                                              labels=labels)

    output = trans.transform(jam)

    # Mask should be false since we have no matching namespace
    assert not np.any(output['madeup/_valid'])

    # Check the shape
    assert output['madeup/tags'].ndim == 2
    assert output['madeup/tags'].shape[1] == len(labels)

    # Make sure it's empty
    assert not np.any(output['madeup/tags'])

    for key in trans.fields:
        assert shape_match(output[key].shape[1:], trans.fields[key].shape)
        assert type_match(output[key].dtype, trans.fields[key].dtype) 
開發者ID:bmcfee,項目名稱:pumpp,代碼行數:25,代碼來源:test_task.py

示例6: test_task_slabel_auto

# 需要導入模塊: import jams [as 別名]
# 或者: from jams import JAMS [as 別名]
def test_task_slabel_auto():
    jam = jams.JAMS(file_metadata=dict(duration=4.0))
    trans = pumpp.task.StaticLabelTransformer(name='genre',
                                              namespace='tag_gtzan')

    output = trans.transform(jam)

    # Mask should be false since we have no matching namespace
    assert not np.any(output['genre/_valid'])

    # Check the shape
    assert output['genre/tags'].ndim == 2
    assert output['genre/tags'].shape[1] == 10

    # Make sure it's empty
    assert not np.any(output['genre/tags'])

    for key in trans.fields:
        assert shape_match(output[key].shape[1:], trans.fields[key].shape)
        assert type_match(output[key].dtype, trans.fields[key].dtype) 
開發者ID:bmcfee,項目名稱:pumpp,代碼行數:22,代碼來源:test_task.py

示例7: test_task_beat_absent

# 需要導入模塊: import jams [as 別名]
# 或者: from jams import JAMS [as 別名]
def test_task_beat_absent(SR, HOP_LENGTH):

    # Construct a jam
    jam = jams.JAMS(file_metadata=dict(duration=4.0))

    # One second = one frame
    trans = pumpp.task.BeatTransformer(name='beat')

    output = trans.transform(jam)

    # Make sure we have the mask
    assert not np.any(output['beat/_valid'])
    assert not output['beat/mask_downbeat']

    # Check the shape: 4 seconds at 2 samples per second
    assert output['beat/beat'].shape == (1, 4 * (SR // HOP_LENGTH), 1)
    assert output['beat/downbeat'].shape == (1, 4 * (SR // HOP_LENGTH), 1)
    assert not np.any(output['beat/beat'])
    assert not np.any(output['beat/downbeat'])

    for key in trans.fields:
        assert shape_match(output[key].shape[1:], trans.fields[key].shape)
        assert type_match(output[key].dtype, trans.fields[key].dtype) 
開發者ID:bmcfee,項目名稱:pumpp,代碼行數:25,代碼來源:test_task.py

示例8: test_transform_noprefix

# 需要導入模塊: import jams [as 別名]
# 或者: from jams import JAMS [as 別名]
def test_transform_noprefix():

    labels = ['foo', 'bar', 'baz']

    jam = jams.JAMS(file_metadata=dict(duration=4.0))
    trans = pumpp.task.StaticLabelTransformer(name=None,
                                              namespace='tag_open',
                                              labels=labels)

    output = trans.transform(jam)

    # Mask should be false since we have no matching namespace
    assert not np.any(output['_valid'])

    # Check the shape
    assert output['tags'].ndim == 2
    assert output['tags'].shape[1] == len(labels)

    # Make sure it's empty
    assert not np.any(output['tags'])

    for key in trans.fields:
        assert shape_match(output[key].shape[1:], trans.fields[key].shape)
        assert type_match(output[key].dtype, trans.fields[key].dtype) 
開發者ID:bmcfee,項目名稱:pumpp,代碼行數:26,代碼來源:test_task.py

示例9: test_task_chord_tag_absent

# 需要導入模塊: import jams [as 別名]
# 或者: from jams import JAMS [as 別名]
def test_task_chord_tag_absent(SR, HOP_LENGTH, VOCAB, SPARSE):

    jam = jams.JAMS(file_metadata=dict(duration=4.0))
    trans = pumpp.task.ChordTagTransformer(name='chord',
                                           vocab=VOCAB,
                                           sr=SR, hop_length=HOP_LENGTH,
                                           sparse=SPARSE)

    output = trans.transform(jam)

    # Valid range is 0 since we have no matching namespace
    assert not np.any(output['chord/_valid'])

    # Make sure it's all no-chord
    Y_pred = trans.encoder.inverse_transform(output['chord/chord'][0])

    assert all([_ == 'X' for _ in Y_pred])

    # Check the shape
    for key in trans.fields:
        assert shape_match(output[key].shape[1:], trans.fields[key].shape)
        assert type_match(output[key].dtype, trans.fields[key].dtype) 
開發者ID:bmcfee,項目名稱:pumpp,代碼行數:24,代碼來源:test_task.py

示例10: test_task_beatpos_absent

# 需要導入模塊: import jams [as 別名]
# 或者: from jams import JAMS [as 別名]
def test_task_beatpos_absent(SR, HOP_LENGTH, MAX_DIVISIONS, SPARSE):
    jam = jams.JAMS(file_metadata=dict(duration=4.0))
    trans = pumpp.task.BeatPositionTransformer(name='beat',
                                               max_divisions=MAX_DIVISIONS,
                                               sr=SR, hop_length=HOP_LENGTH,
                                               sparse=SPARSE)

    output = trans.transform(jam)

    assert not np.any(output['beat/_valid'])

    Y_pred = trans.encoder.inverse_transform(output['beat/position'][0])

    assert all([_ == 'X' for _ in Y_pred])

    for key in trans.fields:
        assert shape_match(output[key].shape[1:], trans.fields[key].shape)
        assert type_match(output[key].dtype, trans.fields[key].dtype) 
開發者ID:bmcfee,項目名稱:pumpp,代碼行數:20,代碼來源:test_task.py

示例11: test_jam_pack

# 需要導入模塊: import jams [as 別名]
# 或者: from jams import JAMS [as 別名]
def test_jam_pack():

    jam = jams.JAMS()

    sr = 22050
    y = np.zeros(sr)

    muda.jam_pack(jam, y=y, sr=sr)

    # Make sure the jam now has a mudabox
    assert hasattr(jam.sandbox, 'muda')
    assert hasattr(jam.sandbox.muda, 'history')
    assert hasattr(jam.sandbox.muda, 'state')

    assert jam.sandbox.muda['y'] is y
    assert jam.sandbox.muda['sr'] == sr 
開發者ID:bmcfee,項目名稱:muda,代碼行數:18,代碼來源:test_core.py

示例12: test_annotation_array_index_simple

# 需要導入模塊: import jams [as 別名]
# 或者: from jams import JAMS [as 別名]
def test_annotation_array_index_simple():

    jam = jams.JAMS()

    anns = [jams.Annotation('beat') for _ in range(5)]

    for ann in anns:
        jam.annotations.append(ann)

    assert len(jam.annotations) == len(anns)
    for i in range(5):
        a1, a2 = anns[i], jam.annotations[i]
        assert a1 == a2 
開發者ID:marl,項目名稱:jams,代碼行數:15,代碼來源:test_jams.py

示例13: test_annotation_array_slice_simple

# 需要導入模塊: import jams [as 別名]
# 或者: from jams import JAMS [as 別名]
def test_annotation_array_slice_simple():

    jam = jams.JAMS()

    anns = [jams.Annotation('beat') for _ in range(5)]

    for ann in anns:
        jam.annotations.append(ann)

    res = jam.annotations[:3]
    assert len(res) == 3
    assert anns[0] in res 
開發者ID:marl,項目名稱:jams,代碼行數:14,代碼來源:test_jams.py

示例14: test_annotation_array_index_fancy

# 需要導入模塊: import jams [as 別名]
# 或者: from jams import JAMS [as 別名]
def test_annotation_array_index_fancy():

    jam = jams.JAMS()
    ann = jams.Annotation(namespace='beat')
    jam.annotations.append(ann)

    # We should have exactly one beat annotation
    res = jam.annotations['beat']
    assert len(res) == 1
    assert res[0] == ann

    # Any other namespace should give an empty list
    assert jam.annotations['segment'] == [] 
開發者ID:marl,項目名稱:jams,代碼行數:15,代碼來源:test_jams.py

示例15: test_annotation_array_index_error

# 需要導入模塊: import jams [as 別名]
# 或者: from jams import JAMS [as 別名]
def test_annotation_array_index_error():

    jam = jams.JAMS()
    ann = jams.Annotation(namespace='beat')
    jam.annotations.append(ann)
    jam.annotations[None]


# JAMS 
開發者ID:marl,項目名稱:jams,代碼行數:11,代碼來源:test_jams.py


注:本文中的jams.JAMS屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。