def oldresyncmain(): """Main driver for subtitle resyncing""" from nktrainutils import SGDSVM, splitTrainEval, evalSVM import librosa from cPickle import dump, load rate = 22050 if len(sys.argv) < 1: print "Usage: python %s <video or audio file> <subtitle file> <vad model>" % (sys.argv[0]) sys.exit() fname, subfname, modelfname = sys.argv[1:4] model = SGDSVM.load(modelfname) allfeats = getmel(fname) def featfunc(a, b): """concats feats from the given times""" a, b = int(a * 10), int(b * 10) ret = allfeats[:, a:b].transpose().flatten() return ret seglen = 0.5 subels = [] A, B = 0, 300 for start in range(A, B): feats = featfunc(start, start + seglen) cls = SGDSVM().classify(model, [feats])[0] subels.append(("Cls: %0.4f" % (cls), start, start + 1)) print start, cls sys.stdout.flush() # print subels playpreview(fname.replace(".mel", ""), subels, A, B)
def oldresyncmain(): """Main driver for subtitle resyncing""" from nktrainutils import SGDSVM, splitTrainEval, evalSVM import librosa from cPickle import dump, load rate = 22050 if len(sys.argv) < 1: print 'Usage: python %s <video or audio file> <subtitle file> <vad model>' % ( sys.argv[0]) sys.exit() fname, subfname, modelfname = sys.argv[1:4] model = SGDSVM.load(modelfname) allfeats = getmel(fname) def featfunc(a, b): """concats feats from the given times""" a, b = int(a * 10), int(b * 10) ret = allfeats[:, a:b].transpose().flatten() return ret seglen = 0.5 subels = [] A, B = 0, 300 for start in range(A, B): feats = featfunc(start, start + seglen) cls = SGDSVM().classify(model, [feats])[0] subels.append(('Cls: %0.4f' % (cls), start, start + 1)) print start, cls sys.stdout.flush() #print subels playpreview(fname.replace('.mel', ''), subels, A, B)