eSpeak NG is an open source speech synthesizer that supports more than hundred languages and accents.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

phoneme.h 5.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. /*
  2. * Copyright (C) 2005 to 2010 by Jonathan Duddington
  3. * email: [email protected]
  4. * Copyright (C) 2015 Reece H. Dunn
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, see: <http://www.gnu.org/licenses/>.
  18. */
  19. #ifdef __cplusplus
  20. extern "C"
  21. {
  22. #endif
  23. // phoneme types
  24. #define phPAUSE 0
  25. #define phSTRESS 1
  26. #define phVOWEL 2
  27. #define phLIQUID 3
  28. #define phSTOP 4
  29. #define phVSTOP 5
  30. #define phFRICATIVE 6
  31. #define phVFRICATIVE 7
  32. #define phNASAL 8
  33. #define phVIRTUAL 9
  34. #define phDELETED 14
  35. #define phINVALID 15
  36. // phoneme properties
  37. // bits 16-19 give place of articulation
  38. #define phARTICULATION 0xf0000
  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 phSINGLE_INSTN 0x1000 // this phoneme has a single instruction program, with an implicit Return
  49. #define phDONTLIST 0x2000 // don't list in dict_phonemes
  50. #define phBRKAFTER 0x4000 // [*] add a post-pause
  51. #define phNONSYLLABIC 0x100000 // don't count this vowel as a syllable when finding the stress position
  52. #define phLONG 0x200000
  53. #define phLENGTHENSTOP 0x400000 // make the pre-pause slightly longer
  54. #define phRHOTIC 0x800000 // bit 23
  55. #define phNOPAUSE 0x1000000
  56. #define phPREVOICE 0x2000000 // for voiced stops
  57. #define phFLAG1 0x10000000
  58. #define phFLAG2 0x20000000
  59. #define phFLAG3 0x40000000
  60. #define phLOCAL 0x80000000 // used during compilation
  61. // fixed phoneme code numbers, these can be used from the program code
  62. #define phonCONTROL 1
  63. #define phonSTRESS_U 2
  64. #define phonSTRESS_D 3
  65. #define phonSTRESS_2 4
  66. #define phonSTRESS_3 5
  67. #define phonSTRESS_P 6
  68. #define phonSTRESS_P2 7 // priority stress within a word
  69. #define phonSTRESS_PREV 8
  70. #define phonPAUSE 9
  71. #define phonPAUSE_SHORT 10
  72. #define phonPAUSE_NOLINK 11
  73. #define phonLENGTHEN 12
  74. #define phonSCHWA 13
  75. #define phonSCHWA_SHORT 14
  76. #define phonEND_WORD 15
  77. #define phonDEFAULTTONE 17
  78. #define phonCAPITAL 18
  79. #define phonGLOTTALSTOP 19
  80. #define phonSYLLABIC 20
  81. #define phonSWITCH 21
  82. #define phonX1 22 // a language specific action
  83. #define phonPAUSE_VSHORT 23
  84. #define phonPAUSE_LONG 24
  85. #define phonT_REDUCED 25
  86. #define phonSTRESS_TONIC 26
  87. #define phonPAUSE_CLAUSE 27
  88. #define phonVOWELTYPES 28 // 28 to 33
  89. extern const unsigned char pause_phonemes[8]; // 0, vshort, short, pause, long, glottalstop
  90. // place of articulation
  91. #define phPLACE 0xf0000
  92. #define phPLACE_blb 0x10000
  93. #define phPLACE_pla 0x60000
  94. #define N_PHONEME_TABS 150 // number of phoneme tables
  95. #define N_PHONEME_TAB 256 // max phonemes in a phoneme table
  96. #define N_PHONEME_TAB_NAME 32 // must be multiple of 4
  97. // main table of phonemes, index by phoneme number (1-254)
  98. typedef struct {
  99. unsigned int mnemonic; // Up to 4 characters. The first char is in the l.s.byte
  100. unsigned int phflags; // bits 16-19 place of articulation
  101. unsigned short program; // index into phondata file
  102. unsigned char code; // the phoneme number
  103. unsigned char type; // phVOWEL, phPAUSE, phSTOP etc
  104. unsigned char start_type;
  105. unsigned char end_type;
  106. unsigned char std_length; // for vowels, in mS/2; for phSTRESS phonemes, this is the stress/tone type
  107. unsigned char length_mod; // a length_mod group number, used to access length_mod_tab
  108. } PHONEME_TAB;
  109. // Several phoneme tables may be loaded into memory. phoneme_tab points to
  110. // one for the current voice
  111. extern int n_phoneme_tab;
  112. extern int current_phoneme_table;
  113. extern PHONEME_TAB *phoneme_tab[N_PHONEME_TAB];
  114. extern unsigned char phoneme_tab_flags[N_PHONEME_TAB]; // bit 0: not inherited
  115. typedef struct {
  116. char name[N_PHONEME_TAB_NAME];
  117. PHONEME_TAB *phoneme_tab_ptr;
  118. int n_phonemes;
  119. int includes; // also include the phonemes from this other phoneme table
  120. int equivalence_tables; // lists of equivalent phonemes to match other languages, byte index into phondata
  121. } PHONEME_TAB_LIST;
  122. // table of phonemes to be replaced with different phonemes, for the current voice
  123. #define N_REPLACE_PHONEMES 60
  124. typedef struct {
  125. unsigned char old_ph;
  126. unsigned char new_ph;
  127. char type; // 0=always replace, 1=only at end of word
  128. } REPLACE_PHONEMES;
  129. extern int n_replace_phonemes;
  130. extern REPLACE_PHONEMES replace_phonemes[N_REPLACE_PHONEMES];
  131. // Table of phoneme programs and lengths. Used by MakeVowelLists
  132. typedef struct {
  133. unsigned int addr;
  134. unsigned int length;
  135. } PHONEME_PROG_LOG;
  136. #define PH(c1, c2) (c2<<8)+c1 // combine two characters into an integer for phoneme name
  137. #define PH3(c1, c2, c3) (c3<<16)+(c2<<8)+c1
  138. #define PhonemeCode2(c1, c2) PhonemeCode((c2<<8)+c1)
  139. int LookupPhonemeString(const char *string);
  140. int PhonemeCode(unsigned int mnem);
  141. const char *EncodePhonemes(const char *p, char *outptr, int *bad_phoneme);
  142. void DecodePhonemes(const char *inptr, char *outptr);
  143. extern const char *WordToString(unsigned int word);
  144. extern PHONEME_TAB_LIST phoneme_tab_list[N_PHONEME_TABS];
  145. extern int phoneme_tab_number;
  146. #ifdef __cplusplus
  147. }
  148. #endif