@@ -0,0 +1,3393 @@
+/*%0A * Copyright 1999-2002 Carnegie Mellon University.  %0A * Portions Copyright 2002 Sun Microsystems, Inc.  %0A * Portions Copyright 2002 Mitsubishi Electronic Research Laboratories.%0A * All Rights Reserved.  Use is subject to license terms.%0A * %0A * See the file %22license.terms%22 for information on usage and%0A * redistribution of this file, and for a DISCLAIMER OF ALL %0A * WARRANTIES.%0A *%0A */%0A%0A%0Apackage edu.cmu.sphinx.frontend.endpoint;%0A%0Aimport edu.cmu.sphinx.frontend.Cepstrum;%0Aimport edu.cmu.sphinx.frontend.CepstrumSource;%0Aimport edu.cmu.sphinx.frontend.DataProcessor;%0Aimport edu.cmu.sphinx.frontend.Signal;%0A%0Aimport edu.cmu.sphinx.util.SphinxProperties;%0A%0Aimport java.io.IOException;%0A%0Aimport java.util.*;%0A%0A%0A/**%0A * Implements an simple single energy threshold endpointer.%0A *%0A */%0Apublic class SingleThresholdEndpointer extends DataProcessor implements Endpointer %7B%0A%0A%0A    private static final String PROP_PREFIX = %0A    %22edu.cmu.sphinx.frontend.endpoint.SingleThresholdEndpointer.%22;%0A%0A%0A    /**%0A     * The SphinxProperty for the energy level which is a lower bound%0A     * threshold at the energy is considered as speech.%0A     */%0A    public static final String PROP_ENERGY_THRESHOLD = %0A        PROP_PREFIX + %22energyThreshold%22;%0A%0A%0A    /**%0A     * The default value for PROP_START_LOW.%0A     */%0A    public static final float PROP_ENERGY_THRESHOLD_DEFAULT = 0.0f;%0A        %0A%0A    private CepstrumSource predecessor;  // where to pull Cepstra from%0A    private float energyThreshold;%0A%0A%0A    /**%0A     * Constructs an SingleThresholdEndpointer with the given name, context,%0A     * and CepstrumSource predecessor.%0A     *%0A     * @param name the name of this SingleThresholdEndpointer%0A     * @param context the context of the SphinxProperties this%0A     *    SingleThresholdEndpointer uses%0A     * @param props the SphinxProperties to read properties from%0A     * @param predecessor the CepstrumSource where this %0A     *    SingleThresholdEndpointer gets Cepstrum from%0A     *%0A     * @throws java.io.IOException%0A     */%0A    public void initialize(String name, String context, %0A                           SphinxProperties props,%0A                           CepstrumSource predecessor) throws IOException %7B%0A        super.initialize(name, context, props);%0A        setProperties();%0A        this.predecessor = predecessor;%0A    %7D%0A%0A%0A    /**%0A     * Reads the parameters needed from the static SphinxProperties object.%0A     */%0A    private void setProperties() %7B%0A        SphinxProperties properties = getSphinxProperties();%0A        energyThreshold%0A            = properties.getFloat(PROP_ENERGY_THRESHOLD,%0A                                  PROP_ENERGY_THRESHOLD_DEFAULT);%0A    %7D%0A%0A%0A    /**%0A     * Returns the next Cepstrum, which can be either Cepstrum with%0A     * data, or Cepstrum with a SPEECH_START or SPEECH_END signal.%0A     *%0A     * @return the next Cepstrum, or null if no Cepstrum is available%0A     *%0A     * @throws java.io.IOException if there is error reading the%0A     *    Cepstrum object%0A     *%0A     * @see Cepstrum%0A     */%0A    public Cepstrum getCepstrum() throws IOException %7B%0A       %0A        Cepstrum cepstrum = predecessor.getCepstrum();%0A        %0A        getTimer().start();%0A        %0A        while (cepstrum != null && cepstrum.hasContent() &&%0A               cepstrum.getEnergy() %3C energyThreshold) %7B%0A            cepstrum = predecessor.getCepstrum();%0A        %7D%0A%0A        getTimer().stop();%0A%0A        return cepstrum;%0A    %7D%0A%7D%0A

Adding an extremely simple endpointer that uses only one energy threshold.