<commit_before>/*
 * Copyright 1999-2002 Carnegie Mellon University.  
 * Portions Copyright 2002 Sun Microsystems, Inc.  
 * Portions Copyright 2002 Mitsubishi Electronic Research Laboratories.
 * All Rights Reserved.  Use is subject to license terms.
 * 
 * See the file "license.terms" for information on usage and
 * redistribution of this file, and for a DISCLAIMER OF ALL 
 * WARRANTIES.
 *
 */


package edu.cmu.sphinx.frontend;

import edu.cmu.sphinx.util.SphinxProperties;
import edu.cmu.sphinx.util.Timer;

import java.io.InputStream;
import java.io.IOException;

import java.util.HashMap;
import java.util.Map;

import java.util.logging.Level;
import java.util.logging.Logger;

/**
 * Pre-processes the audio into Features. The BaseFrontEnd consists
 * of a series of processors. The BaseFrontEnd connects all the processors
 * by the input and output points.
 * 
 * <p>The input to the BaseFrontEnd is a DataSource object.
 * For an audio stream,
 * the <code>StreamAudioSource</code> should be used. The 
 * input can also be a file containing a list of audio files, in which case
 * the <code>BatchFileAudioSource</code> can be used.
 * Currently, this BaseFrontEnd can also take Cepstrum objects as
 * input using the StreamCepstrumSource implementation of DataSource.
 *
 * <p>The output of the BaseFrontEnd are FeatureFrames, which is
 * an array of Features. This BaseFrontEnd enforces the condition that
 * every utterance starts with a Feature that contains the signal 
 * <code>Signal.UTTERANCE_START</code>, and ends with a Feature that 
 * contains the signal <code>Signal.UTTERANCE_END</code>.
 *
 * <p>To obtain a <code>FeatureFrame</code> with 10 Features from the 
 * BaseFrontEnd, you do:
 * <pre>
 * BaseFrontEnd.getFeatureFrame(10);
 * </pre>
 * If there are only 5 Features left, it will return a FeatureFrame with
 * 5 Features, followed by a Feature with a <code>Signal.UTTERANCE_END</code>
 * Signal.
 *
 * This BaseFrontEnd contains all the "standard" frontend processors like<commit_msg>Added more javadocs describing the error conditions of the BaseFrontEnd.<commit_after>/*
 * Copyright 1999-2002 Carnegie Mellon University.  
 * Portions Copyright 2002 Sun Microsystems, Inc.  
 * Portions Copyright 2002 Mitsubishi Electronic Research Laboratories.
 * All Rights Reserved.  Use is subject to license terms.
 * 
 * See the file "license.terms" for information on usage and
 * redistribution of this file, and for a DISCLAIMER OF ALL 
 * WARRANTIES.
 *
 */


package edu.cmu.sphinx.frontend;

import edu.cmu.sphinx.util.SphinxProperties;
import edu.cmu.sphinx.util.Timer;

import java.io.InputStream;
import java.io.IOException;

import java.util.HashMap;
import java.util.Map;

import java.util.logging.Level;
import java.util.logging.Logger;


/**
 * Pre-processes the audio into Features. The BaseFrontEnd consists
 * of a series of processors. The BaseFrontEnd connects all the processors
 * by the input and output points.
 * 
 * <p>The input to the BaseFrontEnd is a DataSource object.
 * For an audio stream,
 * the <code>StreamAudioSource</code> should be used. The 
 * input can also be a file containing a list of audio files, in which case
 * the <code>BatchFileAudioSource</code> can be used.
 * Currently, this BaseFrontEnd can also take Cepstrum objects as
 * input using the StreamCepstrumSource implementation of DataSource.
 *
 * <p>For each utterance, this BaseFrontEnd expects either Audio or
 * Cepstrum frames (or objects) in the following sequence: <code>
 * Signal.UTTERANCE_START
 * Audio or Cepstrum
 * Audio or Cepstrum
 * ...
 * Signal.UTTERANCE_END
 *
 * <p>Any other sequence will cause this BaseFrontEnd to throw errors.
 *
 * <p>If the front end gets a null frame OUTSIDE an utterance, 
 * it just returns a null frame. If the front end gets a null frame
 * INSIDE an utterance, it throws an Error. Therefore, there cannot be
 * a null frame (or object) in between the Signal.UTTERANCE_START and
 * Signal.UTTERANCE_END. The implementation of DataSource given to
 * the BaseFrontEnd in the constructor must make sure that these
 * conditions hold.
 *
 * <p>The output of the BaseFrontEnd are FeatureFrames, which is
 * an array of Features. This BaseFrontEnd enforces the condition that
 * every utterance starts with a Feature that contains the signal 
 * <code>Signal.UTTERANCE_START</code>, and ends with a Feature that 
 * contains the signal <code>Signal.UTTERANCE_END</code>.
 *
 * <p>To obtain a <code>FeatureFrame</code> with 10 Features from the 
 * BaseFrontEnd, you do:
 * <pre>
 * BaseFrontEnd.getFeatureFrame(10);
 * </pre>
 * If there are only 5 Features left, it will return a FeatureFrame with
 * 5 Features, followed by a Feature with a <code>Signal.UTTERANCE_END</code>
 * Signal.
 *
 * This BaseFrontEnd contains all the "standard" frontend processors like
{'fraction_non_alphanumeric': 0.07720891824938067, 'fraction_numerical': 0.009083402146985962, 'mean_word_length': 4.181818181818182, 'pattern_counts': {'":': 0, '<': 41, '<?xml version=': 0, '>': 41, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4320208', 'n_tokens_mistral': 1466, 'n_tokens_neox': 1362, 'n_words': 576}