/** * Returns the processed Data output, basically calls * <code>getData()</code> on the last processor. * * @return a Data object that has been processed by the cepstrum * @throws DataProcessingException if a data processor error occurs */ @Override public Data getData() throws DataProcessingException { DataProcessor dp; dp = selectedDataProcessors.get(selectedDataProcessors.size() - 1); return dp.getData(); }
/** Returns a the next <code>DataProcessor</code> of type <code>predecClass</code> which precedes <code>dp</code> * * @param dp data processor * @param <T> predecessor class type * @param predecClass predecessor class * * @return frontend processor **/ public static <T extends DataProcessor> T getFrontEndProcessor(DataProcessor dp, Class<T> predecClass) { while (!predecClass.isInstance(dp)) { if (dp instanceof FrontEnd) dp = ((FrontEnd) dp).getLastDataProcessor(); else dp = dp.getPredecessor(); if (dp == null) return null; } return predecClass.cast(dp); } }
@Override public void initialize() { super.initialize(); for (DataProcessor dp : frontEndList) { dp.initialize(); } }
/** * Sets the source of data for this front end. It basically sets the predecessor of the first DataProcessor of this * front end. * * @param dataSource the source of data */ public void setDataSource(DataProcessor dataSource) { first.setPredecessor(dataSource); }
private void init() { this.timer = TimerPool.getTimer(this, "Frontend"); last = null; for (DataProcessor dp : frontEndList) { assert dp != null; if (last != null) dp.setPredecessor(last); if (first == null) { first = dp; } last = dp; } initialize(); }
private Data getNextData() throws DataProcessingException { Data d = getPredecessor().getData(); while (d != null && !(d instanceof DoubleData || d instanceof DataEndSignal || d instanceof DataStartSignal || d instanceof SpeechEndSignal)) { outputQueue.add(d); d = getPredecessor().getData(); } return d; }
/** * Sets the source of data for this front end. It basically sets the predecessor of the first DataProcessor of this * front end. * * @param dataSource the source of data */ public void setDataSource(DataProcessor dataSource) { first.setPredecessor(dataSource); }
@Override public void initialize() { super.initialize(); for (DataProcessor dataProcessor : selectedDataProcessors) dataProcessor.initialize(); }
/** * Returns a description of this FrontEnd in the format: <front end name> {<DataProcessor1>, <DataProcessor2> ... * <DataProcessorN>} * * @return a description of this FrontEnd */ @Override public String toString() { if (last == null) return super.toString() + " {}"; LinkedList<DataProcessor> list = new LinkedList<DataProcessor>(); for (DataProcessor current = last; current != null; current = current.getPredecessor()) list.addFirst(current); // add processors in their correct order StringBuilder description = new StringBuilder(super.toString()).append(" {"); for (DataProcessor dp : list) description.append(dp).append(", "); description.setLength(description.length() - 2); return description.append('}').toString(); }
/** * Read a Data object from the predecessor DataProcessor, and increment the ID count appropriately. * * @return the read Data object * @throws edu.cmu.sphinx.frontend.DataProcessingException */ private Data readData() throws DataProcessingException { Data frame = getPredecessor().getData(); if (frame != null) { id++; } return frame; } }
private void init() { this.timer = TimerPool.getTimer(this, "Frontend"); last = null; for (DataProcessor dp : frontEndList) { assert dp != null; if (last != null) dp.setPredecessor(last); if (first == null) { first = dp; } last = dp; } initialize(); }
@Override public void initialize() { super.initialize(); for (DataProcessor dp : frontEndList) { dp.initialize(); } }
/** Returns a the next <code>DataProcessor</code> of type <code>predecClass</code> which precedes <code>dp</code> * * @param dp data processor * @param <T> predecessor class type * @param predecClass predecessor class * * @return frontend processor **/ public static <T extends DataProcessor> T getFrontEndProcessor(DataProcessor dp, Class<T> predecClass) { while (!predecClass.isInstance(dp)) { if (dp instanceof FrontEnd) dp = ((FrontEnd) dp).getLastDataProcessor(); else dp = dp.getPredecessor(); if (dp == null) return null; } return predecClass.cast(dp); } }
@Override public Data getData() throws DataProcessingException { Data d = getPredecessor().getData(); assert isAudioStreamContinuous(d) : "audio stream is not continuous"; return d; }
@Override public void initialize() { super.initialize(); for (DataProcessor dataProcessor : selectedDataProcessors) dataProcessor.initialize(); }
/** * Returns a description of this FrontEnd in the format: <front end name> {<DataProcessor1>, <DataProcessor2> ... * <DataProcessorN>} * * @return a description of this FrontEnd */ @Override public String toString() { if (last == null) return super.toString() + " {}"; LinkedList<DataProcessor> list = new LinkedList<DataProcessor>(); for (DataProcessor current = last; current != null; current = current.getPredecessor()) list.addFirst(current); // add processors in their correct order StringBuilder description = new StringBuilder(super.toString()).append(" {"); for (DataProcessor dp : list) description.append(dp).append(", "); description.setLength(description.length() - 2); return description.append('}').toString(); }
/** * Reads and returns the next Data object from this DataProcessor, return * null if there is no more audio data. * * @return the next Data or <code>null</code> if none is available * @throws DataProcessingException * if there is a data processing error */ @Override public Data getData() throws DataProcessingException { Data input = getPredecessor().getData(); dumpData(input); return input; }
/** * Reads and returns the next Data frame or return <code>null</code> if no data is available. * * @return the next Data or <code>null</code> if none is available * @throws edu.cmu.sphinx.frontend.DataProcessingException * if there is a data processing error */ @Override public Data getData() throws DataProcessingException { Data input = getPredecessor().getData(); for (DataListener l : listeners) l.processDataFrame(input); return input; }
/** * Returns the next DoubleData object, which is the mel cepstrum of the input frame. Signals are returned * unmodified. * * @return the next available DoubleData melcepstrum, or Signal object, or null if no Data is available * @throws DataProcessingException if a data processing error occurred */ @Override public Data getData() throws DataProcessingException { Data input = getPredecessor().getData(); // get the spectrum if (input != null && input instanceof DoubleData) { input = process((DoubleData) input); } return input; }
/** * Reads the cepstra of the entire Utterance into the cepstraList. * * @return the number cepstra (with Data) read * @throws DataProcessingException if an error occurred reading the Data */ private int readUtterance() throws DataProcessingException { Data input = null; int numFrames = 0; while (true) { input = getPredecessor().getData(); if (input == null) { break; } else if (input instanceof DataEndSignal || input instanceof SpeechEndSignal) { cepstraList.add(input); break; } else if (input instanceof DoubleData) { cepstraList.add(input); double c0 = ((DoubleData)input).getValues()[0]; if (agc < c0) agc = c0; } else { // DataStartSignal or other Signal cepstraList.add(input); } numFrames++; } return numFrames; }