1 /** 2 * @file stddefs.h 3 * 4 * <EN> 5 * @brief Basic common definitions 6 * 7 * This is a common header that should be included in all the Julius related 8 * sources. This file contains include list of basic C headers, definition of 9 * common static values and function macro, and basic typedefs to handle 10 * speech input and words. 11 * 12 * The unix function macro definition for Win32 environment is also included. 13 * 14 * Only the important part is documented. Fof all the definition, see 15 * the source. 16 * </EN> 17 * <JA> 18 * @brief ���ܤζ������ 19 * 20 * ���Υե�����Ϥ��٤ƤΥ饤�֥��� include �����٤����̥إå��Ǥ��� 21 * ����Ū��C�إå��ե������ include, �褯�Ȥ�������ͤȼ��ޥ��������� 22 * ���٤Ƥδؿ��Ƕ��̤����Ѥ��������Ū�ʷ���������ޤޤ�ޤ��� 23 * 24 * �ޤ���Win32 �⡼�ɤǤΥ���ѥ���Τ���δؿ��Υޥ��������ޤߤޤ��� 25 * </JA> 26 * 27 * @sa machines.h 28 * 29 * @author Akinobu LEE 30 * @date Sat Feb 12 11:49:37 2005 31 * 32 * $Revision: 1.3 $ 33 * 34 */ 35 /* 36 * Copyright (c) 1991-2007 Kawahara Lab., Kyoto University 37 * Copyright (c) 2000-2005 Shikano Lab., Nara Institute of Science and Technology 38 * Copyright (c) 2005-2007 Julius project team, Nagoya Institute of Technology 39 * All rights reserved 40 */ 41 42 #ifndef __SENT_STANDARD_DEFS__ 43 #define __SENT_STANDARD_DEFS__ 44 45 /* load site-dependent configuration by configure script */ 46 #if defined(_WIN32) && !defined(__CYGWIN32__) && !defined(__MINGW32__) 47 #include <sent/config-win.h> 48 #else 49 #include <sent/config.h> 50 #endif 51 52 #include <stdio.h> 53 #include <stdlib.h> 54 #include <strings.h> 55 #include <string.h> 56 #include <math.h> 57 #if !defined(_WIN32) || defined(__CYGWIN32__) || defined(__MINGW32__) 58 /* unixen */ 59 #ifdef HAVE_UNISTD_H 60 #include <unistd.h> 61 #endif 62 #include <strings.h> 63 #include <sys/time.h> 64 #else 65 /* win32 */ 66 #include <io.h> 67 #endif 68 69 /* get around sleep() */ 70 #ifdef _WIN32 71 # if !defined(__CYGWIN32__) && !defined(__MINGW32__) 72 # define sleep(x) Sleep(x) 73 # endif 74 # ifndef HAVE_SLEEP 75 # define sleep(x) Sleep(x) 76 # endif 77 #endif 78 79 #include <errno.h> 80 #include <fcntl.h> 81 #include <sys/types.h> 82 83 #include <sent/machines.h> 84 85 /// Static PI value 86 #if !defined(PI) 87 #define PI 3.14159265358979 88 #endif 89 /// Static 2*PI value 90 #if !defined(TPI) 91 #define TPI 6.28318530717959 92 #endif 93 /// Static log_e(TPI) 94 #if !defined(LOGTPI) 95 #define LOGTPI 1.83787706640935 96 #endif 97 #if !defined(LOG_TEN) 98 /// Static log_e(10) 99 #define LOG_TEN 2.30258509 100 /// Static 1 / LOG_TEN 101 #define INV_LOG_TEN .434294482 102 #endif 103 104 /// Boolean type 105 typedef unsigned char boolean; 106 #define TRUE 1 107 #define FALSE 0 108 109 #if defined(_WIN32) && !defined(__CYGWIN32__) && !defined(__MINGW32__) 110 /* win32 functions */ 111 #define getpagesize() (4096) 112 #define access _access 113 #define chmod _chmod 114 #define close _close 115 #define eof _eof 116 #define filelength _filelength 117 #define isatty _isatty 118 #define lseek _lseek 119 #define open _open 120 #define read _read 121 #define write _write 122 #define mkdir _mkdir 123 #define unlink _unlink 124 #define getcwd _getcwd 125 #define getpid _getpid 126 #define vsnprintf _vsnprintf 127 #define snprintf _snprintf 128 #endif 129 130 #ifndef R_OK 131 #define R_OK 4 132 #endif 133 #ifndef W_OK 134 #define W_OK 2 135 #endif 136 #ifndef X_OK 137 # if defined(_WIN32) && !defined(__CYGWIN32__) && !defined(__MINGW32__) 138 # define X_OK 0 139 # else 140 # define X_OK 1 141 # endif 142 #endif 143 #ifndef F_OK 144 #define F_OK 0 145 #endif 146 147 /* some macros */ 148 #undef max 149 #undef min 150 #define max(A,B) ((A)>=(B)?(A):(B)) 151 #define min(A,B) ((A)<(B)?(A):(B)) 152 #define abs(X) ((X)>0?(X):-(X)) 153 /// String match function, 0 if the given strings did not match 154 #define strmatch !strcmp 155 /// String match function with length limit, 0 if the given strings did not match 156 #define strnmatch !strncmp 157 /// Common text delimiter 158 #define DELM " \t\n" 159 160 /// definition of log(0) used to represent 'no value' in likelihood computation 161 #define LOG_ZERO -1000000 162 /** 163 * -log_e(-LOG_ZERO) @sa libsent/src/phmm/output.c 164 * 165 */ 166 #define LOG_ADDMIN -13.815510558 167 168 /// To specify log output level 169 enum LogOutputLevel { 170 LOG_NORMAL, ///< Normal level 171 LOG_VERBOSE, ///< Verbose level 172 LOG_DEBUG ///< Debug level 173 }; 174 175 /// To specify the direction of N-gram when reading ARPA file 176 enum { 177 DIR_LR, ///< left-to-right (for 2-gram) 178 DIR_RL ///< right-to-left (for reverse 3-gram) 179 }; 180 181 /// Typedefs to handle speech inputs, parameters and words 182 /* you can't use double for typedefs below */ 183 /* also look at lib/util/mybmalloc.c */ 184 typedef float PROB; ///< Probability 185 typedef float LOGPROB; ///< Log probability 186 typedef short SP16; ///< 16bit speech data 187 typedef float VECT; ///< Vector element 188 189 190 #ifdef WORDS_INT 191 /* maximum number of words = 2G = 2^31 (--enable-words-int) */ 192 typedef int WORD_ID; ///< Typedef for word ID 193 #define MAX_WORD_NUM 2147483647 ///< Maximum size of vocabulary 194 #define WORD_INVALID 2147483647 ///< Out of word ID to represent no-existence of word 195 #else 196 /* maximum number of words = 65535 */ 197 typedef unsigned short WORD_ID; ///< Typedef for word ID 198 #define MAX_WORD_NUM 65535 ///< Maximum size of vocabulary 199 #define WORD_INVALID 65535 ///< Out of word ID to represent no-existence of word 200 #endif 201 202 /// Assumed maximum number of bytes per input line 203 #define MAXLINELEN 1024 204 205 /// Limit of maximum length of a file path 206 #ifndef MAXPATHLEN 207 #define MAXPATHLEN 2048 208 #endif 209 210 #include <sent/util.h> 211 212 #endif /* __SENT_STANDARD_DEFS__ */ 213