public AFlatLinguist(AcousticModel acousticModel, Grammar grammar, UnitManager unitManager, double wordInsertionProbability, double silenceInsertionProbability, double unitInsertionProbability, double fillerInsertionProbability, float languageWeight, bool addOutOfGrammarBranch, double outOfGrammarBranchProbability, double phoneInsertionProbability, AcousticModel phoneLoopAcousticModel) { this.runtime = Runtime.getRuntime(); this.counterForMemoryLogging = 0L; this.EMPTY_ARCS = new SearchStateArc[0]; this.successorCache = new HashMap(); this.logger = Logger.getLogger(Object.instancehelper_getClass(this).getName()); this.acousticModel = acousticModel; this.grammar = grammar; this.unitManager = unitManager; LogMath logMath = LogMath.getLogMath(); this.logWordInsertionProbability = logMath.linearToLog(wordInsertionProbability); this.logSilenceInsertionProbability = logMath.linearToLog(silenceInsertionProbability); this.logUnitInsertionProbability = logMath.linearToLog(unitInsertionProbability); this.logFillerInsertionProbability = logMath.linearToLog(fillerInsertionProbability); this.languageWeight = languageWeight; this.addOutOfGrammarBranch = addOutOfGrammarBranch; this.logOutOfGrammarBranchProbability = logMath.linearToLog(outOfGrammarBranchProbability); this.logPhoneInsertionProbability = logMath.linearToLog((double)this.logPhoneInsertionProbability); if (addOutOfGrammarBranch) { this.phoneLoopAcousticModel = phoneLoopAcousticModel; } }
public TransitionModel(KaldiTextParser parser) { parser.expectToken("<TransitionModel>"); this.parseTopology(parser); parser.expectToken("<Triples>"); this.transitionStates = new HashMap(); int @int = parser.getInt(); int num = 1; for (int i = 0; i < @int; i++) { int j = parser.getInt(); int int2 = parser.getInt(); int int3 = parser.getInt(); Triple triple = new Triple(j, int2, int3); this.transitionStates.put(triple, Integer.valueOf(num)); num += ((HmmState)((List)this.phoneStates.get(Integer.valueOf(j))).get(int2)).getTransitions().size(); } parser.expectToken("</Triples>"); parser.expectToken("<LogProbs>"); this.logProbabilities = parser.getFloatArray(); parser.expectToken("</LogProbs>"); parser.expectToken("</TransitionModel>"); LogMath logMath = LogMath.getLogMath(); for (int j = 0; j < this.logProbabilities.Length; j++) { this.logProbabilities[j] = logMath.lnToLog(this.logProbabilities[j]); } }
/** * Calculate the distance between two clusters, forcing them to have the same words in them, and to not be related * to each other. * * @param cluster1 the first cluster * @param cluster2 the second cluster * @return The intra-cluster distance, or Double.NEGATIVE_INFINITY if the clusters should never be clustered * together. */ protected double intraClusterDistance(Cluster cluster1, Cluster cluster2) { LogMath logMath = LogMath.getLogMath(); double maxSim = Double.NegativeInfinity; foreach (Node node1 in cluster1.getElements()) { foreach (Node node2 in cluster2.getElements()) { if (!node1.getWord().getSpelling().Equals( node2.getWord().getSpelling())) { return(Double.NegativeInfinity); } if (node1.hasAncestralRelationship(node2)) { return(Double.NegativeInfinity); } double overlap = getOverlap(node1, node2); if (overlap > 0.0) { overlap = logMath.logToLinear((float)overlap); overlap += node1.getPosterior() + node2.getPosterior(); if (overlap > maxSim) { maxSim = overlap; } } } } return(maxSim); }
public GaussianMixture(GaussianWeights mixtureWeights, MixtureComponent[] mixtureComponents, int id) { this.logMath = LogMath.getLogMath(); this.mixtureComponents = mixtureComponents; this.mixtureWeights = mixtureWeights; this.id = id; }
public override void newProperties(PropertySheet ps) { base.newProperties(ps); this.path = ps.getString("path"); this.isLooping = ps.getBoolean("isLooping").booleanValue(); this.logMath = LogMath.getLogMath(); }
public virtual void newProperties(PropertySheet ps) { this.logMath = LogMath.getLogMath(); this.dataSource = (StreamCepstrumSource)ps.getComponent("source"); this.frontEnd = (FrontEnd)ps.getComponent("frontend"); this.frontEnd.setDataSource(this.dataSource); }
public FSTGrammar(string path, bool showGrammar, bool optimizeGrammar, bool addSilenceWords, bool addFillerWords, dictionary.Dictionary dictionary) : base(showGrammar, optimizeGrammar, addSilenceWords, addFillerWords, dictionary) { this.ignoreUnknownTransitions = true; this.nodes = new HashMap(); this.expandedNodes = new HashSet(); this.logMath = LogMath.getLogMath(); this.path = path; }
public void newProperties(PropertySheet ps) { logMath = LogMath.getLogMath(); absoluteBeamWidth = ps.getInt(PROP_ABSOLUTE_BEAM_WIDTH); double relativeBeamWidth = ps.getDouble(PROP_RELATIVE_BEAM_WIDTH); logRelativeBeamWidth = logMath.linearToLog(relativeBeamWidth); }
/// <summary> ///Creates a result ///@param activeList the active list associated with this result ///@param resultList the result list associated with this result ///@param frameNumber the frame number for this result. ///@param isFinal if true, the result is a final result. This means that the last frame in the /// speech segment has been decoded. /// <summary> public Result(ActiveList activeList, List <Token> resultList, int frameNumber, Boolean isFinal) { this.activeList = activeList; this.resultList = resultList; this.currentFrameNumber = frameNumber; this._isFinal = isFinal; logMath = LogMath.getLogMath(); }
public virtual void newProperties(PropertySheet ps) { this.logMath = LogMath.getLogMath(); this.absoluteBeamWidth = ps.getInt("absoluteBeamWidth"); double linearValue = ps.getDouble("relativeBeamWidth"); this.logRelativeBeamWidth = this.logMath.linearToLog(linearValue); }
public GDLDumper(string filename, Linguist linguist, bool verticalLayout, bool skipHMMs, bool dumpArcLabels) : base(filename, linguist) { this.verticalLayout = verticalLayout; this.skipHMMs = skipHMMs; this.dumpArcLabels = dumpArcLabels; this.setDepthFirst(false); this.logMath = LogMath.getLogMath(); }
public NetworkLanguageModel(string host, int port, URL location, int maxDepth) { this.host = host; this.port = port; this.maxDepth = maxDepth; this.location = location; this.logMath = LogMath.getLogMath(); }
private void allocateWeights() { this.logMath = LogMath.getLogMath(); this.weights = new float[this.ngauss]; for (int i = 0; i < this.ngauss; i++) { this.setWeight(i, 1f / (float)this.ngauss); } }
public ClassMap(URL classDefsLocation) { this.classVocabulary = new HashMap(); this.wordToClassProbabilities = new HashMap(); this.classToWord = new HashMap(); this.logger = Logger.getLogger(Object.instancehelper_getClass(this).getName()); this.classDefsLocation = classDefsLocation; this.logMath = LogMath.getLogMath(); }
public JSGFGrammar(URL baseURL, string grammarName, bool showGrammar, bool optimizeGrammar, bool addSilenceWords, bool addFillerWords, linguist.dictionary.Dictionary dictionary) : base(showGrammar, optimizeGrammar, addSilenceWords, addFillerWords, dictionary) { this.loadGrammar = true; this.logger = Logger.getLogger(Object.instancehelper_getClass(this).getName()); this.logMath = LogMath.getLogMath(); this.baseURL = baseURL; this.grammarName = grammarName; this.loadGrammar = true; }
public override void newProperties(PropertySheet ps) { base.newProperties(ps); this.logger = ps.getLogger(); this.logMath = LogMath.getLogMath(); this.baseURL = ConfigurationManagerUtils.getResource("grammarLocation", ps); this.grammarName = ps.getString("grammarName"); this.loadGrammar = true; }
public override string toString() { return(String.format(Locale.US, "{%s, %.3f, [%s]}", new object[] { this.word, Double.valueOf(LogMath.getLogMath().logToLinear((float)this.getConfidence())), this.timeFrame })); }
public Result(ActiveList activeList, List resultList, long collectTime, bool isFinal, bool wordTokenFirst, bool toCreateLattice) { this.activeList = activeList; this.resultList = resultList; this.currentCollectTime = collectTime; this._isFinal = isFinal; this._toCreateLattice = toCreateLattice; this.wordTokenFirst = wordTokenFirst; this.logMath = LogMath.getLogMath(); }
public BinaryLoader(string format, bool applyLanguageWeightAndWip, float languageWeight, double wip, float unigramWeight) { this.bigEndian = true; this.startWordID = -1; this.endWordID = -1; this.applyLanguageWeightAndWip = applyLanguageWeightAndWip; this.logMath = LogMath.getLogMath(); this.languageWeight = languageWeight; this.wip = wip; this.unigramWeight = unigramWeight; }
public Stats(Loader loader, ClusteredDensityFileData means) { this.logMath = LogMath.getLogMath(); this.loader = (Sphinx3Loader)loader; this.nClusters = means.getNumberOfClusters(); this.means = means; this.varFlor = 1E-05f; this.invertVariances(); this.init(); this.nFrames = 0; }
public SimpleNGramModel(URL urlLocation, dictionary.Dictionary dictionary, float unigramWeight, int desiredMaxDepth) { this.urlLocation = urlLocation; this.unigramWeight = unigramWeight; this.logMath = LogMath.getLogMath(); this.desiredMaxDepth = desiredMaxDepth; this.dictionary = dictionary; this.map = new HashMap(); this.vocabulary = new HashSet(); this.tokens = new LinkedList(); }
protected internal virtual void init(URL location, UnitManager unitManager, float distFloor, float mixtureWeightFloor, float varianceFloor, int topGauNum, bool useCDUnits, Logger logger) { this.logMath = LogMath.getLogMath(); this.location = location; this.logger = logger; this.unitManager = unitManager; this.distFloor = distFloor; this.mixtureWeightFloor = mixtureWeightFloor; this.varianceFloor = varianceFloor; this.topGauNum = topGauNum; this.useCDUnits = useCDUnits; }
/** * Calculate the sum of posteriors in this cluster. * * @param cluster the cluster to sum over * @return the probability sum */ protected double clusterProbability(LinkedList <Node> cluster) { float p = LogMath.LOG_ZERO; LogMath logMath = LogMath.getLogMath(); foreach (Node node in cluster) { p = logMath.addAsLinear(p, (float)node.getPosterior()); } return(p); }
public HTKLoader(string propsFile, UnitManager unitManager, bool isBinary, int vectorLength, string model, bool tie1ph, float distFloor, float mixtureWeightFloor, float varianceFloor) { this.logger = Logger.getLogger(Object.instancehelper_getClass(this).getName()); this.propsFile = propsFile; this.loadProperties(); this.logMath = LogMath.getLogMath(); this.unitManager = unitManager; this.model = model; this.tie1ph = tie1ph; this.distFloor = distFloor; this.mixtureWeightFloor = mixtureWeightFloor; this.varianceFloor = varianceFloor; }
public override void newProperties(PropertySheet ps) { this.acousticModel = (AcousticModel)ps.getComponent("acousticModel"); this.pip = LogMath.getLogMath().linearToLog((double)ps.getFloat("phoneInsertionProbability")); this.useCD = ps.getBoolean("useContextDependentPhones").booleanValue(); if (this.useCD) { this.createContextDependentSuccessors(); } else { this.createContextIndependentSuccessors(); } }
private float convertScore(float num) { num = LogMath.getLogMath().lnToLog(num); if (Float.isNaN(num)) { [email protected]("gs is Nan, converting to 0"); num = float.MinValue; } if (num < this.distFloor) { num = this.distFloor; } return(num); }
protected internal HMMPoolManager(Loader loader) { loader.load(); this.hmmManager = loader.getHMMManager(); this.indexMap = new HashMap(); this.meansPool = loader.getMeansPool(); this.variancePool = loader.getVariancePool(); this.mixtureWeights = loader.getMixtureWeights(); this.matrixPool = loader.getTransitionMatrixPool(); this.senonePool = loader.getSenonePool(); this.createBuffers(); this.logLikelihood = 0f; this.logMath = LogMath.getLogMath(); }
public override void newProperties(PropertySheet ps) { this.logger = ps.getLogger(); this.logMath = LogMath.getLogMath(); this.location = ConfigurationManagerUtils.getResource("location", ps); this.ngramLogFile = ps.getString("queryLogFile"); this.maxDepth = ps.getInt("maxDepth"); this.ngramCacheSize = ps.getInt("ngramCacheSize"); this.clearCacheAfterUtterance = ps.getBoolean("clearCachesAfterUtterance").booleanValue(); this.dictionary = (dictionary.Dictionary)ps.getComponent("dictionary"); this.applyLanguageWeightAndWip = ps.getBoolean("applyLanguageWeightAndWip").booleanValue(); this.languageWeight = ps.getFloat("languageWeight"); this.logWip = this.logMath.linearToLog(ps.getDouble("wordInsertionProbability")); this.unigramWeight = ps.getFloat("unigramWeight"); }
protected internal override float calculateScore(Data data) { float num = float.MinValue; LogMath logMath = LogMath.getLogMath(); float[] array = this.calculateComponentScore(data); int num2 = array.Length; for (int i = 0; i < num2; i++) { Float @float = Float.valueOf(array[i]); num = logMath.addAsLinear(num, @float.floatValue()); } return(num); }
public SimpleBreadthFirstSearchManager(Linguist linguist, Pruner pruner, AcousticScorer scorer, ActiveListFactory activeListFactory, bool showTokenCount, double relativeWordBeamWidth, int growSkipInterval, bool wantEntryPruning) { this.name = Object.instancehelper_getClass(this).getName(); this.logger = Logger.getLogger(this.name); this.logMath = LogMath.getLogMath(); this.linguist = linguist; this.pruner = pruner; this.scorer = scorer; this.activeListFactory = activeListFactory; this._showTokenCount = showTokenCount; this.growSkipInterval = growSkipInterval; this.wantEntryPruning = wantEntryPruning; this.logRelativeWordBeamWidth = this.logMath.linearToLog(relativeWordBeamWidth); this.keepAllTokens = true; }