/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. // phoneme types
  20. #define phPAUSE 0
  21. #define phSTRESS 1
  22. #define phVOWEL 2
  23. #define phLIQUID 3
  24. #define phSTOP 4
  25. #define phVSTOP 5
  26. #define phFRICATIVE 6
  27. #define phVFRICATIVE 7
  28. #define phNASAL 8
  29. #define phVIRTUAL 9
  30. #define phDELETED 14
  31. #define phINVALID 15
  32. // phoneme properties
  33. // bits 16-19 give place of articulation (not currently used)
  34. #define phWAVE 0x01
  35. #define phUNSTRESSED 0x02
  36. #define phFORTIS 0x08
  37. #define phVOICED 0x10
  38. #define phSIBILANT 0x20
  39. #define phNOLINK 0x40
  40. #define phTRILL 0x80
  41. #define phVOWEL2 0x100 // liquid that is considered a vowel
  42. #define phPALATAL 0x200
  43. #define phAPPENDPH 0x2000 // always insert another phoneme (link_out) after this one
  44. #define phBRKAFTER 0x4000 // [*] add a post-pause
  45. #define phBEFOREPAUSE 0x8000 // replace with the link_out phoneme if the next phoneme is a pause
  46. #define phALTERNATIVE 0x1c00 // bits 10,11,12 specifying use of alternative_ph
  47. #define phBEFOREVOWEL 0x0000
  48. #define phBEFOREVOWELPAUSE 0x0400
  49. #define phBEFORENOTVOWEL 0x0c00
  50. #define phBEFORENOTVOWEL2 0x1000
  51. #define phSWITCHVOICING 0x0800
  52. #define phNONSYLLABIC 0x100000 // don't count this vowel as a syllable when finding the stress position
  53. #define phLONG 0x200000
  54. // fixed phoneme code numbers, these can be used from the program code
  55. #define phonCONTROL 1
  56. #define phonSTRESS_U 2
  57. #define phonSTRESS_D 3
  58. #define phonSTRESS_2 4
  59. #define phonSTRESS_3 5
  60. #define phonSTRESS_P 6
  61. #define phonSTRESS_P2 7 // priority stress within a word
  62. #define phonSTRESS_PREV 8
  63. #define phonPAUSE 9
  64. #define phonPAUSE_SHORT 10
  65. #define phonPAUSE_NOLINK 11
  66. #define phonLENGTHEN 12
  67. #define phonSCHWA 13
  68. #define phonSCHWA_SHORT 14
  69. #define phonEND_WORD 15
  70. #define phonSONORANT 16
  71. #define phonDEFAULTTONE 17
  72. #define phonCAPITAL 18
  73. #define phonGLOTTALSTOP 19
  74. #define phonSYLLABIC 20
  75. #define phonSWITCH 21
  76. #define phonX1 22 // a language specific action
  77. #define phonPAUSE_VSHORT 23
  78. #define phonPAUSE_LONG 24
  79. #define phonT_REDUCED 25
  80. #define phonSTRESS_TONIC 26
  81. #define phonPAUSE_CLAUSE 27
  82. extern const unsigned char pause_phonemes[8]; // 0, vshort, short, pause, long, glottalstop
  83. // place of articulation
  84. #define phPLACE 0xf0000
  85. #define phPLACE_pla 0x60000
  86. #define N_PHONEME_TABS 100 // number of phoneme tables
  87. #define N_PHONEME_TAB 256 // max phonemes in a phoneme table
  88. #define N_PHONEME_TAB_NAME 32 // must be multiple of 4
  89. // main table of phonemes, index by phoneme number (1-254)
  90. typedef struct {
  91. unsigned int mnemonic; // 1st char is in the l.s.byte
  92. unsigned int phflags; // bits 28-30 reduce_to level, bits 16-19 place of articulation
  93. // bits 10-11 alternative ph control
  94. unsigned short std_length; // for vowels, in mS; for phSTRESS, the stress/tone type
  95. unsigned short spect;
  96. unsigned short before;
  97. unsigned short after;
  98. unsigned char code; // the phoneme number
  99. unsigned char type; // phVOWEL, phPAUSE, phSTOP etc
  100. unsigned char start_type;
  101. unsigned char end_type;
  102. unsigned char length_mod; // a length_mod group number, used to access length_mod_tab
  103. unsigned char reduce_to; // change to this phoneme if unstressed
  104. unsigned char alternative_ph; // change to this phoneme if a vowel follows/doesn't follow
  105. unsigned char link_out; // insert linking phoneme if a vowel follows
  106. } PHONEME_TAB;
  107. // Several phoneme tables may be loaded into memory. phoneme_tab points to
  108. // one for the current voice
  109. extern int n_phoneme_tab;
  110. extern int current_phoneme_table;
  111. extern PHONEME_TAB *phoneme_tab[N_PHONEME_TAB];
  112. extern unsigned char phoneme_tab_flags[N_PHONEME_TAB]; // bit 0: not inherited
  113. typedef struct {
  114. char name[N_PHONEME_TAB_NAME];
  115. PHONEME_TAB *phoneme_tab_ptr;
  116. int n_phonemes;
  117. int includes; // also include the phonemes from this other phoneme table
  118. } PHONEME_TAB_LIST;
  119. // table of phonemes to be replaced with different phonemes, for the current voice
  120. #define N_REPLACE_PHONEMES 60
  121. typedef struct {
  122. unsigned char old_ph;
  123. unsigned char new_ph;
  124. char type; // 0=always replace, 1=only at end of word
  125. } REPLACE_PHONEMES;
  126. extern int n_replace_phonemes;
  127. extern REPLACE_PHONEMES replace_phonemes[N_REPLACE_PHONEMES];
  128. char *EncodePhonemes(char *p, char *outptr, unsigned char *bad_phoneme);
  129. void DecodePhonemes(const char *inptr, char *outptr);
  130. const char *PhonemeTabName(void);
  131. int LookupPh(const char *string);
  132. extern const char *WordToString(unsigned int word);