public void logInfo() { logger.info("Sphinx3Loader"); meansPool.logInfo(logger); variancePool.logInfo(logger); matrixPool.logInfo(logger); senonePool.logInfo(logger); meanTransformationMatrixPool.logInfo(logger); meanTransformationVectorPool.logInfo(logger); varianceTransformationMatrixPool.logInfo(logger); varianceTransformationVectorPool.logInfo(logger); mixtureWeightsPool.logInfo(logger); senonePool.logInfo(logger); logger.info("Context Independent Unit Entries: " + contextIndependentUnits.size()); hmmManager.logInfo(logger); }
/** * Loads the phone list, which possibly contains the sizes (number of states) of models. * * @param ps * @param useCDUnits if true, uses context dependent units * @param inputStream the open input stream to use * @param path the path to a density file @throws FileNotFoundException if a file cannot be found * @throws IOException if an error occurs while loading the data */ private void loadPhoneList( PropertySheet ps, boolean useCDUnits, InputStream inputStream, String path) throws IOException { int numState = 0; // TODO: this should be flexible, but we're hardwiring for now int numStreams = 1; // Since we're initializing, we start simple. int numGaussiansPerState = 1; ExtendedStreamTokenizer est = new ExtendedStreamTokenizer(inputStream, '#', false); // Initialize the pools we'll need. meansPool = new Pool<float[]>("means"); variancePool = new Pool<float[]>("variances"); mixtureWeightsPool = new Pool<float[]>("mixtureweights"); matrixPool = new Pool<float[][]>("transitionmatrices"); senonePool = new Pool<Senone>("senones"); float distFloor = ps.getFloat(PROP_MC_FLOOR); float mixtureWeightFloor = ps.getFloat(PROP_MW_FLOOR); float transitionProbabilityFloor = 0; float varianceFloor = ps.getFloat(PROP_VARIANCE_FLOOR); logger.info("Loading phone list file from: "); logger.info(path); // At this point, we only accept version 0.1 String version = "0.1"; est.expectString("version"); est.expectString(version); est.expectString("same_sized_models"); boolean sameSizedModels = est.getString().equals("yes"); if (sameSizedModels) { est.expectString("n_state"); numState = est.getInt("numBase"); } // for this phone list version, let's assume left-to-right // models, with optional state skip. est.expectString("tmat_skip"); boolean tmatSkip = est.getString().equals("yes"); // Load the phones with sizes // stateIndex contains the absolute state index, that is, a // unique index in the senone pool. for (int stateIndex = 0, unitCount = 0; ; ) { String phone = est.getString(); if (est.isEOF()) { break; } int size = numState; if (!sameSizedModels) { size = est.getInt("ModelSize"); } phoneList.put(phone, size); logger.fine("Phone: " + phone + " size: " + size); int[] stid = new int[size]; String position = "-"; for (int j = 0; j < size; j++, stateIndex++) { stid[j] = stateIndex; } Unit unit = unitManager.getUnit(phone, phone.equals(SILENCE_CIPHONE)); contextIndependentUnits.put(unit.getName(), unit); if (logger.isLoggable(Level.FINE)) { logger.fine("Loaded " + unit + " with " + size + " states"); } // Means addModelToDensityPool(meansPool, stid, numStreams, numGaussiansPerState); // Variances addModelToDensityPool(variancePool, stid, numStreams, numGaussiansPerState); // Mixture weights addModelToMixtureWeightPool( mixtureWeightsPool, stid, numStreams, numGaussiansPerState, mixtureWeightFloor); // Transition matrix addModelToTransitionMatrixPool( matrixPool, unitCount, stid.length, transitionProbabilityFloor, tmatSkip); // After creating all pools, we create the senone pool. addModelToSenonePool(senonePool, stid, distFloor, varianceFloor); // With the senone pool in place, we go through all units, and // create the HMMs. // Create tmat float[][] transitionMatrix = matrixPool.get(unitCount); SenoneSequence ss = getSenoneSequence(stid); HMM hmm = new SenoneHMM(unit, ss, transitionMatrix, HMMPosition.lookup(position)); hmmManager.put(hmm); unitCount++; } // If we want to use this code to load sizes/create models for // CD units, we need to find another way of establishing the // number of CI models, instead of just reading until the end // of file. est.close(); }