Esempio n. 1
0
def stream(batch_size=64):
    path = '/hdd/musicnet/train_data'
    pattern = '*.wav'

    samplerate = zounds.SR22050()
    feature_spec = {'spectrogram': (256, 128)}

    feature_funcs = {'spectrogram': (spectrogram, (samplerate, ))}

    bs = batch_stream(path, pattern, batch_size, feature_spec, 'spectrogram',
                      feature_funcs)
    return bs
Esempio n. 2
0
def repr_stream(repr_class):
    path = '/hdd/musicnet/train_data'
    pattern = '*.wav'

    total_samples = 2**17
    audio_channels = 1
    feature_spec = {'audio': (total_samples, audio_channels)}
    feature_funcs = {'audio': (audio, (samplerate, ))}
    batch_size = 2
    bs = batch_stream(path, pattern, batch_size, feature_spec, 'audio',
                      feature_funcs)

    for samples, in bs:
        rep = repr_class.from_audio(samples, samplerate)
        yield rep
def stream(total_samples=8192, batch_size=32):
    path = '/hdd/musicnet/train_data'
    pattern = '*.wav'

    samplerate = zounds.SR22050()
    # total_samples = 8192
    feature_spec = {'audio': (total_samples, 1)}

    feature_funcs = {'audio': (audio, (samplerate, ))}

    # batch_size = 32
    bs = batch_stream(path, pattern, batch_size, feature_spec, 'audio',
                      feature_funcs)
    for batch, in bs:
        transformed = IdentityPhaseReovery.from_audio(batch, samplerate)
        yield batch, transformed
Esempio n. 4
0
import zounds
import torch
import numpy as np
from matplotlib import pyplot as plt

path = '/hdd/musicnet/train_data'
pattern = '*.wav'
total_samples = 2**17

samplerate = zounds.SR22050()
feature_spec = {'audio': (total_samples, 1)}

feature_funcs = {'audio': (audio, (samplerate, ))}

batch_size = 1
bs = batch_stream(path, pattern, batch_size, feature_spec, 'audio',
                  feature_funcs)

if __name__ == '__main__':
    # app = zounds.ZoundsApp(locals=locals(), globals=globals())
    # app.start_in_thread(9999)
    # samples, = next(bs)
    # samples = torch.from_numpy(samples)
    # min_size = 2 ** (np.log2(total_samples) - 4)
    # bands = fft_frequency_decompose(samples, min_size)
    # samples = zounds.AudioSamples(samples.squeeze(), samplerate)
    # input('Waiting...')

    n_bands = 5
    sr = samplerate
    for i in range(n_bands):
        start_hz = 0 if i == (n_bands - 1) else sr.nyquist / 2