Esempio n. 1
0
def test_stem_id():
    S, _ = stempeg.read_stems(stempeg.example_stem_path())
    for k in range(S.shape[0]):
        Sk, _ = stempeg.read_stems(stempeg.example_stem_path(), stem_id=k)
        # test number of channels
        assert Sk.shape[-1] == 2
        # test dim
        assert Sk.ndim == 2
Esempio n. 2
0
def test_nistems():
    mp4exc = stempeg.cmds.find_cmd("MP4Box")

    stems, rate = stempeg.read_stems(stempeg.example_stem_path())
    with tmp.NamedTemporaryFile(delete=False, suffix='.m4a') as tempfile:

        stempeg.write_stems(tempfile.name,
                            stems,
                            sample_rate=rate,
                            writer=stempeg.NIStemsWriter())
        callArgs = [mp4exc]
        callArgs.extend(["-dump-udta", "0:stem", tempfile.name])
        sp.check_call(callArgs)

        root, ext = os.path.splitext(tempfile.name)
        udtaFile = root + "_stem.udta"
        with open(stempeg.default_metadata()) as f:
            d_metadata = json.load(f)

        try:
            fileObj = codecs.open(udtaFile, encoding="utf-8")
            fileObj.seek(8)
            l_metadata = json.load(fileObj)
        except json.decoder.JSONDecodeError:
            with open(udtaFile) as json_file:
                l_metadata = json.load(json_file)

        assert ordered(l_metadata) == ordered(d_metadata)
Esempio n. 3
0
def test_duration(start, duration):
    fp = stempeg.example_stem_path()
    info = stempeg.Info(fp)
    if start:
        if start < min(info.duration_streams):
            S, _ = stempeg.read_stems(fp, start=start, duration=duration)
    else:
        S, rate = stempeg.read_stems(fp, start=start, duration=duration)
        if duration is not None:
            assert S.shape[1] == duration * rate
Esempio n. 4
0
def test_info():
    fp = stempeg.example_stem_path()
    info = stempeg.Info(fp)
    S, rate = stempeg.read_stems(fp, info=info)
Esempio n. 5
0
def test_outtype(dtype):
    S, rate = stempeg.read_stems(stempeg.example_stem_path(), out_type=dtype)
    assert S.dtype == dtype
Esempio n. 6
0
def test_shape():
    S, _ = stempeg.read_stems(stempeg.example_stem_path())
    assert S.shape[0] == 5
    assert ((S.shape[1] % 1024) == 0 and S.shape[1] > 200000)
    assert S.shape[2] == 2
Esempio n. 7
0
def test_stem_id():
    S, _ = stempeg.read_stems(stempeg.example_stem_path())
    for k in range(S.shape[0]):
        Sk, _ = stempeg.read_stems(stempeg.example_stem_path(), stem_id=k)
        assert Sk.ndim == 2
Esempio n. 8
0
import stempeg

# 0 - The mixture,
# 1 - The drums,
# 2 - The bass,
# 3 - The rest of the accompaniment,
# 4 - The vocals.

# example
S, rate = stempeg.read_stems(stempeg.example_stem_path())
stempeg.write_stems(
 "output.mp4",
 S,
 sample_rate=rate,
 writer=stempeg.StreamsWriter())

S, rate = stempeg.read_stems("C:/Users/hahla/Downloads/output.mp4", stem_id=[0])



stems_folder = "D:/Development/github/GAN-tests/audio_files_split/audio_files_001"

filename_mix = "D:/Development/github/GAN-tests/audio_files_split/audio_file_mixture_0002.wav"
filename_drums = "D:/Development/github/GAN-tests/audio_files_split/audio_file_hits_0002.wav"
filename_bass = "D:/Development/github/GAN-tests/audio_files_split/audio_file_soundless_audio_0002.wav"
filename_other = "D:/Development/github/GAN-tests/audio_files_split/audio_file_background_0002.wav"
filename_vocals = "D:/Development/github/GAN-tests/audio_files_split/audio_file_soundless_audio_0002.wav"

S_filename_mix, rate = stempeg.read_stems(filename_mix, stem_id=0)
Esempio n. 9
0
def test_write():
    S, rate = stempeg.read_stems(stempeg.example_stem_path())
    stempeg.write_stems(S, "./stems.mp4")