示例#1
0
config.set_string('-hmm', MODELDIR)
config.set_string('-lm', path.join(BASEDIR, 'etc/MultiWUW.lm'))
config.set_string('-dict', path.join(BASEDIR, 'etc/MultiWUW.dic'))

config.set_string('-logfn', '/dev/null')

# Decode streaming data.
decoder = Decoder(config)
"""
For IV get forward
"""
FinalResult = {}
ListOfFinalResult = []
with open(IV_FileIds) as fi:
    line = fi.readline().strip('\n')
    while (line):
        fileNameForward = BASEDIR + ForwardFeatDir + line + '.mfc'
        fileNameBackward = BASEDIR + ReverseFeatDir + line + '.mfc'
        #print fileName
        score1 = psDecode(fileNameForward)
        score2 = psDecode(fileNameBackward)
        #logmath = decoder.get_logmath()
        #print("Best hypothesis: ", hypothesis.hypstr, " model score: ", hypothesis.best_score, " confidence: ", hypothesis.prob)
        FinalResult = {"FileName": line, "Score1": score1, "Score2": score2}
        ListOfFinalResult.append(FinalResult)
        """
        CONTINUE
        """
        line = fi.readline().strip('\n')
dump.CSVDictWrite(BASEDIR + "IVResults.csv")
            }
            ListOfFinalResults.append(FinalResult)
            #print 'Best hypothesis: ', hypothesis.hypstr, " model score: ", hypothesis.best_score, " confidence: ", hypothesis.prob
            LatticeFile = outLattice + fNameOnly.replace("/", '-')
            #print 'LatticeFile: ' + LatticeFile
            decoder.get_lattice().write(LatticeFile + '.lat')
            decoder.get_lattice().write_htk(LatticeFile + '.htk')
            i = i + 1
            k = k + 1
            if (k == 17):
                k = 0
                sys.stdout.write('*')
                progress = 100 * i / TotalNoOfFiles
                #sys.stdout.write("Progress: %d%% \r" % (progress) )
                #sys.stdout.write("Input SNR: %d" % (snr) +" AM: "+ AM +" File: " + fNameOnly +" Progress: %d%%   \r" % (progress) )
                sys.stdout.flush()
    # Running perl WER test
    print "\n"

    dump.TextWrite(HypText, outDir + currentModel + ".txt")
    dump.CSVDictWrite(ListOfFinalResults,
                      outDir + "/All_" + currentModel + ".csv")
    hypFile = outDir + currentModel + ".txt"
    RefFile = BaseDir + "RefClean.txt"
    out_File = outDir + "WERReslts_" + currentModel + ".txt"
    print 'Finish, now Calculating Error Rate, please wait \n'
    perl_script = subprocess.Popen(
        ["perl", "./word_align.pl", '-silent', hypFile, RefFile, out_File])
    perl_script.wait()
    print '\n'
示例#3
0
ForScore1 = BaseDir + "MultiWUW-1-1_" + IVorOOV + "_Score1.log"
ForScore2 = BaseDir + "MultiWUW-1-1_" + IVorOOV + "_Score2.log"
outResult = BaseDir + IVorOOV + "_Scores.csv"
#out_File = BaseDir + "Noisy_" + str(inputSNR) +"db/" + currentModel
#print ("Storing result in: " + out_File)
FinalResults = {}
ListOfFinalResults = []
print("Getting results of input " + ForScore1)
Score1 = getScore(ForScore1)
Hypothesis = getHypotheses(
    ForScore1
)  # Hypotheses are correct only when extracted from forward decding (i.e. score1)
filesNames = getFileName(ForScore1)

Score2 = getScore(ForScore2)
print("Length of Score1: " + str(len(Score1)))
print("Length of Score2: " + str(len(Score2)))

for i in range(0, len(Score2)):
    #print ("Name",filesNames[i], "Hyp", Hypothesis[i],"Score1", Score1[i])
    #print ("Score2", Score2[i])
    FinalResults = {
        "Name": filesNames[i],
        "Hyp": Hypothesis[i],
        "Score1": Score1[i],
        "Score2": Score2[i]
    }
    ListOfFinalResults.append(FinalResults)
dump.CSVDictWrite(ListOfFinalResults, outResult)