/** * Goes through the active list of tokens and expands each token, finding * the set of successor tokens until all the successor tokens are emitting * tokens. */ protected void growBranches() { int mapSize = activeList.size() * 10; if (mapSize == 0) { mapSize = 1; } growTimer.start(); bestTokenMap = new Dictionary <SearchState, Token>(mapSize); ActiveList oldActiveList = activeList; resultList = new List <Token>(); activeList = activeListFactory.newInstance(); threshold = oldActiveList.getBeamThreshold(); wordThreshold = oldActiveList.getBestScore() + logRelativeWordBeamWidth; var tokens = JavaToCs.GetTokenCollection(oldActiveList); foreach (Token token in tokens) { collectSuccessorTokens(token); } growTimer.stop(); if (logger.IsInfoEnabled) { int hmms = activeList.size(); totalHmms += hmms; logger.Info("Frame: " + currentFrameNumber + " Hmms: " + hmms + " total " + totalHmms); } }
/** * Counts all the tokens in the active list (and displays them). This is an * expensive operation. */ protected void showTokenCount() { if (logger.IsInfoEnabled) { HashSet <Token> tokenSet = new HashSet <Token>(); var tokens = JavaToCs.GetTokenCollection(activeList); foreach (Token token in tokens) { var tok = token; while (tok != null) { tokenSet.Add(tok); tok = tok.getPredecessor(); } } logger.Info("Token Lattice size: " + tokenSet.Count); tokenSet = new HashSet <Token>(); foreach (Token token in resultList) { var tok = token; while (tok != null) { tokenSet.Add(tok); tok = tok.getPredecessor(); } } logger.Info("Result Lattice size: " + tokenSet.Count); } }
/** * Because the growBranches() is called although no data is left after the * last speech frame, the ordering of the active-list might depend on the * transition probabilities and (penalty-scores) only. Therefore we need to * undo the last grow-step up to final states or the last emitting state in * order to fix the list. * * @return newly created list */ protected ActiveList undoLastGrowStep() { ActiveList fixedList = activeList.newInstance(); var tokens = JavaToCs.GetTokenCollection(activeList); foreach (Token token in tokens) { Token curToken = token.getPredecessor(); // remove the final states that are not the real final ones because // they're just hide prior final tokens: while (curToken.getPredecessor() != null && ((curToken.isFinal() && curToken.getPredecessor() != null && !curToken .getPredecessor().isFinal()) || (curToken.isEmitting() && curToken.getData() == null) // the // so // long // not // scored // tokens || (!curToken.isFinal() && !curToken.isEmitting()))) { curToken = curToken.getPredecessor(); } fixedList.add(curToken); } return(fixedList); }