-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.py
73 lines (66 loc) · 1.76 KB
/
test.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import time
startt = time.time()
import numpy as np
import load
from neural import Neural
from open_file import procces_file
from mel_from_mlf.transform import get_neighboring_mel
SAVE_PATH_SER = '/dev/Deep-learning/'
DIRECTORY_PATH = '/home/ura/Documents/Deep-learning/'
FILE = "test_wav/Vocaroo_s0JVyDMnSJYu"
WEIGHTS_FILE = 'weights_file.db'
ARR_SHAPE = [\
(100, 800),\
(800, 800),\
(800, 800),\
(800, 800),\
(800, 28)\
]
TIMES = 100
SHORTCARD = 256
SPEED = 0.01
DROP_INPUT = 0.2
DROP_HIDDEN = 0.6
PRINT_FROM = 10
PRINT_TO = 50
STEP_SHOW = 3
RHO = 0.9
EPSILON = 1e-4
STEP = 50
print "test"
trX, teX = load.loadMel("afterLDA100.db")
# trY, teY = load.loadRes()
trZ, teZ = load.loadLeter()
print "loaded"
neur = Neural()
# neur.load_from_file(WEIGHTS_FILE)
neur.init_model(ARR_SHAPE)
neur.train(trX, teX, trZ, teZ, epochs=TIMES)
neur.save_to_file(WEIGHTS_FILE)
# trT = neur.result(trX)
# teT = neur.result(teX)
# print "start train"
# neur2 = Neural()
# neur2.init_model([(55, 300), (300, 28)])
# neur2.train(trT, teT, trZ, teZ, epochs=TIMES)
# neur = Neural()
# neur.load_from_file(DIRECTORY_PATH + WEIGHTS_FILE)
# mel, res = procces_file(FILE)
# print res
# def translate(neur, mel):
# res = ['sil']
# for x in range(len(mel)):
# result = np.concatenate(get_neighboring_mel(mel, x, 4))
# # resu = SOUND_MAP[neur.predict([result])[0]]
# resu = neur.result([result])[0]
# for y in resu:
# if y > 0.05:
# print "{0:} {1:.1f} ".format(SOUND_MAP[resu.tolist().index(y)], y * 100),
# print
# # print resu, " ",
# # if res[-1] != resu:
# # res.append(resu)
# # print resu, " ",
endt = time.time()
# translate(neur, mel)
print endt - startt