-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprocess.py
executable file
·50 lines (40 loc) · 1.58 KB
/
process.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/python
import traceback
from scipy.io import wavfile
import tensorflow as tf
import numpy as np
import random
import json
import itertools
import math
import time
import matplotlib.pyplot as plt
import params
import model
import train
import argparse
print params.parameters
parser = argparse.ArgumentParser()
parser.add_argument('--model', type=str, default=None,
help='The name of the saved checkpoint to start training from. For example "sound-model". ' +
'The default value is empty and that means starting training from scratch. ' +
'Note that despite the name given here, the trained model will always be saved in ' +
'a file named "sound-model"')
args = parser.parse_args()
sample_freq, snd = wavfile.read('corpus.wav')
sample_freq_test, test = wavfile.read('test.wav')
snd = snd / (2.**15)
snd_test = test / (2.**15)
training_data = snd[:,0]
testing_data = snd_test[:,0]
print "Length of training data: ", len(training_data)
print "Length of test data: ", len(testing_data)
parameters = params.parameters
trainable_model = None
# Note that this model is too large to run on a normal GPU. Trying to run it on GPU only gives you
# grey hairs prematurely. If you want a model that can be run on a very high-end GPU, try the ibab Wavenet
# implementation from GitHub.
with tf.device("/cpu:0"):
trainable_model = model.create(params.parameters)
train.train(params.parameters, trainable_model, training_data, testing_data, starting_model=args.model,
minutes=60 * 24 * 7, loss_improved_limit=10000)