Ejemplo n.º 1
0
                    type=int,
                    default=5,
                    help='Number of hidden layers')
parser.add_argument('--learning_rate',
                    type=float,
                    default=0.001,
                    help='learning rate')
parser.add_argument('--stopping_loss',
                    type=float,
                    default=0.1,
                    help='loss at which training stops')
FLAGS, unparsed = parser.parse_known_args()

SAMPLE_RATE = 24000

inputs, targets = make_batch('assets/SMvocals.wav')
num_time_samples = inputs.shape[1]
num_channels = 1
gpu_fraction = 1

model = Model(num_time_samples=num_time_samples,
              num_channels=num_channels,
              gpu_fraction=gpu_fraction,
              num_layers=FLAGS.num_layers or 5,
              learning_rate=FLAGS.learning_rate,
              stopping_loss=FLAGS.stopping_loss)

tic = time()
model.train(inputs, targets)
toc = time()
Ejemplo n.º 2
0

from time import time

from wavenet.utils import make_batch
from wavenet.models import Model, Generator

from IPython.display import Audio

#get_ipython().magic(u'matplotlib inline')


# In[ ]:


inputs, targets = make_batch('assets/voice.wav')
num_time_samples = inputs.shape[1]
num_channels = 1
gpu_fraction = 1.0

model = Model(num_time_samples=num_time_samples,
              num_channels=num_channels,
              gpu_fraction=gpu_fraction)

Audio(inputs.reshape(inputs.shape[1]), rate=44100)


# In[ ]:


tic = time()
Ejemplo n.º 3
0
from time import time

from wavenet.utils import make_batch
from wavenet.models import Model, Generator

num_channels = 1
gpu_fraction = 1.0
num_classes = 2048

inputs, targets = make_batch('assets/voice.wav', num_classes)
num_time_samples = inputs.shape[1]

print inputs.shape, targets.shape, num_time_samples
model = Model(  #num_time_samples=num_time_samples,
    num_channels=num_channels,
    gpu_fraction=gpu_fraction,
    num_classes=num_classes,
    prob_model_type='softmax')

tic = time()
model.train(inputs, targets)
toc = time()
print('Training took {} seconds.'.format(toc - tic))
Ejemplo n.º 4
0
model = Model(num_time_samples=num_time_samples,
              num_channels=num_channels,
              gpu_fraction=gpu_fraction,
              num_classes=num_classes,
              num_blocks=num_blocks,
              num_layers=num_layers,
              num_hidden=num_hidden)

inputlist = []
targetlist = []

for w in WavList:

    path = 'assets/' + w + '.wav'
    inputs, targets = make_batch(path, sample_rate, duration=duration)
    inputlist.append(inputs)
    targetlist.append(targets)

inputlist = np.stack(inputlist)
targetlist = np.stack(targetlist)

print(inputlist.shape, targetlist.shape)

train_step, losses = model.train(
    inputlist.reshape((inputlist.shape[0], inputlist.shape[2], 1)),
    targetlist.reshape((targetlist.shape[0], -1)))

generator = Generator(model)

new_pred = generator.run([[np.random.randn()]], num_time_samples * 2)