private void init() { this.timer = TimerPool.getTimer(this, "Frontend"); this.last = null; Iterator iterator = this.frontEndList.iterator(); while (iterator.hasNext()) { DataProcessor dataProcessor = (DataProcessor)iterator.next(); if (!FrontEnd.assertionsDisabled && dataProcessor == null) { throw new AssertionError(); } if (this.last != null) { dataProcessor.setPredecessor(this.last); } if (this.first == null) { this.first = dataProcessor; } this.last = dataProcessor; } this.initialize(); }
/* * (non-Javadoc) * @see edu.cmu.sphinx.decoder.search.SearchManager#allocate() */ //@Override public override void allocate() { totalTokensScored = StatisticsVariable .getStatisticsVariable("totalTokensScored"); tokensPerSecond = StatisticsVariable .getStatisticsVariable("tokensScoredPerSecond"); curTokensScored = StatisticsVariable .getStatisticsVariable("curTokensScored"); tokensCreated = StatisticsVariable .getStatisticsVariable("tokensCreated"); viterbiPruned = StatisticsVariable .getStatisticsVariable("viterbiPruned"); beamPruned = StatisticsVariable.getStatisticsVariable("beamPruned"); try { linguist.allocate(); pruner.allocate(); scorer.allocate(); } catch (IOException e) { throw new SystemException( "Allocation of search manager resources failed", e); } scoreTimer = TimerPool.getTimer(this, "Score"); pruneTimer = TimerPool.getTimer(this, "Prune"); growTimer = TimerPool.getTimer(this, "Grow"); }
public void StatusChanged(Recognizer.State status) { if (status == Recognizer.State.Allocated) { if (_showTimers) { TimerPool.DumpAll(); } } if (status == Recognizer.State.Deallocating) { if (_showTimers) { TimerPool.DumpAll(); } } if (status == Recognizer.State.Deallocated) { if (_showSummary) { ShowAudioSummary(); } } }
void Update() { if (isPaused) { return; } while (timersToBeCreated.Count > 0) { timers.AddSorted(timersToBeCreated.Dequeue()); } while (timersToBeDestroyed.Count > 0) { Timer timer = timersToBeDestroyed.Dequeue(); TimerPool.Push(timer); timers.Remove(timer); } currentTime += Time.deltaTime; for (int i = timers.Count - 1; i >= 0; i--) { if (timers[i].GoalTime > currentTime) { break; } timers[i].Invoke(); ReleaseTimer(i); } }
/* * (non-Javadoc) * * @see edu.cmu.sphinx.linguist.dictionary.Dictionary#allocate() */ public override void Allocate() { if (!allocated) { dictionary = new HashMap <String, String>(); wordDictionary = new HashMap <String, Word>(); Timer loadTimer = TimerPool.GetTimer(this, "Load Dictionary"); fillerWords = new HashSet <String>(); loadTimer.Start(); this.LogInfo("Loading dictionary from: " + wordDictionaryFile); LoadDictionary(wordDictionaryFile.OpenStream(), false); LoadCustomDictionaries(addendaUrlList); this.LogInfo("Loading filler dictionary from: " + fillerDictionaryFile); LoadDictionary(fillerDictionaryFile.OpenStream(), true); if (g2pModelFile != null && !g2pModelFile.Path.Equals("")) { g2pDecoder = new G2PConverter(g2pModelFile); } loadTimer.Stop(); } }
public BatchAsyncContainerExecutor( ContainerCore cosmosContainer, CosmosClientContext cosmosClientContext, int maxServerRequestOperationCount, int maxServerRequestBodyLength, int dispatchTimerInSeconds = BatchAsyncContainerExecutor.DefaultDispatchTimerInSeconds) { if (cosmosContainer == null) { throw new ArgumentNullException(nameof(cosmosContainer)); } if (maxServerRequestOperationCount < 1) { throw new ArgumentOutOfRangeException(nameof(maxServerRequestOperationCount)); } if (maxServerRequestBodyLength < 1) { throw new ArgumentOutOfRangeException(nameof(maxServerRequestBodyLength)); } if (dispatchTimerInSeconds < 1) { throw new ArgumentOutOfRangeException(nameof(dispatchTimerInSeconds)); } this.cosmosContainer = cosmosContainer; this.cosmosClientContext = cosmosClientContext; this.maxServerRequestBodyLength = maxServerRequestBodyLength; this.maxServerRequestOperationCount = maxServerRequestOperationCount; this.dispatchTimerInSeconds = dispatchTimerInSeconds; this.timerPool = new TimerPool(BatchAsyncContainerExecutor.MinimumDispatchTimerInSeconds); this.retryOptions = cosmosClientContext.ClientOptions.GetConnectionPolicy().RetryOptions; }
public void Load() { if (!_loaded) { TimerPool.GetTimer(this, "Load AM").Start(); HmmManager = new HMMManager(); ContextIndependentUnits = new LinkedHashMap <String, Unit>(); // dummy pools for these elements MeansTransformationMatrixPool = null; MeansTransformationVectorPool = null; VarianceTransformationMatrixPool = null; VarianceTransformationVectorPool = null; TransformMatrix = null; // do the actual acoustic model loading try { LoadModelFiles(Model); } catch (UriFormatException e) { this.LogInfo(e.Message); throw new RuntimeException(e); } // done _loaded = true; TimerPool.GetTimer(this, "Load AM").Stop(); } }
public ModuleTimer(Action callback, uint interval, bool once, [CallerFilePath] string file = "[unknown].cs", [CallerLineNumber] int line = 0) { LastRun = TimerPool.GetTime(); Callback = callback; Interval = interval; Once = once; Location = line != 0 ? $"{file}:{line}" : file; }
public virtual void allocate() { this.dictionary.allocate(); this.newGrammar(); sphinx.util.Timer timer = TimerPool.getTimer(this, "grammarLoad"); timer.start(); this.initialNode = this.createGrammar(); timer.stop(); }
/** Create the grammar * /// @throws java.io.IOException*/ public void Allocate() { Dictionary.Allocate(); NewGrammar(); Timer timer = TimerPool.GetTimer(this, "grammarLoad"); timer.Start(); InitialNode = CreateGrammar(); timer.Stop(); }
private int detectGapInsertionErrors() { util.Timer timer = TimerPool.getTimer(this, "GapInsertionDetector"); timer.start(); GapInsertionDetector gapInsertionDetector = new GapInsertionDetector(this.dataSource.getTranscriptFile(), this.hypothesisFile, this.showGapInsertions); int result = gapInsertionDetector.detect(); timer.stop(); return(result); }
/// <summary> /// åˆ›å»ºä¸€ä¸ªæ–°çš„è®¡æ—¶å™¨ï¼Œä¼˜å…ˆä»Žå¯¹è±¡æ± åˆ›å»ºã€‚ /// </summary> /// <param name="time">计时时长。</param> /// <param name="callback">回调函数。</param> /// <returns>计时器实例。</returns> internal static Timer Create(float time, Action callback) { Timer timer = TimerPool.Pop(); timer.GoalTime = currentTime + time; timer.Callback = callback; timer.IsActive = true; timersToBeCreated.Enqueue(timer); return(timer); }
public virtual void timeLinguist(int numRuns, int numFrames, int maxBeam) { java.util.Random random = new java.util.Random((long)((ulong)1000)); sphinx.util.Timer timer = TimerPool.getTimer(this, "frameTimer"); sphinx.util.Timer timer2 = TimerPool.getTimer(this, "totalTimer"); [email protected](new StringBuilder().append("TestLinguist: runs ").append(numRuns).append(" frames ").append(numFrames).append(" beam ").append(maxBeam).toString()); timer2.start(); for (int i = 0; i < numRuns; i++) { int num = 0; object obj = new ArrayList(); ((ArrayList)obj).add(this.linguist.getSearchGraph().getInitialState()); this.linguist.startRecognition(); for (int j = 0; j < numFrames; j++) { object obj2 = obj; obj = new ArrayList(maxBeam * 10); timer.start(); object obj3 = obj2; List list; if (obj3 != null) { if ((list = (obj3 as List)) == null) { throw new IncompatibleClassChangeError(); } } else { list = null; } Iterator iterator = list.iterator(); while (iterator.hasNext()) { SearchState searchState = (SearchState)iterator.next(); this.expandState(num, (ArrayList)obj, searchState); } timer.stop(); Collections.shuffle((ArrayList)obj, random); if (((ArrayList)obj).size() > maxBeam) { obj = ((ArrayList)obj).subList(0, maxBeam); } } this.linguist.stopRecognition(); } timer2.stop(); [email protected](new StringBuilder().append(" MaxSuccessors : ").append(this.maxSuccessors).toString()); [email protected](new StringBuilder().append(" TotalStates : ").append(this.totalStates).toString()); [email protected](new StringBuilder().append(" TotalEmitting : ").append(this.totalEmittingStates).toString()); [email protected](new StringBuilder().append(" NonEmitting : ").append(this.totalNonEmittingStates).toString()); [email protected](new StringBuilder().append(" Final States : ").append(this.totalFinalStates).toString()); }
public override void Allocate() { TimerPool.GetTimer(this, "Load LM").Start(); this.LogInfo("Loading n-gram language model from: " + location); // create the log file if specified if (ngramLogFile != null) { logFile = new StreamWriter(ngramLogFile); } BinaryLoader loader; if (location.Path == null || location.Path.Equals("file")) { try { loader = new BinaryLoader(new FileInfo(location.Path)); } catch (Exception ex) { loader = new BinaryLoader(new FileInfo(location.Path)); } } else { loader = new BinaryLoader(location); } loader.verifyHeader(); counts = loader.readCounts(); if (MaxDepth <= 0 || MaxDepth > counts.Length) { MaxDepth = counts.Length; } if (MaxDepth > 1) { quant = loader.readQuant(MaxDepth); } unigrams = loader.readUnigrams(counts[0]); if (MaxDepth > 1) { trie = new NgramTrie(counts, quant.getProbBoSize(), quant.getProbSize()); loader.readTrieByteArr(trie.getMem()); } //string words can be read here words = loader.readWords(counts[0]); BuildUnigramIDMap(); ngramProbCache = new LRUCache <WordSequence, Float>(ngramCacheSize); loader.close(); TimerPool.GetTimer(this, "Load LM").Stop(); }
public BatchAsyncStreamer( int maxBatchOperationCount, int maxBatchByteSize, int dispatchTimerInSeconds, TimerPool timerPool, CosmosSerializer cosmosSerializer, BatchAsyncBatcherExecuteDelegate executor, BatchAsyncBatcherRetryDelegate retrier) { if (maxBatchOperationCount < 1) { throw new ArgumentOutOfRangeException(nameof(maxBatchOperationCount)); } if (maxBatchByteSize < 1) { throw new ArgumentOutOfRangeException(nameof(maxBatchByteSize)); } if (dispatchTimerInSeconds < 1) { throw new ArgumentOutOfRangeException(nameof(dispatchTimerInSeconds)); } if (executor == null) { throw new ArgumentNullException(nameof(executor)); } if (retrier == null) { throw new ArgumentNullException(nameof(retrier)); } if (cosmosSerializer == null) { throw new ArgumentNullException(nameof(cosmosSerializer)); } this.maxBatchOperationCount = maxBatchOperationCount; this.maxBatchByteSize = maxBatchByteSize; this.executor = executor; this.retrier = retrier; this.dispatchTimerInSeconds = dispatchTimerInSeconds; this.timerPool = timerPool; this.cosmosSerializer = cosmosSerializer; this.currentBatcher = this.CreateBatchAsyncBatcher(); this.ResetTimer(); }
/** * /// Creates the HMMTree * * /// @param pool the pool of HMMs and units * /// @param dictionary the dictionary containing the pronunciations * /// @param lm the source of the set of words to add to the lex tree * /// @param addFillerWords if <code>false</code> add filler words * /// @param languageWeight the languageWeight */ public HMMTree(HMMPool pool, IDictionary dictionary, LanguageModel lm, Boolean addFillerWords, float languageWeight) { HMMPool = pool; Dictionary = dictionary; _lm = lm; _endNodeMap = new HashMap <Object, HMMNode[]>(); WordNodeMap = new HashMap <Pronunciation, WordNode>(); _addFillerWords = addFillerWords; _languageWeight = languageWeight; TimerPool.GetTimer(this, "Create HMM Tree").Start(); Compile(); TimerPool.GetTimer(this, "Create HMM Tree").Stop(); }
public override void allocate() { this.logger.info("Allocating DFLAT"); this.allocateAcousticModel(); this.grammar.allocate(); this.hmmPool = new HMMPool(this.acousticModel, this.logger, this.unitManager); this.nodeToNextUnitArrayMap = new HashMap(); this.nodeToUnitSetMap = new HashMap(); sphinx.util.Timer timer = TimerPool.getTimer(this, "compileGrammar"); timer.start(); this.compileGrammar(); timer.stop(); this.logger.info("Done allocating DFLAT"); }
public override void allocate() { TimerPool.getTimer(this, "Load LM").start(); this.logger.info(new StringBuilder().append("Loading n-gram language model from: ").append(this.location).toString()); if (this.ngramLogFile != null) { this.logFile = new PrintWriter(new FileOutputStream(this.ngramLogFile)); } BinaryLoader binaryLoader; if (this.location.getProtocol() != null) { if (!String.instancehelper_equals(this.location.getProtocol(), "file")) { binaryLoader = new BinaryLoader(this.location); goto IL_EC; } } try { binaryLoader = new BinaryLoader(new File(this.location.toURI())); } catch (System.Exception) { binaryLoader = new BinaryLoader(new File(this.location.getPath())); } IL_EC: binaryLoader.verifyHeader(); this.counts = binaryLoader.readCounts(); if (this.maxDepth <= 0 || this.maxDepth > this.counts.Length) { this.maxDepth = this.counts.Length; } if (this.maxDepth > 1) { this.quant = binaryLoader.readQuant(this.maxDepth); } this.unigrams = binaryLoader.readUnigrams(this.counts[0]); if (this.maxDepth > 1) { this.trie = new NgramTrie(this.counts, this.quant.getProbBoSize(), this.quant.getProbSize()); binaryLoader.readTrieByteArr(this.trie.getMem()); } this.words = binaryLoader.readWords(this.counts[0]); this.buildUnigramIDMap(); this.ngramProbCache = new LRUCache(this.ngramCacheSize); binaryLoader.close(); TimerPool.getTimer(this, "Load LM").stop(); }
public async Task TenK_WithPooledTimer() { TimerPool timerPool = new TimerPool(1); List <Task> timers = new List <Task>(this.timeouts.Count); for (int i = 0; i < this.timeouts.Count; i++) { PooledTimer timer = timerPool.GetPooledTimer(this.timeouts[i] / 1000); timers.Add(timer.StartTimerAsync()); } await Task.WhenAll(timers); timerPool.Dispose(); }
public virtual void statusChanged(Recognizer.State status) { if (status == Recognizer.State.__ALLOCATED && this.showTimers) { TimerPool.dumpAll(this.logger); } if (status == Recognizer.State.__DEALLOCATING && this.showTimers) { TimerPool.dumpAll(this.logger); } if (status == Recognizer.State.__DEALLOCATED && this.showSummary) { this.showAudioSummary(); } }
/** Compiles the n-gram into a lex tree that is used during the search */ private void CompileGrammar() { TimerPool.GetTimer(this, "Compile").Start(); SentenceEndWord = Dictionary.GetSentenceEndWord(); _sentenceStartWordArray = new Word[1]; _sentenceStartWordArray[0] = Dictionary.GetSentenceStartWord(); MaxDepth = LanguageModel.MaxDepth; GenerateHmmTree(); TimerPool.GetTimer(this, "Compile").Stop(); // Now that we are all done, dump out some interesting // information about the process _searchGraph = new LexTreeSearchGraph(GetInitialSearchState()); }
public override void allocate() { this.scoreTimer = TimerPool.getTimer(this, "Score"); this.pruneTimer = TimerPool.getTimer(this, "Prune"); this.growTimer = TimerPool.getTimer(this, "Grow"); this.totalTokensScored = StatisticsVariable.getStatisticsVariable("totalTokensScored"); this.curTokensScored = StatisticsVariable.getStatisticsVariable("curTokensScored"); this.tokensCreated = StatisticsVariable.getStatisticsVariable("tokensCreated"); try { this.linguist.allocate(); this.pruner.allocate(); this.scorer.allocate(); } catch (IOException ex) { throw new RuntimeException("Allocation of search manager resources failed", ex); } }
void Benchmark() { var nullCount = 0; this.LogInfo("benchmarking ..."); TimerPool.GetTimer(this, "hmmPoolBenchmark").Start(); for (var i = 0; i < 1000000; i++) { var id = Ids[i % Ids.Length]; var position = Pos[i % Pos.Length]; var hmm = GetHMM(id, position); if (hmm == null) { nullCount++; } } TimerPool.GetTimer(this, "hmmPoolBenchmark").Stop(); this.LogInfo("null count " + nullCount); }
public override void allocate() { if (!this.allocated) { this.dictionary = new HashMap(); this.wordDictionary = new HashMap(); sphinx.util.Timer timer = TimerPool.getTimer(this, "Load Dictionary"); this.fillerWords = new HashSet(); timer.start(); this.logger.info(new StringBuilder().append("Loading dictionary from: ").append(this.wordDictionaryFile).toString()); this.loadDictionary(this.wordDictionaryFile.openStream(), false); this.loadCustomDictionaries(this.addendaUrlList); this.logger.info(new StringBuilder().append("Loading filler dictionary from: ").append(this.fillerDictionaryFile).toString()); this.loadDictionary(this.fillerDictionaryFile.openStream(), true); if (this.g2pModelFile != null && !String.instancehelper_equals(this.g2pModelFile.getPath(), "")) { this.g2pDecoder = new G2PConverter(this.g2pModelFile); } timer.stop(); } }
private void Init() { _timer = TimerPool.GetTimer(this, "FrontEnd"); LastDataProcessor = null; foreach (IDataProcessor dp in _frontEndList) { Debug.Assert(dp != null); if (LastDataProcessor != null) { dp.Predecessor = LastDataProcessor; } if (_first == null) { _first = dp; } LastDataProcessor = dp; } Initialize(); }
/* * /// (non-Javadoc) * * /// @see edu.cmu.sphinx.decoder.search.SearchManager#allocate() */ override public void allocate() { // tokenTracker = new TokenTracker(); // tokenTypeTracker = new TokenTypeTracker(); scoreTimer = TimerPool.getTimer(this, "Score"); pruneTimer = TimerPool.getTimer(this, "Prune"); growTimer = TimerPool.getTimer(this, "Grow"); totalTokensScored = StatisticsVariable.getStatisticsVariable("totalTokensScored"); curTokensScored = StatisticsVariable.getStatisticsVariable("curTokensScored"); tokensCreated = StatisticsVariable.getStatisticsVariable("tokensCreated"); try { linguist.allocate(); pruner.allocate(); scorer.allocate(); } catch (IOException e) { throw new SystemException("Allocation of search manager resources failed", e); } }
/// <summary> /// @see Search.SearchManager#allocate() /// </summary> public override void Allocate() { _totalTokensScored = StatisticsVariable.GetStatisticsVariable("totalTokensScored"); _tokensPerSecond = StatisticsVariable.GetStatisticsVariable("tokensScoredPerSecond"); _curTokensScored = StatisticsVariable.GetStatisticsVariable("curTokensScored"); TokensCreated = StatisticsVariable.GetStatisticsVariable("tokensCreated"); _viterbiPruned = StatisticsVariable.GetStatisticsVariable("viterbiPruned"); _beamPruned = StatisticsVariable.GetStatisticsVariable("beamPruned"); try { Linguist.Allocate(); _pruner.Allocate(); _scorer.Allocate(); } catch (IOException e) { throw new SystemException("Allocation of search manager resources failed", e); } _scoreTimer = TimerPool.GetTimer(this, "Score"); _pruneTimer = TimerPool.GetTimer(this, "Prune"); GrowTimer = TimerPool.GetTimer(this, "Grow"); }
public virtual void load() { if (!this.loaded) { TimerPool.getTimer(this, "Load AM").start(); this.hmmManager = new HMMManager(); this.contextIndependentUnits = new LinkedHashMap(); this.meanTransformationMatrixPool = null; this.meanTransformationVectorPool = null; this.varianceTransformationMatrixPool = null; this.varianceTransformationVectorPool = null; this.transformMatrix = (float[][])null; try { this.loadModelFiles(); } catch (URISyntaxException ex) { throw new RuntimeException(ex); } this.loaded = true; TimerPool.getTimer(this, "Load AM").stop(); } }
public override void Allocate() { // tokenTracker = new TokenTracker(); // tokenTypeTracker = new TokenTypeTracker(); ScoreTimer = TimerPool.GetTimer(this, "Score"); PruneTimer = TimerPool.GetTimer(this, "Prune"); GrowTimer = TimerPool.GetTimer(this, "Grow"); TotalTokensScored = StatisticsVariable.GetStatisticsVariable("totalTokensScored"); CurTokensScored = StatisticsVariable.GetStatisticsVariable("curTokensScored"); TokensCreated = StatisticsVariable.GetStatisticsVariable("tokensCreated"); try { Linguist.Allocate(); Pruner.Allocate(); Scorer.Allocate(); } catch (IOException e) { throw new SystemException("Allocation of search manager resources failed", e); } }
internal virtual void benchmark() { int num = 0; [email protected]("benchmarking ..."); TimerPool.getTimer(this, "hmmPoolBenchmark").start(); for (int i = 0; i < 1000000; i++) { int[] array = HMMPool.ids; int num2 = i; int num3 = HMMPool.ids.Length; int unitID = array[(num3 != -1) ? (num2 % num3) : 0]; HMMPosition[] array2 = HMMPool.pos; int num4 = i; int num5 = HMMPool.pos.Length; HMMPosition position = array2[(num5 != -1) ? (num4 % num5) : 0]; if (this.getHMM(unitID, position) == null) { num++; } } TimerPool.getTimer(this, "hmmPoolBenchmark").stop(); [email protected](new StringBuilder().append("null count ").append(num).toString()); }