protected internal override Data computeNextFeature() { DoubleData doubleData = this.cepstraBuffer[this.currentPosition]; float[] array = new float[(this.window * 2 + 1) * doubleData.getValues().Length]; int num = 0; for (int i = -this.window; i <= this.window; i++) { int num2 = this.currentPosition + i + this.cepstraBufferSize; int cepstraBufferSize = this.cepstraBufferSize; int num3 = (cepstraBufferSize != -1) ? (num2 % cepstraBufferSize) : 0; double[] values = this.cepstraBuffer[num3].getValues(); double[] array2 = values; int num4 = array2.Length; for (int j = 0; j < num4; j++) { double num5 = array2[j]; float[] array3 = array; int num6 = num; num++; array3[num6] = (float)num5; } } int num7 = this.currentPosition + 1; int cepstraBufferSize2 = this.cepstraBufferSize; this.currentPosition = ((cepstraBufferSize2 != -1) ? (num7 % cepstraBufferSize2) : 0); return(new FloatData(array, doubleData.getSampleRate(), doubleData.getFirstSampleNumber())); }
private DoubleData process(DoubleData doubleData) { double[] values = doubleData.getValues(); if (this.criticalBandFilter == null || this.sampleRate != doubleData.getSampleRate()) { this.numberFftPoints = values.Length - 1 << 1; this.sampleRate = doubleData.getSampleRate(); this.buildCriticalBandFilterbank(); this.buildEqualLoudnessScalingFactors(); } else if (values.Length != (this.numberFftPoints >> 1) + 1) { string text = new StringBuilder().append("Window size is incorrect: in.length == ").append(values.Length).append(", numberFftPoints == ").append((this.numberFftPoints >> 1) + 1).toString(); throw new IllegalArgumentException(text); } double[] array = new double[this.numberFilters]; for (int i = 0; i < this.numberFilters; i++) { array[i] = this.criticalBandFilter[i].filterOutput(values); double[] array2 = array; int num = i; double[] array3 = array2; array3[num] *= this.equalLoudnessScaling[i]; } return(new DoubleData(array, doubleData.getSampleRate(), doubleData.getFirstSampleNumber())); }
private bool isAudioStreamContinuous(Data data) { if (data is DoubleData) { DoubleData doubleData = (DoubleData)data; if (this.lastSampleNum != -1L && this.lastSampleNum != doubleData.getFirstSampleNumber()) { return(false); } this.lastSampleNum = doubleData.getFirstSampleNumber() + (long)doubleData.getValues().Length; } else if (data is DataStartSignal) { this.lastSampleNum = -1L; } return(true); }
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); }
public static FloatData DoubleData2FloatData(DoubleData data) { int num = data.getValues().Length; float[] array = new float[num]; double[] values = data.getValues(); for (int i = 0; i < values.Length; i++) { array[i] = (float)values[i]; } return(new FloatData(array, data.getSampleRate(), data.getFirstSampleNumber())); }
private Data process(DoubleData doubleData) { double[] values = doubleData.getValues(); if (values.Length != this.numberPLPFilters) { string text = new StringBuilder().append("PLPSpectrum size is incorrect: plpspectrum.length == ").append(values.Length).append(", numberPLPFilters == ").append(this.numberPLPFilters).toString(); throw new IllegalArgumentException(text); } double[] array = this.powerLawCompress(values); double[] autocor = this.applyCosine(array); LinearPredictor linearPredictor = new LinearPredictor(this.LPCOrder); linearPredictor.getARFilter(autocor); double[] data = linearPredictor.getData(this.cepstrumSize); return(new DoubleData(data, doubleData.getSampleRate(), doubleData.getFirstSampleNumber())); }
private DoubleData process(Data data) { if (!Dither.assertionsDisabled && !(data is DoubleData)) { throw new AssertionError(); } DoubleData doubleData = (DoubleData)data; double[] values = doubleData.getValues(); double[] array = new double[values.Length]; for (int i = 0; i < values.Length; i++) { array[i] = (double)(this.r.nextFloat() * 2f) * this.ditherMax - this.ditherMax + values[i]; array[i] = Math.max(Math.min(array[i], this.maxValue), this.minValue); } return(new DoubleData(array, doubleData.getSampleRate(), doubleData.getFirstSampleNumber())); }
private DoubleData process(DoubleData doubleData) { double[] values = doubleData.getValues(); if (this.numberFftPoints < values.Length) { int i; for (i = 0; i < this.numberFftPoints; i++) { this.inputFrame[i].set(values[i], (double)0f); } while (i < values.Length) { this.tempComplex.set(values[i], (double)0f); Complex[] array = this.inputFrame; int num = i; int num2 = this.numberFftPoints; Complex complex = array[(num2 != -1) ? (num % num2) : 0]; Complex[] array2 = this.inputFrame; int num3 = i; int num4 = this.numberFftPoints; complex.addComplex(array2[(num4 != -1) ? (num3 % num4) : 0], this.tempComplex); i++; } } else { int i; for (i = 0; i < values.Length; i++) { this.inputFrame[i].set(values[i], (double)0f); } while (i < this.numberFftPoints) { this.inputFrame[i].reset(); i++; } } double[] array3 = new double[(this.numberFftPoints >> 1) + 1]; this.recurseFft(this.inputFrame, array3, this.numberFftPoints, this.invert); return(new DoubleData(array3, doubleData.getSampleRate(), doubleData.getFirstSampleNumber())); }
private DoubleData process(DoubleData doubleData) { double[] values = doubleData.getValues(); if (this.melcosine == null) { this.numberMelFilters = values.Length; this.computeMelCosine(); } else if (values.Length != this.numberMelFilters) { string text = new StringBuilder().append("MelSpectrum size is incorrect: melspectrum.length == ").append(values.Length).append(", numberMelFilters == ").append(this.numberMelFilters).toString(); throw new IllegalArgumentException(text); } for (int i = 0; i < values.Length; i++) { values[i] = Math.log(values[i] + 0.0001); } double[] values2 = this.applyMelCosine(values); return(new DoubleData(values2, doubleData.getSampleRate(), doubleData.getFirstSampleNumber())); }
private DoubleData process(DoubleData doubleData) { double[] values = doubleData.getValues(); if (this.filter == null || this.sampleRate != doubleData.getSampleRate()) { this.numberFftPoints = values.Length - 1 << 1; this.sampleRate = doubleData.getSampleRate(); this.buildFilterbank(this.numberFftPoints, this.numberFilters, this.minFreq, this.maxFreq); } else if (values.Length != (this.numberFftPoints >> 1) + 1) { string text = new StringBuilder().append("Window size is incorrect: in.length == ").append(values.Length).append(", numberFftPoints == ").append((this.numberFftPoints >> 1) + 1).toString(); throw new IllegalArgumentException(text); } double[] array = new double[this.numberFilters]; for (int i = 0; i < this.numberFilters; i++) { array[i] = this.filter[i].filterOutput(values); } return(new DoubleData(array, this.sampleRate, doubleData.getFirstSampleNumber())); }
protected internal override Data computeNextFeature() { int num = this.currentPosition - 1 + this.cepstraBufferSize; int cepstraBufferSize = this.cepstraBufferSize; int num2 = (cepstraBufferSize != -1) ? (num % cepstraBufferSize) : 0; int num3 = this.currentPosition - 2 + this.cepstraBufferSize; int cepstraBufferSize2 = this.cepstraBufferSize; int num4 = (cepstraBufferSize2 != -1) ? (num3 % cepstraBufferSize2) : 0; int num5 = this.currentPosition - 3 + this.cepstraBufferSize; int cepstraBufferSize3 = this.cepstraBufferSize; int num6 = (cepstraBufferSize3 != -1) ? (num5 % cepstraBufferSize3) : 0; int num7 = this.currentPosition - 4 + this.cepstraBufferSize; int cepstraBufferSize4 = this.cepstraBufferSize; int num8 = (cepstraBufferSize4 != -1) ? (num7 % cepstraBufferSize4) : 0; int num9 = this.currentPosition + 1; int cepstraBufferSize5 = this.cepstraBufferSize; int num10 = (cepstraBufferSize5 != -1) ? (num9 % cepstraBufferSize5) : 0; int num11 = this.currentPosition + 2; int cepstraBufferSize6 = this.cepstraBufferSize; int num12 = (cepstraBufferSize6 != -1) ? (num11 % cepstraBufferSize6) : 0; int num13 = this.currentPosition + 3; int cepstraBufferSize7 = this.cepstraBufferSize; int num14 = (cepstraBufferSize7 != -1) ? (num13 % cepstraBufferSize7) : 0; int num15 = this.currentPosition + 4; int cepstraBufferSize8 = this.cepstraBufferSize; int num16 = (cepstraBufferSize8 != -1) ? (num15 % cepstraBufferSize8) : 0; DoubleData doubleData = this.cepstraBuffer[this.currentPosition]; double[] values = this.cepstraBuffer[num16].getValues(); double[] values2 = this.cepstraBuffer[num14].getValues(); double[] values3 = this.cepstraBuffer[num12].getValues(); double[] values4 = this.cepstraBuffer[num10].getValues(); double[] values5 = doubleData.getValues(); double[] values6 = this.cepstraBuffer[num2].getValues(); double[] values7 = this.cepstraBuffer[num4].getValues(); double[] values8 = this.cepstraBuffer[num6].getValues(); double[] values9 = this.cepstraBuffer[num8].getValues(); float[] array = new float[values5.Length * 3]; int num17 = this.currentPosition + 1; int cepstraBufferSize9 = this.cepstraBufferSize; this.currentPosition = ((cepstraBufferSize9 != -1) ? (num17 % cepstraBufferSize9) : 0); int num18 = 0; double[] array2 = values5; int num19 = array2.Length; for (int i = 0; i < num19; i++) { double num20 = array2[i]; float[] array3 = array; int num21 = num18; num18++; array3[num21] = (float)num20; } for (int j = 0; j < values3.Length; j++) { float[] array4 = array; int num22 = num18; num18++; array4[num22] = (float)(2.0 * values3[j] + values4[j] - values6[j] - 2.0 * values7[j]) / 10f; } for (int j = 0; j < values2.Length; j++) { float[] array5 = array; int num23 = num18; num18++; array5[num23] = (float)(4.0 * values[j] + 4.0 * values2[j] + values3[j] - 4.0 * values4[j] - 10.0 * values5[j] + (4.0 * values9[j] + 4.0 * values8[j] + values7[j] - 4.0 * values6[j])) / 100f; } return(new FloatData(array, doubleData.getSampleRate(), doubleData.getFirstSampleNumber())); }
public override Data getData() { object obj = this.readData(); if ((Data)obj != null) { if (!(((Data)obj) is Signal)) { int num = this.id; int num2 = this.dropEveryNthFrame; if (((num2 != -1) ? (num % num2) : 0) == this.dropEveryNthFrame - 1) { if (this.replaceNthWithPrevious) { if (((Data)obj) is FloatData) { FloatData floatData = (FloatData)this.lastFeature; obj = new FloatData(floatData.getValues(), floatData.getSampleRate(), floatData.getFirstSampleNumber()); } else { DoubleData doubleData = (DoubleData)this.lastFeature; obj = new DoubleData(doubleData.getValues(), doubleData.getSampleRate(), doubleData.getFirstSampleNumber()); } } else { obj = this.readData(); } } } if (obj != null) { if (obj is DataEndSignal) { this.id = -1; } if (obj is FloatData) { object obj2 = obj; Data data; if (obj2 != null) { if ((data = (obj2 as Data)) == null) { throw new IncompatibleClassChangeError(); } } else { data = null; } this.lastFeature = data; } else { this.lastFeature = null; } } else { this.lastFeature = null; } } object obj3 = obj; Data result; if (obj3 != null) { if ((result = (obj3 as Data)) == null) { throw new IncompatibleClassChangeError(); } } else { result = null; } return(result); }
protected internal override Data computeNextFeature() { int num = this.currentPosition - 1 + this.cepstraBufferSize; int cepstraBufferSize = this.cepstraBufferSize; int num2 = (cepstraBufferSize != -1) ? (num % cepstraBufferSize) : 0; int num3 = this.currentPosition - 2 + this.cepstraBufferSize; int cepstraBufferSize2 = this.cepstraBufferSize; int num4 = (cepstraBufferSize2 != -1) ? (num3 % cepstraBufferSize2) : 0; int num5 = this.currentPosition - 3 + this.cepstraBufferSize; int cepstraBufferSize3 = this.cepstraBufferSize; int num6 = (cepstraBufferSize3 != -1) ? (num5 % cepstraBufferSize3) : 0; int num7 = this.currentPosition + 1; int cepstraBufferSize4 = this.cepstraBufferSize; int num8 = (cepstraBufferSize4 != -1) ? (num7 % cepstraBufferSize4) : 0; int num9 = this.currentPosition + 2; int cepstraBufferSize5 = this.cepstraBufferSize; int num10 = (cepstraBufferSize5 != -1) ? (num9 % cepstraBufferSize5) : 0; int num11 = this.currentPosition + 3; int cepstraBufferSize6 = this.cepstraBufferSize; int num12 = (cepstraBufferSize6 != -1) ? (num11 % cepstraBufferSize6) : 0; DoubleData doubleData = this.cepstraBuffer[this.currentPosition]; double[] values = this.cepstraBuffer[num12].getValues(); double[] values2 = this.cepstraBuffer[num10].getValues(); double[] values3 = this.cepstraBuffer[num8].getValues(); double[] values4 = doubleData.getValues(); double[] values5 = this.cepstraBuffer[num2].getValues(); double[] values6 = this.cepstraBuffer[num4].getValues(); double[] values7 = this.cepstraBuffer[num6].getValues(); float[] array = new float[values4.Length * 3]; int num13 = this.currentPosition + 1; int cepstraBufferSize7 = this.cepstraBufferSize; this.currentPosition = ((cepstraBufferSize7 != -1) ? (num13 % cepstraBufferSize7) : 0); int num14 = 0; double[] array2 = values4; int num15 = array2.Length; for (int i = 0; i < num15; i++) { double num16 = array2[i]; float[] array3 = array; int num17 = num14; num14++; array3[num17] = (float)num16; } for (int j = 0; j < values2.Length; j++) { float[] array4 = array; int num18 = num14; num14++; array4[num18] = (float)(values2[j] - values6[j]); } for (int j = 0; j < values.Length; j++) { float[] array5 = array; int num19 = num14; num14++; array5[num19] = (float)(values[j] - values5[j] - (values3[j] - values7[j])); } return(new FloatData(array, doubleData.getSampleRate(), doubleData.getFirstSampleNumber())); }
public override Data getData() { object obj = this.getPredecessor().getData(); if (((Data)obj) is DoubleData && String.instancehelper_equals(this.convMode, "d2f")) { DoubleData doubleData = (DoubleData)((Data)obj); obj = new FloatData(MatrixUtils.double2float(doubleData.getValues()), doubleData.getSampleRate(), doubleData.getFirstSampleNumber()); } else if (((Data)obj) is FloatData && String.instancehelper_equals(this.convMode, "f2d")) { FloatData floatData = (FloatData)((Data)obj); obj = new DoubleData(MatrixUtils.float2double(floatData.getValues()), floatData.getSampleRate(), floatData.getFirstSampleNumber()); } object obj2 = obj; Data result; if (obj2 != null) { if ((result = (obj2 as Data)) == null) { throw new IncompatibleClassChangeError(); } } else { result = null; } return(result); }