/// <summary>
        /// Grows the emitting branches. This version applies a simple acoustic lookahead based upon the rate of change in the current acoustic score.
        /// </summary>
        protected void GrowEmittingBranches()
        {
            if (_acousticLookaheadFrames > 0F)
            {
                GrowTimer.Start();
                var bestScore = -Float.MAX_VALUE;
                foreach (var t in ActiveList)
                {
                    var score = t.Score + t.AcousticScore * _acousticLookaheadFrames;
                    if (score > bestScore)
                    {
                        bestScore = score;
                    }
                    //t.setWorkingScore(score);
                }
                var relativeBeamThreshold = bestScore + _relativeBeamWidth;
                this.LogDebug("RelativeBeamThreshold: {0}", relativeBeamThreshold.ToString("R"));

                foreach (var t in ActiveList)
                {
                    if (t.Score + t.AcousticScore * _acousticLookaheadFrames > relativeBeamThreshold)
                    {
                        CollectSuccessorTokens(t);
                    }
                }
                GrowTimer.Stop();
            }
            else
            {
                GrowBranches();
            }
        }
        /// <summary>
        /// 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.
        /// </summary>
        protected void GrowBranches()
        {
            GrowTimer.Start();
            var relativeBeamThreshold = ActiveList.GetBeamThreshold();

            //this.LogInfo("Frame: " + currentFrameNumber
            //            + " thresh : " + relativeBeamThreshold + " bs "
            //            + activeList.getBestScore() + " tok "
            //            + activeList.getBestToken());
            this.LogDebug("RelativeBeamThreshold: {0}", relativeBeamThreshold.ToString("R"));
            var tokenList = ActiveList;

            foreach (var token in tokenList)
            {
                if (token == null)
                {
                    break;
                }
                if (token.Score >= relativeBeamThreshold && AllowExpansion(token))
                {
                    CollectSuccessorTokens(token);
                }
            }


            //this.LogDebug(string.Format("ActiveList:{0} ",activeList.Count()));
            GrowTimer.Stop();
        }
Пример #3
0
        /// <summary>
        /// Goes through the fast match active list of tokens and expands each token,
        /// finding the set of successor tokens until all the successor tokens are emitting tokens.
        /// </summary>
        protected void GrowFastmatchBranches()
        {
            GrowTimer.Start();
            var oldActiveList = FastmatchActiveList;

            FastmatchActiveList = _fastmatchActiveListFactory.NewInstance();
            var fastmathThreshold = oldActiveList.GetBeamThreshold();
            // TODO more precise range of baseIds, remove magic number
            var frameCiScores = new float[100];

            Arrays.Fill(frameCiScores, -Float.MAX_VALUE);
            var frameMaxCiScore = -Float.MAX_VALUE;

            foreach (var token in oldActiveList)
            {
                var tokenScore = token.Score;
                if (tokenScore < fastmathThreshold)
                {
                    continue;
                }

                // filling max ci scores array that will be used in general search
                // token score composing
                if (token.SearchState is PhoneHmmSearchState)
                {
                    var baseId = ((PhoneHmmSearchState)token.SearchState).GetBaseId();
                    if (frameCiScores[baseId] < tokenScore)
                    {
                        frameCiScores[baseId] = tokenScore;
                    }
                    if (frameMaxCiScore < tokenScore)
                    {
                        frameMaxCiScore = tokenScore;
                    }
                }
                CollectFastMatchSuccessorTokens(token);
            }
            _ciScores.Add(new FrameCiScores(frameCiScores, frameMaxCiScore));
            GrowTimer.Stop();
        }
Пример #4
0
        /**
         * /// 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 HashMap <ISearchState, Token>(mapSize);
            ActiveList oldActiveList = ActiveList;

            ResultList     = new List <Token>();
            ActiveList     = ActiveListFactory.NewInstance();
            _threshold     = oldActiveList.GetBeamThreshold();
            _wordThreshold = oldActiveList.GetBestScore() + _logRelativeWordBeamWidth;

            foreach (Token token in oldActiveList)
            {
                CollectSuccessorTokens(token);
            }
            GrowTimer.Stop();
        }