当前位置: 首页>>代码示例>>Python>>正文


Python jams.Annotation方法代码示例

本文整理汇总了Python中jams.Annotation方法的典型用法代码示例。如果您正苦于以下问题:Python jams.Annotation方法的具体用法?Python jams.Annotation怎么用?Python jams.Annotation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在jams的用法示例。


在下文中一共展示了jams.Annotation方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_annotation_eq

# 需要导入模块: import jams [as 别名]
# 或者: from jams import Annotation [as 别名]
def test_annotation_eq(tag_data):
    namespace = 'tag_open'

    ann1 = jams.Annotation(namespace, data=tag_data)
    ann2 = jams.Annotation(namespace, data=tag_data)

    assert ann1 == ann2

    # Test the type-check in equality
    assert not (ann1 == tag_data)

    update = dict(time=2.0, duration=1.0, value='three', confidence=0.8)

    ann2.append(**update)

    assert not (ann1 == ann2) 
开发者ID:marl,项目名称:jams,代码行数:18,代码来源:test_jams.py

示例2: test_jams_add

# 需要导入模块: import jams [as 别名]
# 或者: from jams import Annotation [as 别名]
def test_jams_add(tag_data):

    fn = 'tests/fixtures/valid.jams'

    # The original jam
    jam_orig = jams.load(fn)
    jam = jams.load(fn)

    # Make a new jam with the same metadata and different data
    jam2 = jams.load(fn)
    ann = jams.Annotation('tag_open', data=tag_data)
    jam2.annotations = jams.AnnotationArray(annotations=[ann])

    # Add the two
    jam.add(jam2)

    assert len(jam.annotations) == 3
    assert jam.annotations[:-1] == jam_orig.annotations
    assert jam.annotations[-1] == jam2.annotations[0] 
开发者ID:marl,项目名称:jams,代码行数:21,代码来源:test_jams.py

示例3: test_annotation_trim_no_overlap

# 需要导入模块: import jams [as 别名]
# 或者: from jams import Annotation [as 别名]
def test_annotation_trim_no_overlap():
    # when there's no overlap, a warning is raised and the
    # returned annotation should be empty
    ann = jams.Annotation('tag_open')
    ann.time = 5
    ann.duration = 10

    trim_times = [(1, 2), (16, 20)]

    for tt in trim_times[:2]:

        clean_warning_registry()
        with warnings.catch_warnings(record=True) as out:
            ann_trim = ann.trim(*tt)

        assert len(out) > 0
        assert out[0].category is UserWarning
        assert 'does not intersect' in str(out[0].message).lower()

        assert len(ann_trim.data) == 0
        assert ann_trim.time == ann.time
        assert ann_trim.duration == 0 
开发者ID:marl,项目名称:jams,代码行数:24,代码来源:test_jams.py

示例4: test_annotation_data_frame

# 需要导入模块: import jams [as 别名]
# 或者: from jams import Annotation [as 别名]
def test_annotation_data_frame():
    namespace = 'tag_open'
    data = dict(time=[5.0, 5.0, 10.0],
                duration=[2.0, 4.0, 4.0],
                value=['one', 'two', 'three'],
                confidence=[0.9, 0.9, 0.9])
    ann = jams.Annotation(namespace, data=data, time=5.0, duration=10.0)

    df = ann.to_dataframe()

    assert list(df.columns) == ['time', 'duration', 'value', 'confidence']

    for i, row in df.iterrows():
        assert row.time == data['time'][i]
        assert row.duration == data['duration'][i]
        assert row.value == data['value'][i]
        assert row.confidence == data['confidence'][i] 
开发者ID:marl,项目名称:jams,代码行数:19,代码来源:test_jams.py

示例5: test_annotation_to_samples

# 需要导入模块: import jams [as 别名]
# 或者: from jams import Annotation [as 别名]
def test_annotation_to_samples(confidence):

    ann = jams.Annotation('tag_open')

    ann.append(time=0, duration=0.5, value='one', confidence=0.1)
    ann.append(time=0.25, duration=0.5, value='two', confidence=0.2)
    ann.append(time=0.75, duration=0.5, value='three', confidence=0.3)
    ann.append(time=1.5, duration=0.5, value='four', confidence=0.4)

    values = ann.to_samples([0.2, 0.4, 0.75, 1.25, 1.75, 1.4], confidence=confidence)

    if confidence:
        values, confs = values
        assert confs == [[0.1], [0.1, 0.2], [0.2, 0.3], [0.3], [0.4], []]

    assert values == [['one'], ['one', 'two'], ['two', 'three'], ['three'], ['four'], []] 
开发者ID:marl,项目名称:jams,代码行数:18,代码来源:test_jams.py

示例6: test_ns_contour_valid

# 需要导入模块: import jams [as 别名]
# 或者: from jams import Annotation [as 别名]
def test_ns_contour_valid():

    srand()

    ann = Annotation(namespace='pitch_contour')

    seq_len = 21
    times = np.arange(seq_len)
    durations = np.zeros(seq_len)
    values = np.linspace(0, 22050, seq_len)  # includes 0 (odd symmetric)
    ids = np.arange(len(values)) // 4
    voicing = np.random.randn(len(ids)) > 0

    confidences = np.linspace(0, 1., seq_len)
    confidences[seq_len//2] = None  # throw in a None confidence value

    for (t, d, v, c, i, b) in zip(times, durations, values,
                                  confidences, ids, voicing):
        ann.append(time=t, duration=d,
                   value={'pitch': v, 'id': i, 'voiced': b}, confidence=c)

    ann.validate() 
开发者ID:marl,项目名称:jams,代码行数:24,代码来源:test_ns.py

示例7: test_ns_contour_invalid

# 需要导入模块: import jams [as 别名]
# 或者: from jams import Annotation [as 别名]
def test_ns_contour_invalid():

    srand()

    ann = Annotation(namespace='pitch_contour')

    seq_len = 21
    times = np.arange(seq_len)
    durations = np.zeros(seq_len)
    values = np.linspace(0, 22050, seq_len)  # includes 0 (odd symmetric)
    ids = np.arange(len(values)) // 4
    voicing = np.random.randn(len(ids)) * 2

    confidences = np.linspace(0, 1., seq_len)
    confidences[seq_len//2] = None  # throw in a None confidence value

    for (t, d, v, c, i, b) in zip(times, durations, values,
                                  confidences, ids, voicing):
        ann.append(time=t, duration=d,
                   value={'pitch': v, 'id': i, 'voiced': b}, confidence=c)

    ann.validate() 
开发者ID:marl,项目名称:jams,代码行数:24,代码来源:test_ns.py

示例8: test_ns_scaper_source_time

# 需要导入模块: import jams [as 别名]
# 或者: from jams import Annotation [as 别名]
def test_ns_scaper_source_time(source_time):

    ann = Annotation(namespace='scaper')

    value = {
        "source_time": source_time,
        "event_duration": 0.5310546236891855,
        "event_time": 5.6543442662431795,
        "time_stretch": 0.8455598669219283,
        "pitch_shift": -1.2204911976305648,
        "snr": 7.790682558359417,
        "label": 'gun_shot',
        "role": "foreground",
        "source_file": "/audio/foreground/gun_shot/135544-6-17-0.wav"
    }

    ann.append(time=0, duration=1, value=value)
    ann.validate() 
开发者ID:marl,项目名称:jams,代码行数:20,代码来源:test_ns.py

示例9: test_ns_scaper_event_duration

# 需要导入模块: import jams [as 别名]
# 或者: from jams import Annotation [as 别名]
def test_ns_scaper_event_duration(event_duration):

    ann = Annotation(namespace='scaper')

    value = {
        "source_time": 0.0,
        "event_duration": event_duration,
        "event_time": 5.6543442662431795,
        "time_stretch": 0.8455598669219283,
        "pitch_shift": -1.2204911976305648,
        "snr": 7.790682558359417,
        "label": 'gun_shot',
        "role": "foreground",
        "source_file": "/audio/foreground/gun_shot/135544-6-17-0.wav"
    }

    ann.append(time=0, duration=1, value=value)
    ann.validate() 
开发者ID:marl,项目名称:jams,代码行数:20,代码来源:test_ns.py

示例10: test_ns_scaper_event_time

# 需要导入模块: import jams [as 别名]
# 或者: from jams import Annotation [as 别名]
def test_ns_scaper_event_time(event_time):

    ann = Annotation(namespace='scaper')

    value = {
        "source_time": 0.0,
        "event_duration": 0.5310546236891855,
        "event_time": event_time,
        "time_stretch": 0.8455598669219283,
        "pitch_shift": -1.2204911976305648,
        "snr": 7.790682558359417,
        "label": 'gun_shot',
        "role": "foreground",
        "source_file": "/audio/foreground/gun_shot/135544-6-17-0.wav"
    }

    ann.append(time=0, duration=1, value=value)
    ann.validate() 
开发者ID:marl,项目名称:jams,代码行数:20,代码来源:test_ns.py

示例11: test_ns_scaper_time_stretch

# 需要导入模块: import jams [as 别名]
# 或者: from jams import Annotation [as 别名]
def test_ns_scaper_time_stretch(time_stretch):

    ann = Annotation(namespace='scaper')

    value = {
        "source_time": 0.0,
        "event_duration": 0.5310546236891855,
        "event_time": 5.6543442662431795,
        "time_stretch": time_stretch,
        "pitch_shift": -1.2204911976305648,
        "snr": 7.790682558359417,
        "label": 'gun_shot',
        "role": "foreground",
        "source_file": "/audio/foreground/gun_shot/135544-6-17-0.wav"
    }

    ann.append(time=0, duration=1, value=value)
    ann.validate() 
开发者ID:marl,项目名称:jams,代码行数:20,代码来源:test_ns.py

示例12: test_ns_scaper_pitch_shift

# 需要导入模块: import jams [as 别名]
# 或者: from jams import Annotation [as 别名]
def test_ns_scaper_pitch_shift(pitch_shift):

    ann = Annotation(namespace='scaper')

    value = {
        "source_time": 0.0,
        "event_duration": 0.5310546236891855,
        "event_time": 5.6543442662431795,
        "time_stretch": 0.8455598669219283,
        "pitch_shift": pitch_shift,
        "snr": 7.790682558359417,
        "label": 'gun_shot',
        "role": "foreground",
        "source_file": "/audio/foreground/gun_shot/135544-6-17-0.wav"
    }

    ann.append(time=0, duration=1, value=value)
    ann.validate() 
开发者ID:marl,项目名称:jams,代码行数:20,代码来源:test_ns.py

示例13: test_annotation

# 需要导入模块: import jams [as 别名]
# 或者: from jams import Annotation [as 别名]
def test_annotation(namespace, tag_data, ann_metadata, ann_sandbox):
    ann = jams.Annotation(namespace, data=tag_data,
                          annotation_metadata=ann_metadata,
                          sandbox=ann_sandbox)

    assert namespace == ann.namespace

    assert dict(ann_metadata) == dict(ann.annotation_metadata)

    assert dict(ann_sandbox) == dict(ann.sandbox)

    assert len(ann.data) == len(tag_data)
    for obs1, obs2 in zip(ann.data, tag_data):
        assert obs1._asdict() == obs2 
开发者ID:marl,项目名称:jams,代码行数:16,代码来源:test_jams.py

示例14: test_annotation_append

# 需要导入模块: import jams [as 别名]
# 或者: from jams import Annotation [as 别名]
def test_annotation_append():

    data = [dict(time=0, duration=0.5, value='one', confidence=0.9),
            dict(time=1.0, duration=0.5, value='two', confidence=0.9)]

    namespace = 'tag_open'

    ann = jams.Annotation(namespace, data=data)

    update = dict(time=2.0, duration=1.0, value='three', confidence=0.8)

    ann.append(**update)

    assert ann.data[-1]._asdict() == update 
开发者ID:marl,项目名称:jams,代码行数:16,代码来源:test_jams.py

示例15: test_annotation_iterator

# 需要导入模块: import jams [as 别名]
# 或者: from jams import Annotation [as 别名]
def test_annotation_iterator():

    data = [dict(time=0, duration=0.5, value='one', confidence=0.2),
            dict(time=1, duration=1, value='two', confidence=0.5)]

    namespace = 'tag_open'

    ann = jams.Annotation(namespace, data=data)

    for obs, obs_raw in zip(ann, data):
        assert isinstance(obs, jams.Observation)
        assert obs._asdict() == obs_raw, (obs, obs_raw) 
开发者ID:marl,项目名称:jams,代码行数:14,代码来源:test_jams.py


注:本文中的jams.Annotation方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。