All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
kaldi-utils.cc
Go to the documentation of this file.
1 // base/kaldi-utils.cc
2 // Copyright 2009-2011 Karel Vesely; Yanmin Qian; Microsoft Corporation
3 
4 // See ../../COPYING for clarification regarding multiple authors
5 //
6 // Licensed under the Apache License, Version 2.0 (the "License");
7 // you may not use this file except in compliance with the License.
8 // You may obtain a copy of the License at
9 
10 // http://www.apache.org/licenses/LICENSE-2.0
11 
12 // THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
13 // KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
14 // WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
15 // MERCHANTABLITY OR NON-INFRINGEMENT.
16 // See the Apache 2 License for the specific language governing permissions and
17 // limitations under the License.
18 
19 #ifdef _WIN32_WINNT_WIN8
20 #include <Synchapi.h>
21 #elif defined(_WIN32) || defined(_MSC_VER) || defined(MINGW)
22 #include <Windows.h>
23 #if defined(_MSC_VER) && _MSC_VER < 1900
24 #define snprintf _snprintf
25 #endif /* _MSC_VER < 1900 */
26 #else
27 #include <unistd.h>
28 #endif
29 
30 #include <string>
31 #include "base/kaldi-common.h"
32 
33 
34 namespace kaldi {
35 
36 std::string CharToString(const char &c) {
37  char buf[20];
38  if (std::isprint(c))
39  snprintf(buf, sizeof(buf), "\'%c\'", c);
40  else
41  snprintf(buf, sizeof(buf), "[character %d]", static_cast<int>(c));
42  return (std::string) buf;
43 }
44 
45 void Sleep(float seconds) {
46 #if defined(_MSC_VER) || defined(MINGW)
47  ::Sleep(static_cast<int>(seconds * 1000.0));
48 #else
49  usleep(static_cast<int>(seconds * 1000000.0));
50 #endif
51 }
52 
53 } // end namespace kaldi
Relabels neural network egs with the read pdf-id alignments.
Definition: chain.dox:20
void Sleep(float seconds)
Definition: kaldi-utils.cc:45
std::string CharToString(const char &c)
Definition: kaldi-utils.cc:36