* the same base name found...
*/
if (!tie1ph) {
for (Iterator<SingleHMM> monoPhones = htkModels.hmmsHTK.get1phIt(); monoPhones
.hasNext();) {
SingleHMM hmm = monoPhones.next();
if (hmm == null)
break;
String name = hmm.getName();
String attribute;
if (name.equals("sil") || name.equals("sp")
|| name.equals("bb") || name.equals("xx")
|| name.equals("hh"))
attribute = FILLER;
else
attribute = "nofiller";
// get the transition index
int tmat = hmm.trIdx;
// This includes non-emitting states !
numStatePerHMM = hmm.getNstates();
int[] stid = new int[hmm.getNbEmittingStates()];
// stid contains the number of senone as it in senone pool
int j = 0;
for (int ii = 0; ii < numStatePerHMM; ii++) {
if (hmm.isEmitting(ii)) {
HMMState s = hmm.getState(ii);
// we use the index of HMM in MMF file
stid[j] = htkModels.hmmsHTK.getStateIdx(s);
j++;
// assert stid[j] >= 0 && stid[j] <
// numContextIndependentTiedState;
}
}
// assert tmat < numTiedTransitionMatrices;
Unit unit = unitManager.getUnit(name, attribute.equals(FILLER));
contextIndependentUnits.put(unit.getName(), unit);
if (logger.isLoggable(Level.FINE)) {
logger.fine("Loaded " + unit);
}
// The first filler
if (unit.isFiller() && unit.getName().equals(SILENCE_CIPHONE)) {
unit = UnitManager.SILENCE;
}
float[][] transitionMatrix = matrixPool.get(tmat);
SenoneSequence ss = getSenoneSequence(stid);
HMM hmm2 = new SenoneHMM(unit, ss, transitionMatrix,
HMMPosition.lookup("-"));
hmmManager.put(hmm2);
}
} else {
// build the 1ph by tying to the first 3ph
for (int i = 0; i < htkModels.hmmsHTK.getNhmms(); i++) {
SingleHMM hmm = htkModels.hmmsHTK.getHMM(i);
if (hmm == null)
break;
String name = hmm.getBaseName();
if (!contextIndependentUnits.containsKey(name)) {
String attribute;
if (name.equals("SIL") || name.equals("SP")
|| name.equals("BB") || name.equals("XX")
|| name.equals("HH"))
attribute = FILLER;
else
attribute = "nofiller";
// get the transition index
int tmat = hmm.trIdx;
// warning ! this includes non-emitting states !
numStatePerHMM = hmm.getNstates();
int[] stid = new int[hmm.getNbEmittingStates()];
// stid contains the identifier of senone used during
// creation of senone pool
int j = 0;
for (int ii = 0; ii < numStatePerHMM; ii++) {
if (hmm.isEmitting(ii)) {
HMMState s = hmm.getState(ii);
// We get an index of HMM in MMF file
stid[j] = htkModels.hmmsHTK.getStateIdx(s);
j++;
// assert stid[j] >= 0 && stid[j] <
// numContextIndependentTiedState;
}
}
// assert tmat < numTiedTransitionMatrices;
Unit unit = unitManager.getUnit(name, attribute
.equals(FILLER));
contextIndependentUnits.put(unit.getName(), unit);
if (logger.isLoggable(Level.FINE)) {
logger.fine("Loaded " + unit);
}
// The first filler
if (unit.isFiller()
&& unit.getName().equals(SILENCE_CIPHONE)) {
unit = UnitManager.SILENCE;
}
float[][] transitionMatrix = matrixPool.get(tmat);
SenoneSequence ss = getSenoneSequence(stid);
HMM hmm2 = new SenoneHMM(unit, ss, transitionMatrix,
HMMPosition.lookup("-"));
hmmManager.put(hmm2);
}
}
}
// Load the context dependent phones. If the useCDUnits
// property is false, the CD phones will not be created, but
// the values still need to be read in from the file.
String lastUnitName = "";
Unit lastUnit = null;
int[] lastStid = null;
SenoneSequence lastSenoneSequence = null;
List<String> HMMdejavu = new ArrayList<String>();
for (Iterator<SingleHMM> triPhones = htkModels.hmmsHTK.get3phIt(); triPhones
.hasNext();) {
SingleHMM hmm = triPhones.next();
if (hmm == null)
break;
String name = hmm.getBaseName();
String left = hmm.getLeft();
String right = hmm.getRight();
{
// diphones are transformed into triphones with SIL context, as
// it looks
// like S4 do not support diphones
if (left.equals("-"))
left = "SIL";
if (right.equals("-"))
right = "SIL";
String s = left + ' ' + name + ' ' + right;
if (HMMdejavu.contains(s)) {
// this may happen when a diphone is transformed into a
// triphone with SIL
continue;
}
HMMdejavu.add(s);
}
// TODO: For this moment we don't know if the HMMS are in the end or
// not
String position = "i";
int tmat = hmm.trIdx;
numStatePerHMM = hmm.getNstates();
int[] stid = new int[hmm.getNbEmittingStates()];
int j = 0;
for (int ii = 0; ii < numStatePerHMM; ii++) {
if (hmm.isEmitting(ii)) {
HMMState s = hmm.getState(ii);
stid[j] = htkModels.hmmsHTK.getStateIdx(s);
j++;
// assert stid[j] >= 0 && stid[j] <
// numContextIndependentTiedState;
}