21 #ifndef KALDI_BASE_KALDI_UTILS_H_ 22 #define KALDI_BASE_KALDI_UTILS_H_ 1 25 # define WIN32_LEAN_AND_MEAN 32 #define unlink _unlink 41 #pragma warning(disable: 4244 4056 4305 4800 4267 4996 4756 4661) 45 #define __restrict__ __restrict 50 # define KALDI_MEMALIGN(align, size, pp_orig) \ 51 (*(pp_orig) = _aligned_malloc(size, align)) 52 # define KALDI_MEMALIGN_FREE(x) _aligned_free(x) 53 #elif defined(__CYGWIN__) 54 # define KALDI_MEMALIGN(align, size, pp_orig) \ 55 (*(pp_orig) = aligned_alloc(align, size)) 56 # define KALDI_MEMALIGN_FREE(x) free(x) 58 # define KALDI_MEMALIGN(align, size, pp_orig) \ 59 (!posix_memalign(pp_orig, align, size) ? *(pp_orig) : NULL) 60 # define KALDI_MEMALIGN_FREE(x) free(x) 64 #pragma warning(disable: 383) // ICPC remark we don't want. 65 #pragma warning(disable: 810) // ICPC remark we don't want. 66 #pragma warning(disable: 981) // ICPC remark we don't want. 67 #pragma warning(disable: 1418) // ICPC remark we don't want. 68 #pragma warning(disable: 444) // ICPC remark we don't want. 69 #pragma warning(disable: 869) // ICPC remark we don't want. 70 #pragma warning(disable: 1287) // ICPC remark we don't want. 71 #pragma warning(disable: 279) // ICPC remark we don't want. 72 #pragma warning(disable: 981) // ICPC remark we don't want. 85 return (*reinterpret_cast<char*>(&check) != 0);
91 void Sleep(
float seconds);
94 #define KALDI_SWAP8(a) { \ 95 int t = (reinterpret_cast<char*>(&a))[0];\ 96 (reinterpret_cast<char*>(&a))[0]=(reinterpret_cast<char*>(&a))[7];\ 97 (reinterpret_cast<char*>(&a))[7]=t;\ 98 t = (reinterpret_cast<char*>(&a))[1];\ 99 (reinterpret_cast<char*>(&a))[1]=(reinterpret_cast<char*>(&a))[6];\ 100 (reinterpret_cast<char*>(&a))[6]=t;\ 101 t = (reinterpret_cast<char*>(&a))[2];\ 102 (reinterpret_cast<char*>(&a))[2]=(reinterpret_cast<char*>(&a))[5];\ 103 (reinterpret_cast<char*>(&a))[5]=t;\ 104 t = (reinterpret_cast<char*>(&a))[3];\ 105 (reinterpret_cast<char*>(&a))[3]=(reinterpret_cast<char*>(&a))[4];\ 106 (reinterpret_cast<char*>(&a))[4]=t;} 107 #define KALDI_SWAP4(a) { \ 108 int t = (reinterpret_cast<char*>(&a))[0];\ 109 (reinterpret_cast<char*>(&a))[0]=(reinterpret_cast<char*>(&a))[3];\ 110 (reinterpret_cast<char*>(&a))[3]=t;\ 111 t = (reinterpret_cast<char*>(&a))[1];\ 112 (reinterpret_cast<char*>(&a))[1]=(reinterpret_cast<char*>(&a))[2];\ 113 (reinterpret_cast<char*>(&a))[2]=t;} 114 #define KALDI_SWAP2(a) { \ 115 int t = (reinterpret_cast<char*>(&a))[0];\ 116 (reinterpret_cast<char*>(&a))[0]=(reinterpret_cast<char*>(&a))[1];\ 117 (reinterpret_cast<char*>(&a))[1]=t;} 121 #define KALDI_DISALLOW_COPY_AND_ASSIGN(type) \ 123 void operator = (const type&) 131 #define KALDI_COMPILE_TIME_ASSERT(b) KaldiCompileTimeAssert<(b)>::Check() 133 #define KALDI_ASSERT_IS_INTEGER_TYPE(I) \ 134 KaldiCompileTimeAssert<std::numeric_limits<I>::is_specialized \ 135 && std::numeric_limits<I>::is_integer>::Check() 137 #define KALDI_ASSERT_IS_FLOATING_TYPE(F) \ 138 KaldiCompileTimeAssert<std::numeric_limits<F>::is_specialized \ 139 && !std::numeric_limits<F>::is_integer>::Check() 141 #if defined(_MSC_VER) 142 #define KALDI_STRCASECMP _stricmp 143 #elif defined(__CYGWIN__) 145 #define KALDI_STRCASECMP strcasecmp 147 #define KALDI_STRCASECMP strcasecmp 150 # define KALDI_STRTOLL(cur_cstr, end_cstr) _strtoi64(cur_cstr, end_cstr, 10); 152 # define KALDI_STRTOLL(cur_cstr, end_cstr) strtoll(cur_cstr, end_cstr, 10); 155 #endif // KALDI_BASE_KALDI_UTILS_H_ This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
void Sleep(float seconds)
int MachineIsLittleEndian()
std::string CharToString(const char &c)