5 import scipy
.io
.wavfile
as wav
7 from python_speech_features
import mfcc
9 from keras
.models
import model_from_json
11 modelfile
= sys
.argv
[1]
12 hdf5file
= '{}.hdf5'.format(modelfile
[:-5])
14 with
open(modelfile
, 'r', encoding
='utf-8') as f
:
16 model
= model_from_json(json
)
17 model
.load_weights(hdf5file
)
19 (_
, winlen
, winstep
, _
) = modelfile
.split('_')
20 winlen
= float(winlen
)
21 winstep
= float(winstep
)
24 loss
='binary_crossentropy',
28 (rate
, sig
) = wav
.read(sys
.argv
[2], mmap
=True)
29 data
= mfcc(sig
, rate
, winlen
, winstep
, numcep
=13, appendEnergy
=True)
30 tgob
= pympi
.TextGrid(xmax
=winstep
*len(data
))
31 tier
= tgob
.add_tier('lyrics')
36 for i
in model
.predict(data
, batch_size
=32, verbose
=0):
37 # print('{}\t{}'.format(time, i))
39 if label
!= lastlabel
and time
-lasttime
> 0.5:
40 tier
.add_interval(lasttime
, time
, '*' if lastlabel
else '')
45 tgob
.to_file('/dev/stdout')