online-timing.h
Go to the documentation of this file.
1 // online2/online-timing.h
2 
3 // Copyright 2014 Johns Hopkins University (author: Daniel Povey)
4 
5 // See ../../COPYING for clarification regarding multiple authors
6 //
7 // Licensed under the Apache License, Version 2.0 (the "License");
8 // you may not use this file except in compliance with the License.
9 // You may obtain a copy of the License at
10 //
11 // http://www.apache.org/licenses/LICENSE-2.0
12 //
13 // THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 // KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
15 // WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
16 // MERCHANTABLITY OR NON-INFRINGEMENT.
17 // See the Apache 2 License for the specific language governing permissions and
18 // limitations under the License.
19 
20 
21 #ifndef KALDI_ONLINE2_ONLINE_TIMING_H_
22 #define KALDI_ONLINE2_ONLINE_TIMING_H_
23 
24 #include <string>
25 #include <vector>
26 #include <deque>
27 
28 #include "base/timer.h"
29 #include "base/kaldi-error.h"
30 
31 namespace kaldi {
34 
35 
36 class OnlineTimer;
37 
42  public:
47  void Print(bool online = true);
48  protected:
49  friend class OnlineTimer;
51  // all times are in seconds.
52  double total_audio_; // total time of audio.
53  double total_time_taken_; // total time spent processing the audio.
54  double total_time_waited_; // total time we pretended to wait (but just
55  // increased the waited_ counter)... zero if you
56  // called SleepUntil instead of WaitUntil().
57  double max_delay_; // maximum delay at utterance end.
58  std::string max_delay_utt_;
59 };
60 
61 
62 
87 
88 class OnlineTimer {
89  public:
90  OnlineTimer(const std::string &utterance_id);
91 
95  void SleepUntil(double cur_utterance_length);
96 
100  void WaitUntil(double cur_utterance_length);
101 
104  void OutputStats(OnlineTimingStats *stats);
105 
108  double Elapsed();
109 
110  private:
111  std::string utterance_id_;
113  // all times are in seconds.
114  double waited_;
116 };
117 
118 
120 } // namespace kaldi
121 
122 
123 
124 #endif // KALDI_ONLINE2_ONLINE_TIMING_
This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
Definition: chain.dox:20
class OnlineTimer is used to test real-time decoding algorithms and evaluate how long the decoding of...
Definition: online-timing.h:88
std::string utterance_id_
kaldi::int32 int32
void Print(bool online=true)
Here, if "online == false" we take into account that the setup was used in not-really-online mode whe...
class OnlineTimingStats stores statistics from timing of online decoding, which will enable the Print...
Definition: online-timing.h:41