本文整理汇总了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)
示例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)
示例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)
示例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)
示例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)
示例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)
示例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)
示例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)
示例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)
示例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)
示例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
示例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
示例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
示例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'] == []
示例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