def get_stream(batch_size, source_window=4000, target_window=1000, num_examples=5000): from fuel.datasets.youtube_audio import YouTubeAudio data = YouTubeAudio('XqaJ2Ol5cC4') train_stream = data.get_example_stream() train_stream = ForceFloatX(train_stream) window_stream = Window(0,source_window, target_window, overlapping=False, data_stream=train_stream) source_stream = FilterSources(window_stream, sources=('features',)) feats_stream = Mapping(source_stream, mfcc) targets_stream = FilterSources(window_stream, sources=('targets',)) targets_stream = Flatten(targets_stream) stream = Merge((feats_stream,targets_stream), sources = ('features','targets')) #Add a random Scheme? it_scheme = ConstantScheme(batch_size,num_examples) batched_stream = Batch(stream, it_scheme, strictness=1) return batched_stream
def get_stream(batch_size, source_window=4000, target_window=1000, num_examples=5000): from fuel.datasets.youtube_audio import YouTubeAudio data = YouTubeAudio('XqaJ2Ol5cC4') train_stream = data.get_example_stream() train_stream = ForceFloatX(train_stream) window_stream = Window(0, source_window, target_window, overlapping=False, data_stream=train_stream) source_stream = FilterSources(window_stream, sources=('features', )) feats_stream = Mapping(source_stream, mfcc) targets_stream = FilterSources(window_stream, sources=('targets', )) targets_stream = Flatten(targets_stream) stream = Merge((feats_stream, targets_stream), sources=('features', 'targets')) #Add a random Scheme? it_scheme = ConstantScheme(batch_size, num_examples) batched_stream = Batch(stream, it_scheme, strictness=1) return batched_stream
from fuel.datasets.youtube_audio import YouTubeAudio import matplotlib.pyplot as plt import numpy as np import scipy.io.wavfile from random import randint amp = 10000. data = YouTubeAudio('XqaJ2Ol5cC4') stream = data.get_example_stream() it = stream.get_epoch_iterator() track = next(it) track = track[0].reshape(-1) track = track/amp sample_rate = scipy.io.wavfile.read("/home/alex/fuel_data/XqaJ2Ol5cC4.wav")[0] total_len = track.shape[0] #input shape is expected to be #(batch_size, sequence_length, num_inputs) secs = 0.75 num_inputs = int(sample_rate*secs) seq_len = 20 example = seq_len*num_inputs #Setting appropriate length to account for the size of an example train_len = total_len*8/10/example*example valid_len = (total_len-train_len)/2/example*example test_len = (total_len-train_len)/2/example*example unused = total_len - train_len - valid_len - test_len
def get_sound(name): data = YouTubeAudio(name) stream = data.get_example_stream() it = stream.get_epoch_iterator() return next(it)[0][:, 0]