Beispiel #1
0
        protected internal virtual GaussianWeights loadMixtureWeights(string path, float floor)
        {
            this.logger.fine(new StringBuilder().append("Loading mixture weights from: ").append(path).toString());
            Properties      properties      = new Properties();
            DataInputStream dataInputStream = this.readS3BinaryHeader(path, properties);
            string          property        = properties.getProperty("version");

            if (property == null || !String.instancehelper_equals(property, "1.0"))
            {
                string text = new StringBuilder().append("Unsupported version in ").append(path).toString();

                throw new IOException(text);
            }
            string property2 = properties.getProperty("chksum0");
            int    num       = (property2 == null || !String.instancehelper_equals(property2, "yes")) ? 0 : 1;

            this.resetChecksum();
            int             num2            = this.readInt(dataInputStream);
            int             num3            = this.readInt(dataInputStream);
            int             num4            = this.readInt(dataInputStream);
            int             num5            = this.readInt(dataInputStream);
            GaussianWeights gaussianWeights = new GaussianWeights(path, num2, num4, num3);

            this.logger.fine(new StringBuilder().append("Number of states ").append(num2).toString());
            this.logger.fine(new StringBuilder().append("Number of streams ").append(num3).toString());
            this.logger.fine(new StringBuilder().append("Number of gaussians per state ").append(num4).toString());
            if (!Sphinx3Loader.assertionsDisabled && num5 != num2 * num3 * num4)
            {
                throw new AssertionError();
            }
            for (int i = 0; i < num2; i++)
            {
                for (int j = 0; j < num3; j++)
                {
                    float[] array = this.readFloatArray(dataInputStream, num4);
                    Utilities.normalize(array);
                    Utilities.floorData(array, floor);
                    this.logMath.linearToLog(array);
                    gaussianWeights.put(i, j, array);
                }
            }
            this.validateChecksum(dataInputStream, num != 0);
            dataInputStream.close();
            return(gaussianWeights);
        }
Beispiel #2
0
            public GaussianWeights htkWeights(string name, float num)
            {
                int             numStates       = this.getNumStates();
                int             numStreams      = 1;
                int             gmmsize         = this.getGMMSize();
                GaussianWeights gaussianWeights = new GaussianWeights(name, numStates, gmmsize, numStreams);

                for (int i = 0; i < numStates; i++)
                {
                    GMMDiag gmmdiag = (GMMDiag)this.hmmsHTK.__gmms.get(i);
                    float[] array   = new float[gmmsize];
                    for (int j = 0; j < gmmsize; j++)
                    {
                        array[j] = gmmdiag.getWeight(j);
                    }
                    Utilities.floorData(array, HTKLoader.access_100(this.this_0));
                    HTKLoader.access_200(this.this_0).linearToLog(array);
                    gaussianWeights.put(i, 0, array);
                }
                return(gaussianWeights);
            }