PageRenderTime 25ms CodeModel.GetById 13ms app.highlight 8ms RepoModel.GetById 1ms app.codeStats 0ms

/native/external/espeak/src/phoneme.h

http://eyes-free.googlecode.com/
C++ Header | 159 lines | 104 code | 27 blank | 28 comment | 0 complexity | 82161a2f5d774f900d6122cf95096be6 MD5 | raw file
  1/***************************************************************************
  2 *   Copyright (C) 2005 to 2007 by Jonathan Duddington                     *
  3 *   email: jonsd@users.sourceforge.net                                    *
  4 *                                                                         *
  5 *   This program is free software; you can redistribute it and/or modify  *
  6 *   it under the terms of the GNU General Public License as published by  *
  7 *   the Free Software Foundation; either version 3 of the License, or     *
  8 *   (at your option) any later version.                                   *
  9 *                                                                         *
 10 *   This program is distributed in the hope that it will be useful,       *
 11 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 12 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 13 *   GNU General Public License for more details.                          *
 14 *                                                                         *
 15 *   You should have received a copy of the GNU General Public License     *
 16 *   along with this program; if not, see:                                 *
 17 *               <http://www.gnu.org/licenses/>.                           *
 18 ***************************************************************************/
 19
 20
 21
 22// phoneme types
 23#define phPAUSE   0
 24#define phSTRESS  1
 25#define phVOWEL   2
 26#define phLIQUID  3
 27#define phSTOP    4
 28#define phVSTOP   5
 29#define phFRICATIVE 6
 30#define phVFRICATIVE 7
 31#define phNASAL   8
 32#define phVIRTUAL 9
 33#define phDELETED 14
 34#define phINVALID 15
 35
 36
 37// phoneme properties
 38//   bits 16-19 give place of articulation (not currently used)
 39#define phWAVE     0x01
 40#define phUNSTRESSED 0x02
 41#define phFORTIS   0x08
 42#define phVOICED   0x10
 43#define phSIBILANT 0x20
 44#define phNOLINK   0x40
 45#define phTRILL    0x80
 46#define phVOWEL2   0x100   // liquid that is considered a vowel
 47#define phPALATAL  0x200
 48#define phAPPENDPH 0x2000  // always insert another phoneme (link_out) after this one
 49#define phBRKAFTER 0x4000  // [*] add a post-pause
 50#define phBEFOREPAUSE 0x8000  // replace with the link_out phoneme if the next phoneme is a pause
 51
 52#define phALTERNATIVE    0x1c00   // bits 10,11,12  specifying use of alternative_ph
 53#define phBEFOREVOWEL    0x0000
 54#define phBEFOREVOWELPAUSE  0x0400
 55#define phBEFORENOTVOWEL 0x0c00
 56#define phBEFORENOTVOWEL2 0x1000
 57#define phSWITCHVOICING  0x0800
 58
 59#define phNONSYLLABIC 0x100000   // don't count this vowel as a syllable when finding the stress position 
 60#define phLONG        0x200000
 61
 62// fixed phoneme code numbers, these can be used from the program code
 63#define phonCONTROL     1
 64#define phonSTRESS_U    2
 65#define phonSTRESS_D    3
 66#define phonSTRESS_2    4
 67#define phonSTRESS_3    5
 68#define phonSTRESS_P    6
 69#define phonSTRESS_P2   7    // priority stress within a word
 70#define phonSTRESS_PREV 8
 71#define phonPAUSE       9
 72#define phonPAUSE_SHORT 10
 73#define phonPAUSE_NOLINK 11
 74#define phonLENGTHEN    12
 75#define phonSCHWA       13
 76#define phonSCHWA_SHORT 14
 77#define phonEND_WORD    15
 78#define phonSONORANT    16
 79#define phonDEFAULTTONE 17
 80#define phonCAPITAL     18
 81#define phonGLOTTALSTOP 19
 82#define phonSYLLABIC    20
 83#define phonSWITCH      21
 84#define phonX1          22      // a language specific action
 85#define phonPAUSE_VSHORT 23
 86#define phonPAUSE_LONG  24
 87#define phonT_REDUCED   25
 88#define phonSTRESS_TONIC 26
 89#define phonPAUSE_CLAUSE 27
 90
 91extern const unsigned char pause_phonemes[8];  // 0, vshort, short, pause, long, glottalstop
 92
 93// place of articulation
 94#define phPLACE        0xf0000
 95#define phPLACE_pla    0x60000
 96
 97#define N_PHONEME_TABS     100     // number of phoneme tables
 98#define N_PHONEME_TAB      256     // max phonemes in a phoneme table
 99#define N_PHONEME_TAB_NAME  32     // must be multiple of 4
100
101// main table of phonemes, index by phoneme number (1-254)
102typedef struct {
103	unsigned int mnemonic;        // 1st char is in the l.s.byte
104	unsigned int phflags;         // bits 28-30 reduce_to level,  bits 16-19 place of articulation
105                                 // bits 10-11 alternative ph control
106
107	unsigned short std_length;    // for vowels, in mS;  for phSTRESS, the stress/tone type
108	unsigned short  spect;
109	unsigned short  before;
110	unsigned short  after;
111
112	unsigned char  code;          // the phoneme number
113	unsigned char  type;          // phVOWEL, phPAUSE, phSTOP etc
114	unsigned char  start_type;
115	unsigned char  end_type;
116	
117	unsigned char  length_mod;     // a length_mod group number, used to access length_mod_tab
118	unsigned char  reduce_to;      // change to this phoneme if unstressed
119	unsigned char  alternative_ph; // change to this phoneme if a vowel follows/doesn't follow
120	unsigned char  link_out;       // insert linking phoneme if a vowel follows
121	
122} PHONEME_TAB;
123
124
125// Several phoneme tables may be loaded into memory. phoneme_tab points to
126// one for the current voice
127extern int n_phoneme_tab;
128extern int current_phoneme_table;
129extern PHONEME_TAB *phoneme_tab[N_PHONEME_TAB];
130extern unsigned char phoneme_tab_flags[N_PHONEME_TAB];  // bit 0: not inherited
131
132typedef struct {
133	char name[N_PHONEME_TAB_NAME];
134	PHONEME_TAB *phoneme_tab_ptr;
135	int n_phonemes;
136	int includes;           // also include the phonemes from this other phoneme table
137} PHONEME_TAB_LIST;
138
139
140
141// table of phonemes to be replaced with different phonemes, for the current voice
142#define N_REPLACE_PHONEMES   60
143typedef struct {
144	unsigned char old_ph;
145	unsigned char new_ph;
146	char type;   // 0=always replace, 1=only at end of word
147} REPLACE_PHONEMES;
148
149extern int n_replace_phonemes;
150extern REPLACE_PHONEMES replace_phonemes[N_REPLACE_PHONEMES];
151
152
153
154char *EncodePhonemes(char *p, char *outptr, unsigned char *bad_phoneme);
155void DecodePhonemes(const char *inptr, char *outptr);
156const char *PhonemeTabName(void);
157int LookupPh(const char *string);
158extern const char *WordToString(unsigned int word);
159