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


Python jams.load方法代码示例

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


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

示例1: _get_info_from_item

# 需要导入模块: import jams [as 别名]
# 或者: from jams import load [as 别名]
def _get_info_from_item(self, item):
        path_to_item = os.path.join(self.folder, item)
        item_base_name = os.path.splitext(item)[0]

        jam = jams.load(path_to_item)
        ann = jam.annotations.search(namespace='scaper')[0]
        mix_path = ann.sandbox.scaper['soundscape_audio_path']
        source_paths = ann.sandbox.scaper['isolated_events_audio_path']

        mix_path = os.path.join(
            self.folder, item_base_name + mix_path.split(item_base_name)[-1])
        for i, source_path in enumerate(source_paths):
            source_paths[i] = os.path.join(
                self.folder, item_base_name + source_path.split(item_base_name)[-1])

        return jam, ann, mix_path, source_paths 
开发者ID:nussl,项目名称:nussl,代码行数:18,代码来源:hooks.py

示例2: test_jams_add

# 需要导入模块: import jams [as 别名]
# 或者: from jams import load [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_jams_add_conflict

# 需要导入模块: import jams [as 别名]
# 或者: from jams import load [as 别名]
def test_jams_add_conflict(on_conflict):
    fn = 'tests/fixtures/valid.jams'

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

    # The copy
    jam2 = jams.load(fn)

    jam2.file_metadata = jams.FileMetadata()

    jam.add(jam2, on_conflict=on_conflict)

    if on_conflict == 'overwrite':
        assert jam.file_metadata == jam2.file_metadata
    elif on_conflict == 'ignore':
        assert jam.file_metadata == jam_orig.file_metadata 
开发者ID:marl,项目名称:jams,代码行数:20,代码来源:test_jams.py

示例4: test_load_invalid

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

    def __test_warn(filename, valid, strict):
        clean_warning_registry()

        with warnings.catch_warnings(record=True) as out:
            jams.load(filename, validate=valid, strict=strict)

        assert len(out) > 0
        assert out[0].category is UserWarning
        assert 'failed validating' in str(out[0].message).lower()

    # 5. test bad jams file with strict validation
    # 6. test bad jams file without strict validation
    fn = 'tests/fixtures/invalid.jams'

    # Test once with no validation
    jams.load(fn, validate=False, strict=False)

    # With validation, failure can either be a warning or an exception
    with pytest.raises(jams.SchemaError):
        jams.load(fn, validate=True, strict=True)

    __test_warn(fn, True, False) 
开发者ID:marl,项目名称:jams,代码行数:26,代码来源:test_jams.py

示例5: load

# 需要导入模块: import jams [as 别名]
# 或者: from jams import load [as 别名]
def load(data_home=None):
    """Load GuitarSet

    Args:
        data_home (str): Local path where GuitarSet is stored.
            If `None`, looks for the data in the default directory, `~/mir_datasets`

    Returns:
        (dict): {`track_id`: track data}
    """
    if data_home is None:
        data_home = utils.get_default_dataset_path(DATASET_DIR)

    guitarset_data = {}
    for key in DATA.index.keys():
        guitarset_data[key] = Track(key, data_home=data_home)
    return guitarset_data 
开发者ID:mir-dataset-loaders,项目名称:mirdata,代码行数:19,代码来源:guitarset.py

示例6: load_pitch_contour

# 需要导入模块: import jams [as 别名]
# 或者: from jams import load [as 别名]
def load_pitch_contour(jams_path, string_num):
    """
    Args:
        jams_path (str): Path of the jams annotation file

    string_num (int), in range(6): Which string to load.
        0 is the Low E string, 5 is the high e string.
    """
    if not os.path.exists(jams_path):
        raise IOError("jams_path {} does not exist".format(jams_path))
    jam = jams.load(jams_path)
    anno_arr = jam.search(namespace='pitch_contour')
    anno = anno_arr.search(data_source=str(string_num))[0]
    times, values = anno.to_event_values()
    frequencies = [v['frequency'] for v in values]
    return utils.F0Data(times, frequencies, np.ones_like(times)) 
开发者ID:mir-dataset-loaders,项目名称:mirdata,代码行数:18,代码来源:guitarset.py

示例7: get_duration

# 需要导入模块: import jams [as 别名]
# 或者: from jams import load [as 别名]
def get_duration(features_file):
    """Reads the duration of a given features file.

    Parameters
    ----------
    features_file: str
        Path to the JSON file containing the features.

    Returns
    -------
    dur: float
        Duration of the analyzed file.
    """
    with open(features_file) as f:
        feats = json.load(f)
    return float(feats["globals"]["dur"]) 
开发者ID:urinieto,项目名称:msaf,代码行数:18,代码来源:input_output.py

示例8: test_read_hier_references

# 需要导入模块: import jams [as 别名]
# 或者: from jams import load [as 别名]
def test_read_hier_references():
    one_jams = os.path.join("..", "datasets", "Sargon", "references",
                            "01-Sargon-Mindless.jams")
    three_jams = os.path.join("..", "datasets", "SALAMI", "references",
                              "SALAMI_200.jams")

    audio, fs = librosa.load(audio_file, sr=sr)
    y_harmonic, y_percussive = librosa.effects.hpss(audio)

    # One level file
    hier_bounds, hier_labels, hier_levels = \
        msaf.io.read_hier_references(one_jams)
    assert len(hier_bounds) == len(hier_labels) and \
        len(hier_labels) == len(hier_levels)
    assert len(hier_levels) == 1

    # Three level file
    hier_bounds, hier_labels, hier_levels = \
        msaf.io.read_hier_references(three_jams)
    assert len(hier_bounds) == len(hier_labels) and \
        len(hier_labels) == len(hier_levels)
    assert len(hier_levels) == 3 
开发者ID:urinieto,项目名称:msaf,代码行数:24,代码来源:test_input_output.py

示例9: track_eval

# 需要导入模块: import jams [as 别名]
# 或者: from jams import load [as 别名]
def track_eval(ann, aud):

    model = crema.models.chord.ChordModel()

    # Load the audio and make a prediction
    track = crema.utils.base(ann)

    jam_ref = jams.load(ann, validate=False)

    est = model.predict(filename=aud)
    try:
        scores = jams.eval.chord(jam_ref.annotations['chord', 0],
                                 est)
    except ValueError as exc:
        print(ann)
        print(est.to_dataframe())
        print(jam_ref.annotations['chord', 0].to_dataframe())
        raise exc

    return (track, dict(scores)) 
开发者ID:bmcfee,项目名称:crema,代码行数:22,代码来源:03-evaluate.py

示例10: test_save

# 需要导入模块: import jams [as 别名]
# 或者: from jams import load [as 别名]
def test_save(jam_in, audio_file, strict, fmt):

    jam = muda.load_jam_audio(jam_in, audio_file)

    _, jamfile = tempfile.mkstemp(suffix='.jams')
    _, audfile = tempfile.mkstemp(suffix='.wav')

    muda.save(audfile, jamfile, jam, strict=strict, fmt=fmt)

    jam2 = muda.load_jam_audio(jamfile, audfile, fmt=fmt)
    jam2_raw = jams.load(jamfile, fmt=fmt)

    os.unlink(audfile)
    os.unlink(jamfile)

    assert hasattr(jam2.sandbox, 'muda')
    assert '_audio' in jam2.sandbox.muda
    assert '_audio' not in jam2_raw.sandbox.muda

    duration = librosa.get_duration(**jam2.sandbox.muda['_audio'])

    assert jam2.file_metadata.duration == duration 
开发者ID:bmcfee,项目名称:muda,代码行数:24,代码来源:test_core.py

示例11: compare_beats

# 需要导入模块: import jams [as 别名]
# 或者: from jams import load [as 别名]
def compare_beats(f_ref, f_est):

    # f_ref contains the reference annotations
    j_ref = jams.load(f_ref)

    # f_est contains the estimated annotations
    j_est = jams.load(f_est)

    # Get the first reference beats
    beat_ref = j_ref.search(namespace='beat')[0]
    beat_est = j_est.search(namespace='beat')[0]

    # Get the scores
    return jams.eval.beat(beat_ref, beat_est) 
开发者ID:marl,项目名称:jams,代码行数:16,代码来源:example_eval.py

示例12: input_jam

# 需要导入模块: import jams [as 别名]
# 或者: from jams import load [as 别名]
def input_jam():
    return jams.load('tests/fixtures/valid.jams') 
开发者ID:marl,项目名称:jams,代码行数:4,代码来源:test_jams.py

示例13: test_jams_save

# 需要导入模块: import jams [as 别名]
# 或者: from jams import load [as 别名]
def test_jams_save(input_jam, output_path):

    input_jam.save(output_path)
    reload_jam = jams.load(output_path)
    assert input_jam == reload_jam 
开发者ID:marl,项目名称:jams,代码行数:7,代码来源:test_jams.py

示例14: test_jams_validate_good

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

    fn = 'tests/fixtures/valid.jams'
    j1 = jams.load(fn, validate=False)

    j1.validate()

    j1.file_metadata.validate() 
开发者ID:marl,项目名称:jams,代码行数:10,代码来源:test_jams.py

示例15: jam_validate

# 需要导入模块: import jams [as 别名]
# 或者: from jams import load [as 别名]
def jam_validate():
    j1 = jams.load('tests/fixtures/invalid.jams', validate=False)
    return j1 
开发者ID:marl,项目名称:jams,代码行数:5,代码来源:test_jams.py


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