private void saveMixtureWeightsBinary(GaussianWeights gaussianWeights, string text, bool append) { this.logger.info("Saving mixture weights to: "); this.logger.info(text); Properties properties = new Properties(); properties.setProperty("version", "1.0"); if (this.doCheckSum) { properties.setProperty("chksum0", this.checksum); } DataOutputStream dataOutputStream = this.writeS3BinaryHeader(this.location, text, properties, append); int statesNum = gaussianWeights.getStatesNum(); int streamsNum = gaussianWeights.getStreamsNum(); int gauPerState = gaussianWeights.getGauPerState(); this.writeInt(dataOutputStream, statesNum); this.writeInt(dataOutputStream, streamsNum); this.writeInt(dataOutputStream, gauPerState); if (!Sphinx3Saver.assertionsDisabled && streamsNum != 1) { throw new AssertionError(); } int val = gauPerState * statesNum * streamsNum; this.writeInt(dataOutputStream, val); for (int i = 0; i < statesNum; i++) { for (int j = 0; j < streamsNum; j++) { float[] array = new float[gauPerState]; float[] array2 = new float[gauPerState]; for (int k = 0; k < gauPerState; k++) { array2[k] = gaussianWeights.get(i, j, k); } this.logMath.logToLinear(array2, array); this.writeFloatArray(dataOutputStream, array); } } if (this.doCheckSum && !Sphinx3Saver.assertionsDisabled) { int num = 0; bool flag = num != 0; this.doCheckSum = (num != 0); if (!flag) { object obj = "Checksum not supported"; throw new AssertionError(obj); } } dataOutputStream.close(); }
private void saveMixtureWeightsAscii(GaussianWeights gaussianWeights, string text, bool append) { this.logger.info("Saving mixture weights to: "); this.logger.info(text); OutputStream outputStream = StreamFactory.getOutputStream(this.location, text, append); if (outputStream == null) { string text2 = new StringBuilder().append("Error trying to write file ").append(this.location).append(text).toString(); throw new IOException(text2); } PrintWriter printWriter = new PrintWriter(outputStream, true); printWriter.print("mixw "); int statesNum = gaussianWeights.getStatesNum(); printWriter.print(new StringBuilder().append(statesNum).append(" ").toString()); int streamsNum = gaussianWeights.getStreamsNum(); printWriter.print(new StringBuilder().append(streamsNum).append(" ").toString()); int gauPerState = gaussianWeights.getGauPerState(); printWriter.println(gauPerState); for (int i = 0; i < statesNum; i++) { for (int j = 0; j < streamsNum; j++) { printWriter.print(new StringBuilder().append("mixw [").append(i).append(" ").append(j).append("] ").toString()); float[] array = new float[gauPerState]; float[] array2 = new float[gauPerState]; for (int k = 0; k < gauPerState; k++) { array2[k] = gaussianWeights.get(i, j, k); } this.logMath.logToLinear(array2, array); float num = 0f; for (int l = 0; l < gauPerState; l++) { num += array[l]; } printWriter.println(num); printWriter.print("\n\t"); for (int l = 0; l < gauPerState; l++) { printWriter.print(new StringBuilder().append(" ").append(array[l]).toString()); } printWriter.println(); } } outputStream.close(); }