protected internal virtual void loadHMMPool(bool useCDUnits, InputStream inputStream) { ExtendedStreamTokenizer extendedStreamTokenizer = new ExtendedStreamTokenizer(inputStream, 35, false); this.logger.fine(new StringBuilder().append("Loading HMM file from: ").append(this.location).toString()); extendedStreamTokenizer.expectString("0.3"); int @int = extendedStreamTokenizer.getInt("numBase"); extendedStreamTokenizer.expectString("n_base"); int int2 = extendedStreamTokenizer.getInt("numTri"); extendedStreamTokenizer.expectString("n_tri"); int int3 = extendedStreamTokenizer.getInt("numStateMap"); extendedStreamTokenizer.expectString("n_state_map"); int int4 = extendedStreamTokenizer.getInt("numTiedState"); extendedStreamTokenizer.expectString("n_tied_state"); int int5 = extendedStreamTokenizer.getInt("numContextIndependentTiedState"); extendedStreamTokenizer.expectString("n_tied_ci_state"); int int6 = extendedStreamTokenizer.getInt("numTiedTransitionMatrices"); extendedStreamTokenizer.expectString("n_tied_tmat"); int num = int3; int num2 = int2 + @int; int num3 = (num2 != -1) ? (num / num2) : (-num); if (!Sphinx3Loader.assertionsDisabled && int4 != this.mixtureWeights.getStatesNum()) { throw new AssertionError(); } if (!Sphinx3Loader.assertionsDisabled && int6 != this.transitionsPool.size()) { throw new AssertionError(); } for (int i = 0; i < @int; i++) { string @string = extendedStreamTokenizer.getString(); string string2 = extendedStreamTokenizer.getString(); string string3 = extendedStreamTokenizer.getString(); string string4 = extendedStreamTokenizer.getString(); string string5 = extendedStreamTokenizer.getString(); int int7 = extendedStreamTokenizer.getInt("tmat"); int[] array = new int[num3 - 1]; for (int j = 0; j < num3 - 1; j++) { array[j] = extendedStreamTokenizer.getInt("j"); if (!Sphinx3Loader.assertionsDisabled && (array[j] < 0 || array[j] >= int5)) { throw new AssertionError(); } } extendedStreamTokenizer.expectString("N"); if (!Sphinx3Loader.assertionsDisabled && !String.instancehelper_equals(string2, "-")) { throw new AssertionError(); } if (!Sphinx3Loader.assertionsDisabled && !String.instancehelper_equals(string3, "-")) { throw new AssertionError(); } if (!Sphinx3Loader.assertionsDisabled && !String.instancehelper_equals(string4, "-")) { throw new AssertionError(); } if (!Sphinx3Loader.assertionsDisabled && int7 >= int6) { throw new AssertionError(); } Unit unit = this.unitManager.getUnit(@string, String.instancehelper_equals(string5, "filler")); this.contextIndependentUnits.put(unit.getName(), unit); if (this.logger.isLoggable(Level.FINE)) { this.logger.fine(new StringBuilder().append("Loaded ").append(unit).toString()); } if (unit.isFiller() && String.instancehelper_equals(unit.getName(), "SIL")) { unit = UnitManager.__SILENCE; } float[][] transitionMatrix = (float[][])this.transitionsPool.get(int7); SenoneSequence senoneSequence = this.getSenoneSequence(array); SenoneHMM hmm = new SenoneHMM(unit, senoneSequence, transitionMatrix, HMMPosition.lookup(string4)); this.hmmManager.put(hmm); } if (this.hmmManager.get(HMMPosition.__UNDEFINED, UnitManager.__SILENCE) == null) { string text = "Could not find SIL unit in acoustic model"; throw new IOException(text); } string text2 = ""; Unit unit2 = null; int[] ssid = null; SenoneSequence senoneSequence2 = null; for (int k = 0; k < int2; k++) { string string5 = extendedStreamTokenizer.getString(); string string6 = extendedStreamTokenizer.getString(); string string7 = extendedStreamTokenizer.getString(); string string8 = extendedStreamTokenizer.getString(); string string9 = extendedStreamTokenizer.getString(); int int8 = extendedStreamTokenizer.getInt("tmat"); int[] array2 = new int[num3 - 1]; for (int l = 0; l < num3 - 1; l++) { array2[l] = extendedStreamTokenizer.getInt("j"); if (!Sphinx3Loader.assertionsDisabled && (array2[l] < int5 || array2[l] >= int4)) { throw new AssertionError(); } } extendedStreamTokenizer.expectString("N"); if (!Sphinx3Loader.assertionsDisabled && String.instancehelper_equals(string6, "-")) { throw new AssertionError(); } if (!Sphinx3Loader.assertionsDisabled && String.instancehelper_equals(string7, "-")) { throw new AssertionError(); } if (!Sphinx3Loader.assertionsDisabled && String.instancehelper_equals(string8, "-")) { throw new AssertionError(); } if (!Sphinx3Loader.assertionsDisabled && !String.instancehelper_equals(string9, "n/a")) { throw new AssertionError(); } if (!Sphinx3Loader.assertionsDisabled && int8 >= int6) { throw new AssertionError(); } if (useCDUnits) { string text3 = new StringBuilder().append(string5).append(' ').append(string6).append(' ').append(string7).toString(); Unit unit3; if (String.instancehelper_equals(text3, text2)) { unit3 = unit2; } else { LeftRightContext context = LeftRightContext.get(new Unit[] { (Unit)this.contextIndependentUnits.get(string6) }, new Unit[] { (Unit)this.contextIndependentUnits.get(string7) }); unit3 = this.unitManager.getUnit(string5, false, context); } text2 = text3; unit2 = unit3; if (this.logger.isLoggable(Level.FINE)) { this.logger.fine(new StringBuilder().append("Loaded ").append(unit3).toString()); } float[][] transitionMatrix2 = (float[][])this.transitionsPool.get(int8); SenoneSequence senoneSequence3 = senoneSequence2; if (senoneSequence3 == null || !this.sameSenoneSequence(array2, ssid)) { senoneSequence3 = this.getSenoneSequence(array2); } senoneSequence2 = senoneSequence3; ssid = array2; SenoneHMM hmm2 = new SenoneHMM(unit3, senoneSequence3, transitionMatrix2, HMMPosition.lookup(string8)); this.hmmManager.put(hmm2); } } extendedStreamTokenizer.close(); }
private void loadPhoneList(PropertySheet propertySheet, bool flag, InputStream inputStream, string text) { int num = 0; int num2 = 1; int num3 = 1; ExtendedStreamTokenizer extendedStreamTokenizer = new ExtendedStreamTokenizer(inputStream, 35, false); this.meansPool = new Pool("means"); this.variancePool = new Pool("variances"); this.matrixPool = new Pool("transitionmatrices"); this.senonePool = new Pool("senones"); float @float = propertySheet.getFloat("MixtureComponentScoreFloor"); float float2 = propertySheet.getFloat("mixtureWeightFloor"); float num4 = 0f; float float3 = propertySheet.getFloat("varianceFloor"); this.logger.info("Loading phone list file from: "); this.logger.info(text); string expecting = "0.1"; extendedStreamTokenizer.expectString("version"); extendedStreamTokenizer.expectString(expecting); extendedStreamTokenizer.expectString("same_sized_models"); int num5 = String.instancehelper_equals(extendedStreamTokenizer.getString(), "yes") ? 1 : 0; if (num5 != 0) { extendedStreamTokenizer.expectString("n_state"); num = extendedStreamTokenizer.getInt("numBase"); } extendedStreamTokenizer.expectString("tmat_skip"); int num6 = String.instancehelper_equals(extendedStreamTokenizer.getString(), "yes") ? 1 : 0; int num7 = 0; int num8 = 0; for (;;) { string @string = extendedStreamTokenizer.getString(); if (extendedStreamTokenizer.isEOF()) { break; } int num9 = num; if (num5 == 0) { num9 = extendedStreamTokenizer.getInt("ModelSize"); } this.phoneList.put(@string, Integer.valueOf(num9)); this.logger.fine(new StringBuilder().append("Phone: ").append(@string).append(" size: ").append(num9).toString()); int[] array = new int[num9]; string rep = "-"; int i = 0; while (i < num9) { array[i] = num7; i++; num7++; } Unit unit = this.unitManager.getUnit(@string, String.instancehelper_equals(@string, "SIL")); this.contextIndependentUnits.put(unit.getName(), unit); if (this.logger.isLoggable(Level.FINE)) { this.logger.fine(new StringBuilder().append("Loaded ").append(unit).append(" with ").append(num9).append(" states").toString()); } this.addModelToDensityPool(this.meansPool, array, num2, num3); this.addModelToDensityPool(this.variancePool, array, num2, num3); this.addModelToTransitionMatrixPool(this.matrixPool, num8, array.Length, num4, num6 != 0); this.addModelToSenonePool(this.senonePool, array, @float, float3); float[][] transitionMatrix = (float[][])this.matrixPool.get(num8); SenoneSequence senoneSequence = this.getSenoneSequence(array); SenoneHMM hmm = new SenoneHMM(unit, senoneSequence, transitionMatrix, HMMPosition.lookup(rep)); this.hmmManager.put(hmm); num8++; } this.mixtureWeights = this.initMixtureWeights(num7, num2, num3, float2); extendedStreamTokenizer.close(); }
private void getSenoneToCIPhone() { InputStream dataStream = this.getDataStream("mdef"); if (dataStream == null) { string text = "can't find model definition"; throw new IOException(text); } ExtendedStreamTokenizer extendedStreamTokenizer = new ExtendedStreamTokenizer(dataStream, 35, false); this.logger.fine(new StringBuilder().append("Loading HMM file from ").append(this.location).toString()); extendedStreamTokenizer.expectString("0.3"); this.numBase = extendedStreamTokenizer.getInt("numBase"); extendedStreamTokenizer.expectString("n_base"); int @int = extendedStreamTokenizer.getInt("numTri"); extendedStreamTokenizer.expectString("n_tri"); int int2 = extendedStreamTokenizer.getInt("numStateMap"); extendedStreamTokenizer.expectString("n_state_map"); int int3 = extendedStreamTokenizer.getInt("numTiedState"); extendedStreamTokenizer.expectString("n_tied_state"); this.senone2ci = new int[int3]; extendedStreamTokenizer.getInt("numContextIndependentTiedState"); extendedStreamTokenizer.expectString("n_tied_ci_state"); int int4 = extendedStreamTokenizer.getInt("numTiedTransitionMatrices"); extendedStreamTokenizer.expectString("n_tied_tmat"); int num = int2; int num2 = @int + this.numBase; int num3 = (num2 != -1) ? (num / num2) : (-num); if (!Sphinx3Loader.assertionsDisabled && int3 != this.mixtureWeights.getStatesNum()) { throw new AssertionError(); } if (!Sphinx3Loader.assertionsDisabled && int4 != this.transitionsPool.size()) { throw new AssertionError(); } for (int i = 0; i < this.numBase + @int; i++) { int j; for (j = 0; j < 5; j++) { extendedStreamTokenizer.getString(); } j = extendedStreamTokenizer.getInt("tmat"); for (int k = 0; k < num3 - 1; k++) { this.senone2ci[extendedStreamTokenizer.getInt("j")] = j; } extendedStreamTokenizer.expectString("N"); if (!Sphinx3Loader.assertionsDisabled && j >= int4) { throw new AssertionError(); } } extendedStreamTokenizer.close(); }