Package edu.cmu.sphinx.decoder.search

Examples of edu.cmu.sphinx.decoder.search.Token


     * @param withFillers true if we want filler words included, false otherwise
     * @param wordTokenFirst true if the word tokens come before other types of tokens
     * @return the string of words
     */
    public List<WordResult> getTimedBestResult(boolean withFillers) {
        Token token = getBestToken();
        if (token == null) {
            return emptyList();
        } else {
            if (wordTokenFirst) {
                return getTimedWordPath(token, withFillers);
View Full Code Here


    }

    /** Returns a string representation of this object */
    @Override
    public String toString() {
        Token token = getBestToken();
        if (token == null) {
            return "";
        } else {
            return token.getWordPath();
        }
    }
View Full Code Here

    private int dumpBestPath(DataOutputStream out, CTLUtterance utt, Token token) throws IOException {

        if (token == null) return 0;

        Token pred = token.getPredecessor();
        int startFrame = dumpBestPath(out, utt, pred);
        if (token.isWord()) {

            int endFrame = token.getFrameNumber();
View Full Code Here


    @Override
    protected void handleResult(DataOutputStream out, CTLUtterance utt, Result result) throws IOException {
        System.out.println(utt + " --> " + result);
        Token token = result.getBestToken();
        dumpTokenTimes(token);
    }
View Full Code Here

     * @param result the result to dump
     */
    private void showFullPath(Result result) {
        if (showFullPath) {
            System.out.println();
            Token bestToken = result.getBestToken();
            if (bestToken != null) {
                bestToken.dumpTokenPath();
            } else {
                System.out.println("Null result");
            }
            System.out.println();
        }
View Full Code Here

     * @param result the result to dump
     */
    private void showFullPath(Result result) {
        if (showFullPath) {
            System.out.println();
            Token bestToken = result.getBestToken();
            if (bestToken != null) {
                bestToken.dumpTokenPath();
            } else {
                System.out.println("Null result");
            }
            System.out.println();
        }
View Full Code Here

   *
   * @param result
   *            Result object to collect counts from.
   */
  public void collect(SpeechResult result) throws Exception {
    Token token = result.getResult().getBestToken();
    float[] componentScore, featureVector, posteriors, tmean;
    float dnom, wtMeanVar, wtDcountVar, wtDcountVarMean, mean;
    int mId, len, cluster;

    if (token == null)
      throw new Exception("Best token not found!");

    do {
      FloatData feature = (FloatData) token.getData();
      SearchState ss = token.getSearchState();

      if (!(ss instanceof HMMSearchState && ss.isEmitting())) {
        token = token.getPredecessor();
        continue;
      }

      componentScore = token.calculateComponentScore(feature);
      featureVector = FloatData.toFloatData(feature).getValues();
      mId = (int) ((HMMSearchState)token.getSearchState()).getHMMState().getMixtureId();
      posteriors = this.computePosterios(componentScore);
      len = loader.getVectorLength()[0];

      for (int i = 0; i < componentScore.length; i++) {
        cluster = means.getClassIndex(mId
            * loader.getNumGaussiansPerState() + i);
        dnom = posteriors[i];
        if (dnom > 0.) {
          tmean = loader.getMeansPool().get(
              mId * loader.getNumGaussiansPerState() + i);

          for (int j = 0; j < featureVector.length; j++) {
            mean = posteriors[i] * featureVector[j];
            wtMeanVar = mean
                * loader.getVariancePool().get(mId
                    * loader.getNumGaussiansPerState()
                    + i)[j];
            wtDcountVar = dnom
                * loader.getVariancePool().get(mId
                    * loader.getNumGaussiansPerState()
                    + i)[j];

            for (int p = 0; p < featureVector.length; p++) {
              wtDcountVarMean = wtDcountVar * tmean[p];

              for (int q = p; q < featureVector.length; q++) {
                regLs[cluster][0][j][p][q] += wtDcountVarMean
                    * tmean[q];
              }
              regLs[cluster][0][j][p][len] += wtDcountVarMean;
              regRs[cluster][0][j][p] += wtMeanVar * tmean[p];
            }
            regLs[cluster][0][j][len][len] += wtDcountVar;
            regRs[cluster][0][j][len] += wtMeanVar;

          }
        }
      }

      token = token.getPredecessor();
    } while (token != null);
  }
View Full Code Here

    public Scoreable normalize(List<? extends Scoreable> scoreableList, Scoreable bestToken) {
        if (activeListProvider == null) {
            return bestToken;
        }

        Token normToken = activeListProvider.getActiveList().getBestToken();

        assert bestToken.getFrameNumber() == normToken.getFrameNumber() - 1 : "frame numbers should be equal for a meaningful normalization";

        float normScore = normToken.getScore();

        for (Scoreable scoreable : scoreableList) {
            if (scoreable instanceof Token) {
                scoreable.normalizeScore(normScore);
            }
View Full Code Here

            collectStatistics(result);
        } else {
            List<Token> tokenList = result.getActiveTokens().getTokens();
            if (!tokenList.isEmpty()) {
                Collections.sort(tokenList, Scoreable.COMPARATOR);
                Token bestToken = tokenList.get(0);
                int rank = 0;
                for (Token token : tokenList) {
                    float scoreDiff = bestToken.getScore() -
                            token.getScore();
                    assert scoreDiff >= 0;

                    token.getTokenProps().put(TOKEN_RANK, new TokenRank(rank++, scoreDiff));
                    assert tokenIsRanked(token);
View Full Code Here

     * Collects the absolute beam statistics
     *
     * @param result the result of interest
     */
    private void collectAbsoluteBeamStatistics(Result result) {
        Token token = result.getBestToken();
        int count = 0;
        int sumBeam = 0;
        maxAbsoluteBeam = 0;
        while (token != null) {
            if (token.isEmitting()) {
                TokenRank rank = (TokenRank) token.getTokenProps().get(TOKEN_RANK);
                if (rank != null) {
                    if (rank.getAbsoluteRank() > maxAbsoluteBeam) {
                        maxAbsoluteBeam = rank.getAbsoluteRank();
                    }
                    sumBeam += rank.getAbsoluteRank();
                    count++;
                } else {
                    if (token.getFrameNumber() > 0) {
                        System.out.println("Null rank! for " + token);
                    }
                }
            }
            token = token.getPredecessor();
        }

        if (count > 0) {
            avgAbsoluteBeam = sumBeam / count;
            if (maxAbsoluteBeam > totMaxAbsoluteBeam) {
View Full Code Here

TOP

Related Classes of edu.cmu.sphinx.decoder.search.Token

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.