def validateNN( nnfile ): try: res = loadNN( nnfile ) if res is not None: print "Valid NeuralNet file." else: print "INVALID NeuralNet file, please regenerate." except: print "INVALID NeuralNet file, please regenerate."
def testWord( nnfile, word ): pcas, phones, nn = loadNN( nnfile ) fgen = FeatureGenerator(None) wordc = [c for c in word.lower()] vectors = fgen.word_vectors( wordc ) print "For word: %s"%word # print "Phonemes: %d, %s"%(len(phones),str(phones)) for c, v in vectors: pp = zip( nn.run(v), phones ) # print sorted(pp,reverse=True) (_,best_pronunciation) = sorted(pp,reverse=True)[0] print "char: %s, pronunciation: %s"%(c,best_pronunciation)