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


Python musdb.DB属性代码示例

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


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

示例1: _compute_musdb_metrics

# 需要导入模块: import musdb [as 别名]
# 或者: from musdb import DB [as 别名]
def _compute_musdb_metrics(
        arguments,
        musdb_root_directory,
        audio_output_directory):
    """ Generates musdb metrics fro previsouly computed audio estimation.

    :param arguments: Entrypoint arguments.
    :param audio_output_directory: Directory to get audio estimation from.
    :returns: Path of generated metrics directory.
    """
    metrics_output_directory = join(
        arguments.output_path,
        _METRICS_DIRECTORY)
    get_logger().info('Starting musdb evaluation (this could be long) ...')
    dataset = musdb.DB(
        root=musdb_root_directory,
        is_wav=True,
        subsets=[_SPLIT])
    museval.eval_mus_dir(
        dataset=dataset,
        estimates_dir=audio_output_directory,
        output_dir=metrics_output_directory)
    get_logger().info('musdb evaluation done')
    return metrics_output_directory 
开发者ID:deezer,项目名称:spleeter,代码行数:26,代码来源:evaluate.py

示例2: load_dataset

# 需要导入模块: import musdb [as 别名]
# 或者: from musdb import DB [as 别名]
def load_dataset(self):

        print('Loading MUSDB18 dataset for singing voice separation...')

        mus = musdb.DB(root_dir=self.path, is_wav=True)
        tracks = mus.load_mus_tracks(subsets='train')
        np.random.seed(seed=1337)
        val_idx = np.random.choice(len(tracks), size=25, replace=False)
        train_idx = [i for i in range(len(tracks)) if i not in val_idx]
        val_tracks = [tracks[i] for i in val_idx]
        train_tracks = [tracks[i] for i in train_idx]
        for condition in ['mixture', 'vocals']:
            self.file_paths['val'][condition] = [track.path[:-11] + condition + '.wav' for track in val_tracks]
        for condition in ['mixture', 'vocals']:
            self.file_paths['train'][condition] = [track.path[:-11] + condition + '.wav' for track in train_tracks]
        self.load_songs()
        return self 
开发者ID:francesclluis,项目名称:source-separation-wavenet,代码行数:19,代码来源:datasets.py

示例3: test_download_and_validation

# 需要导入模块: import musdb [as 别名]
# 或者: from musdb import DB [as 别名]
def test_download_and_validation():
    mus_all = musdb.DB(download=True)

    assert len(mus_all) == 144

    for track in mus_all:
        assert track.audio.shape[1] > 0
        assert track.audio.shape[-1] == 2
        assert track.stems.shape[0] == 5

    mus_test = musdb.DB(download=True, subsets='test', split=None)
    assert len(mus_test) == 50

    mus_train = musdb.DB(download=True, subsets='train', split='train')
    assert len(mus_train) == 80
    # test validation set
    mus_valid = musdb.DB(download=True, subsets='train', split='valid')
    assert len(mus_valid) == 14

    assert len(mus_train) == len(mus_all) - len(mus_test) - len(mus_valid) 
开发者ID:sigsep,项目名称:sigsep-mus-db,代码行数:22,代码来源:test_parser.py

示例4: main

# 需要导入模块: import musdb [as 别名]
# 或者: from musdb import DB [as 别名]
def main():
    parser = argparse.ArgumentParser('rawset')
    parser.add_argument('--workers', type=int, default=10)
    parser.add_argument('--samplerate', type=int, default=44100)
    parser.add_argument('--channels', type=int, default=2)
    parser.add_argument('musdb', type=Path)
    parser.add_argument('destination', type=Path)

    args = parser.parse_args()

    build_raw(musdb.DB(root=args.musdb, subsets=["train"], split="train"),
              args.destination / "train",
              normalize=True,
              channels=args.channels,
              samplerate=args.samplerate,
              workers=args.workers)
    build_raw(musdb.DB(root=args.musdb, subsets=["train"], split="valid"),
              args.destination / "valid",
              normalize=True,
              samplerate=args.samplerate,
              channels=args.channels,
              workers=args.workers) 
开发者ID:facebookresearch,项目名称:demucs,代码行数:24,代码来源:raw.py

示例5: musdb_tracks

# 需要导入模块: import musdb [as 别名]
# 或者: from musdb import DB [as 别名]
def musdb_tracks():
    with tempfile.TemporaryDirectory() as tmp_dir:
        _dir = tmp_dir if fix_dir is None else fix_dir
        db = musdb.DB(root=_dir, download=True)
        yield db 
开发者ID:nussl,项目名称:nussl,代码行数:7,代码来源:conftest.py

示例6: eval_mus_dir

# 需要导入模块: import musdb [as 别名]
# 或者: from musdb import DB [as 别名]
def eval_mus_dir(
    dataset,
    estimates_dir,
    output_dir=None,
    ext='wav'
):
    """Run evaluation of musdb estimate dir

    Parameters
    ----------
    dataset : DB(object)
        MUSDB18 Database object.
    estimates_dir : str
        Path to estimates folder.
    output_dir : str
        Output folder where evaluation json files are stored.
    ext : str
        estimate file extension, defaults to `wav`
    """
    # create a new musdb instance for estimates with the same file structure
    est = musdb.DB(root=estimates_dir, is_wav=True)
    # get a list of track names
    tracks_to_be_estimated = [t.name for t in est.tracks]

    for track in dataset:
        if track.name not in tracks_to_be_estimated:
            continue
        _load_track_estimates(
            track=track,
            estimates_dir=estimates_dir,
            output_dir=output_dir
        ) 
开发者ID:sigsep,项目名称:sigsep-mus-eval,代码行数:34,代码来源:__init__.py

示例7: museval

# 需要导入模块: import musdb [as 别名]
# 或者: from musdb import DB [as 别名]
def museval(inargs=None):
    """
    Commandline interface for museval evaluation tools
    """
    parser = argparse.ArgumentParser()

    parser.add_argument(
        'estimates_dir',
        type=str
    )

    parser.add_argument('-o', help='output_dir')

    parser.add_argument(
        '--musdb',
        help='path to musdb',
        type=str
    )

    parser.add_argument(
        '--is-wav', help='Read musdb wav instead of stems',
        action='store_true',
    )

    args = parser.parse_args(inargs)
    mus = musdb.DB(root=args.musdb, is_wav=args.is_wav)

    if not args.o:
        output_dir = args.estimates_dir
    else:
        output_dir = args.o

    # evaluate an existing estimate folder with wav files
    eval_mus_dir(
        dataset=mus,  # instance of musdb
        estimates_dir=args.estimates_dir,  # path to estiamte folder
        output_dir=output_dir,  # set a folder to write eval json files
    ) 
开发者ID:sigsep,项目名称:sigsep-mus-eval,代码行数:40,代码来源:cli.py

示例8: mus

# 需要导入模块: import musdb [as 别名]
# 或者: from musdb import DB [as 别名]
def mus():
    return musdb.DB(download=True) 
开发者ID:sigsep,项目名称:sigsep-mus-eval,代码行数:4,代码来源:test_regression.py

示例9: produce_musdb_source_estimates

# 需要导入模块: import musdb [as 别名]
# 或者: from musdb import DB [as 别名]
def produce_musdb_source_estimates(model_config, load_model, musdb_path, output_path, subsets=None):
    '''
    Predicts source estimates for MUSDB for a given model checkpoint and configuration, and evaluate them.
    :param model_config: Model configuration of the model to be evaluated
    :param load_model: Model checkpoint path
    :return: 
    '''
    print("Evaluating trained model saved at " + str(load_model)+ " on MUSDB and saving source estimate audio to " + str(output_path))

    mus = musdb.DB(root_dir=musdb_path)
    predict_fun = lambda track : predict(track, model_config, load_model, output_path)
    assert(mus.test(predict_fun))
    mus.run(predict_fun, estimates_dir=output_path, subsets=subsets) 
开发者ID:f90,项目名称:Wave-U-Net,代码行数:15,代码来源:Evaluate.py

示例10: mus

# 需要导入模块: import musdb [as 别名]
# 或者: from musdb import DB [as 别名]
def mus(request, subset):
    return musdb.DB(
        root='data/MUS-STEMS-SAMPLE', is_wav=request.param, subsets=subset
    ) 
开发者ID:sigsep,项目名称:sigsep-mus-db,代码行数:6,代码来源:test_parser.py

示例11: mus

# 需要导入模块: import musdb [as 别名]
# 或者: from musdb import DB [as 别名]
def mus(request):
    return musdb.DB(root='data/MUS-STEMS-SAMPLE', is_wav=request.param) 
开发者ID:sigsep,项目名称:sigsep-mus-db,代码行数:4,代码来源:test_audio_classes.py

示例12: get_musdb_tracks

# 需要导入模块: import musdb [as 别名]
# 或者: from musdb import DB [as 别名]
def get_musdb_tracks(root, *args, **kwargs):
    mus = musdb.DB(root, *args, **kwargs)
    return {track.name: track.path for track in mus} 
开发者ID:facebookresearch,项目名称:demucs,代码行数:5,代码来源:compressed.py

示例13: getMUSDB

# 需要导入模块: import musdb [as 别名]
# 或者: from musdb import DB [as 别名]
def getMUSDB(database_path):
    mus = musdb.DB(root_dir=database_path, is_wav=False)

    subsets = list()

    for subset in ["train", "test"]:
        tracks = mus.load_mus_tracks(subset)
        samples = list()

        # Go through tracks
        for track in tracks:
            # Skip track if mixture is already written, assuming this track is done already
            track_path = track.path[:-4]
            mix_path = track_path + "_mix.wav"
            acc_path = track_path + "_accompaniment.wav"
            if os.path.exists(mix_path):
                print("WARNING: Skipping track " + mix_path + " since it exists already")

                # Add paths and then skip
                paths = {"mix" : mix_path, "accompaniment" : acc_path}
                paths.update({key : track_path + "_" + key + ".wav" for key in ["bass", "drums", "other", "vocals"]})

                samples.append(paths)

                continue

            rate = track.rate

            # Go through each instrument
            paths = dict()
            stem_audio = dict()
            for stem in ["bass", "drums", "other", "vocals"]:
                path = track_path + "_" + stem + ".wav"
                audio = track.targets[stem].audio
                soundfile.write(path, audio, rate, "PCM_16")
                stem_audio[stem] = audio
                paths[stem] = path

            # Add other instruments to form accompaniment
            acc_audio = np.clip(sum([stem_audio[key] for key in list(stem_audio.keys()) if key != "vocals"]), -1.0, 1.0)
            soundfile.write(acc_path, acc_audio, rate, "PCM_16")
            paths["accompaniment"] = acc_path

            # Create mixture
            mix_audio = track.audio
            soundfile.write(mix_path, mix_audio, rate, "PCM_16")
            paths["mix"] = mix_path

            diff_signal = np.abs(mix_audio - acc_audio - stem_audio["vocals"])
            print("Maximum absolute deviation from source additivity constraint: " + str(np.max(diff_signal)))# Check if acc+vocals=mix
            print("Mean absolute deviation from source additivity constraint:    " + str(np.mean(diff_signal)))

            samples.append(paths)

        subsets.append(samples)

    return subsets 
开发者ID:f90,项目名称:Wave-U-Net,代码行数:59,代码来源:Datasets.py

示例14: getMUSDB

# 需要导入模块: import musdb [as 别名]
# 或者: from musdb import DB [as 别名]
def getMUSDB(database_path):
    mus = musdb.DB(root=database_path, is_wav=False)

    subsets = list()

    for subset in ["train", "test"]:
        tracks = mus.load_mus_tracks(subset)
        samples = list()

        # Go through tracks
        for track in sorted(tracks):
            # Skip track if mixture is already written, assuming this track is done already
            track_path = track.path[:-4]
            mix_path = track_path + "_mix.wav"
            acc_path = track_path + "_accompaniment.wav"
            if os.path.exists(mix_path):
                print("WARNING: Skipping track " + mix_path + " since it exists already")

                # Add paths and then skip
                paths = {"mix" : mix_path, "accompaniment" : acc_path}
                paths.update({key : track_path + "_" + key + ".wav" for key in ["bass", "drums", "other", "vocals"]})

                samples.append(paths)

                continue

            rate = track.rate

            # Go through each instrument
            paths = dict()
            stem_audio = dict()
            for stem in ["bass", "drums", "other", "vocals"]:
                path = track_path + "_" + stem + ".wav"
                audio = track.targets[stem].audio
                write_wav(path, audio, rate)
                stem_audio[stem] = audio
                paths[stem] = path

            # Add other instruments to form accompaniment
            acc_audio = np.clip(sum([stem_audio[key] for key in list(stem_audio.keys()) if key != "vocals"]), -1.0, 1.0)
            write_wav(acc_path, acc_audio, rate)
            paths["accompaniment"] = acc_path

            # Create mixture
            mix_audio = track.audio
            write_wav(mix_path, mix_audio, rate)
            paths["mix"] = mix_path

            diff_signal = np.abs(mix_audio - acc_audio - stem_audio["vocals"])
            print("Maximum absolute deviation from source additivity constraint: " + str(np.max(diff_signal)))# Check if acc+vocals=mix
            print("Mean absolute deviation from source additivity constraint:    " + str(np.mean(diff_signal)))

            samples.append(paths)

        subsets.append(samples)

    print("DONE preparing dataset!")
    return subsets 
开发者ID:f90,项目名称:Wave-U-Net-Pytorch,代码行数:60,代码来源:data.py

示例15: musdb_convert

# 需要导入模块: import musdb [as 别名]
# 或者: from musdb import DB [as 别名]
def musdb_convert(inargs=None):
    """
    cli application to conver audio files to spectrogram images
    """
    parser = argparse.ArgumentParser()

    parser.add_argument(
        'musdb_root',
        type=str,
    )

    parser.add_argument(
        'output_root',
        type=str
    )

    parser.add_argument(
        '--download', action='store_true', default=False,
        help='use the downloaded 7s musdb stems',
    )

    parser.add_argument(
        '--extension', type=str, default='.wav', 
    )

    parser.add_argument(
        '--hop',
        type=int, default=1024,
        help='hop size in samples, defaults to `1024`'
    )

    args = parser.parse_args(inargs)

    mus = DB(root=args.musdb_root, download=args.download)

    for track in tqdm.tqdm(mus):

        track_estimate_dir = Path(
            args.output_root, track.subset, track.name
        )
        track_estimate_dir.mkdir(exist_ok=True, parents=True)
        # write out tracks to disk

        sf.write(
            track_estimate_dir / Path('mixture').with_suffix(args.extension),
            track.audio,
            track.rate
        )
        for name, track in track.targets.items():
            sf.write(
                track_estimate_dir / Path(name).with_suffix(args.extension),
                track.audio,
                track.rate
            ) 
开发者ID:sigsep,项目名称:sigsep-mus-db,代码行数:56,代码来源:tools.py


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