public override Data getData() { object obj = null; if (this.streamEndReached) { if (!this.utteranceEndSent) { obj = new DataEndSignal(this.getDuration()); this.utteranceEndSent = true; } } else if (!this.utteranceStarted) { this.utteranceStarted = true; obj = new DataStartSignal(this.sampleRate); } else if (this.dataStream != null) { do { obj = this.readNextFrame(); }while ((DoubleData)obj != null && this.getDuration() < this.timeFrame.getStart()); if (((DoubleData)obj == null || this.getDuration() > this.timeFrame.getEnd()) && !this.utteranceEndSent) { obj = new DataEndSignal(this.getDuration()); this.utteranceEndSent = true; this.streamEndReached = true; } } else { this.logger.warning("Input stream is not set"); if (!this.utteranceEndSent) { obj = new DataEndSignal(this.getDuration()); this.utteranceEndSent = true; } } object obj2 = obj; Data result; if (obj2 != null) { if ((result = (obj2 as Data)) == null) { throw new IncompatibleClassChangeError(); } } else { result = null; } return(result); }
public override Data getData() { Data data; if (this.outputQueue.isEmpty()) { data = this.getPredecessor().getData(); if (data != null) { if (data is DoubleData) { DoubleData doubleData = (DoubleData)data; if (this.currentFirstSampleNumber == -1L) { this.currentFirstSampleNumber = doubleData.getFirstSampleNumber(); } this.createWindow(doubleData.getSampleRate()); this.process(doubleData); } else { if (data is DataStartSignal) { DataStartSignal dataStartSignal = (DataStartSignal)data; this.createWindow(dataStartSignal.getSampleRate()); Map props = dataStartSignal.getProps(); props.put("windowSize", Integer.valueOf(this.windowShift)); props.put("windowShift", Integer.valueOf(this.cosineWindow.Length)); this.currentFirstSampleNumber = -1L; } else if (data is SpeechStartSignal) { this.currentFirstSampleNumber = -1L; } else if (data is DataEndSignal || data is SpeechEndSignal) { this.processUtteranceEnd(); } this.outputQueue.add(data); } } } if (this.outputQueue.isEmpty()) { return(null); } data = (Data)this.outputQueue.remove(0); if (data is DoubleData && !RaisedCosineWindower.assertionsDisabled && ((DoubleData)data).getValues().Length != this.cosineWindow.Length) { throw new AssertionError(); } return(data); }
/// <summary> /// Reads and returns the next Data from the InputStream of /// StreamDataSource, return null if no data is read and end of file is /// reached. /// </summary> /// <returns>the next Data or <code>null</code> if none is available</returns> public override IData GetData() { IData output = null; if (_streamEndReached) { if (!_utteranceEndSent) { // since 'firstSampleNumber' starts at 0, the last // sample number should be 'totalValuesRead - 1' output = new DataEndSignal(Duration); _utteranceEndSent = true; } } else { if (!_utteranceStarted) { _utteranceStarted = true; output = new DataStartSignal(SampleRate); } else { if (_dataStream != null) { do { output = ReadNextFrame(); }while (output != null && Duration < _timeFrame.Start); if ((output == null || Duration > _timeFrame.End) && !_utteranceEndSent) { output = new DataEndSignal(Duration); _utteranceEndSent = true; _streamEndReached = true; } } else { this.LogInfo("Input stream is not set"); if (!_utteranceEndSent) { output = new DataEndSignal(Duration); _utteranceEndSent = true; } } } } return(output); }
public override Data getData() { object obj = null; if (this.streamEndReached) { if (!this.utteranceEndSent) { obj = this.createDataEndSignal(); this.utteranceEndSent = true; } } else if (!this.utteranceStarted) { this.utteranceStarted = true; obj = new DataStartSignal(this.sampleRate); } else if (this.dataStream != null) { obj = this.readNextFrame(); if ((Data)obj == null && !this.utteranceEndSent) { obj = this.createDataEndSignal(); this.utteranceEndSent = true; } } object obj2 = obj; Data result; if (obj2 != null) { if ((result = (obj2 as Data)) == null) { throw new IncompatibleClassChangeError(); } } else { result = null; } return(result); }
/** * Reads and returns the next Data from the InputStream of StreamDataSource, return null if no data is read and end * of file is reached. * * @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 */ public override IData GetData() { IData output = null; if (_streamEndReached) { if (!_utteranceEndSent) { // since 'firstSampleNumber' starts at 0, the last // sample number should be 'totalValuesRead - 1' output = CreateDataEndSignal(); _utteranceEndSent = true; } } else { if (!_utteranceStarted) { _utteranceStarted = true; output = new DataStartSignal(SampleRate); } else { if (DataStream != null) { output = ReadNextFrame(); if (output == null) { if (!_utteranceEndSent) { output = CreateDataEndSignal(); _utteranceEndSent = true; } } } } } return(output); }
public override Data getData() { object obj; if (this.curPoint == -1) { obj = new DataStartSignal(this.sampleRate); this.curPoint++; } else { if (this.curPoint == this.numPoints) { if (this.numPoints > 0) { this.firstSampleNumber = this.firstSampleNumber - (long)this.frameShift + (long)this.frameSize - 1L; } int num = this.curPoint; int num2 = this.cepstrumLength; int num3 = (num2 != -1) ? (num / num2) : (-num); int i = (num3 - 1) * this.frameShift + this.frameSize; long duration = ByteCodeHelper.d2l((double)i / (double)this.sampleRate * 1000.0); obj = new DataEndSignal(duration); try { this.binaryStream.close(); this.curPoint++; } catch (IOException ex) { throw new DataProcessingException("IOException closing cepstrum stream", ex); } goto IL_1B5; } if (this.curPoint > this.numPoints) { obj = null; } else { double[] array = new double[this.cepstrumLength]; int i = 0; while (i < this.cepstrumLength) { try { if (this.bigEndian) { array[i] = (double)this.binaryStream.readFloat(); } else { array[i] = (double)Utilities.readLittleEndianFloat(this.binaryStream); } this.curPoint++; } catch (IOException ex4) { throw new DataProcessingException("IOException reading from cepstrum stream", ex4); } i++; continue; } obj = new DoubleData(array, this.sampleRate, this.firstSampleNumber); this.firstSampleNumber += (long)this.frameShift; } } IL_1B5: object obj2 = obj; Data result; if (obj2 != null) { if ((result = (obj2 as Data)) == null) { throw new IncompatibleClassChangeError(); } } else { result = null; } return(result); }
/** Handles the first element in a feature-stream. * /// @param dataStartSignal*/ protected void handleDataStartSignal(DataStartSignal dataStartSignal) { Dictionary <String, Object> dataProps = dataStartSignal.getProps(); useSpeechSignals = dataProps.ContainsKey(DataStartSignal.SPEECH_TAGGED_FEATURE_STREAM) && (Boolean)dataProps[DataStartSignal.SPEECH_TAGGED_FEATURE_STREAM]; }
/// <summary> /// Returns the next Data object, which is the mel cepstrum of the input frame. However, it can also be other Data objects like DataStartSignal. /// </summary> /// <returns> /// The next available Data object, returns null if no Data object is available. /// </returns> /// <exception cref="System.Exception"> /// IOException closing cepstrum stream /// or /// IOException reading from cepstrum stream /// </exception> public override IData GetData() { IData data; if (_curPoint == -1) { data = new DataStartSignal(_sampleRate); _curPoint++; } else if (_curPoint == _numPoints) { if (_numPoints > 0) { _firstSampleNumber = (_firstSampleNumber - _frameShift + _frameSize - 1); } // send a DataEndSignal var numberFrames = _curPoint / _cepstrumLength; var totalSamples = (numberFrames - 1) * _frameShift + _frameSize; var duration = (long) ((totalSamples / (double)_sampleRate) * 1000.0); data = new DataEndSignal(duration); try { if (_binary) { _binaryStream.Close(); } else { _est.Close(); } _curPoint++; } catch (IOException ioe) { throw new Exception("IOException closing cepstrum stream", ioe); } } else if (_curPoint > _numPoints) { data = null; } else { var vectorData = new double[_cepstrumLength]; for (var i = 0; i < _cepstrumLength; i++) { try { if (_binary) { if (_bigEndian) { vectorData[i] = _binaryStream.ReadFloat(); } else { vectorData[i] = Utilities.ReadLittleEndianFloat(_binaryStream); } } else { vectorData[i] = _est.GetFloat("cepstrum data"); } _curPoint++; } catch (IOException ioe) { throw new Exception("IOException reading from cepstrum stream", ioe); } } // System.out.println("Read: " + curPoint); data = new DoubleData (vectorData, _sampleRate, _firstSampleNumber); _firstSampleNumber += _frameShift; // System.out.println(data); } return(data); }