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 6.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. /***************************************************************************
  2. * Copyright (C) 2005 to 2010 by Jonathan Duddington *
  3. * email: [email protected] *
  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
  34. #define phARTICULATION 0xf0000
  35. #define phWAVE 0x01
  36. #define phUNSTRESSED 0x02
  37. #define phFORTIS 0x08
  38. #define phVOICED 0x10
  39. #define phSIBILANT 0x20
  40. #define phNOLINK 0x40
  41. #define phTRILL 0x80
  42. #define phVOWEL2 0x100 // liquid that is considered a vowel
  43. #define phPALATAL 0x200
  44. #define phSINGLE_INSTN 0x1000 // this phoneme has a single instruction program, with an implicit Return
  45. #define phAPPENDPH 0x2000 // always insert another phoneme (link_out) after this one
  46. #define phBRKAFTER 0x4000 // [*] add a post-pause
  47. #define phBEFOREPAUSE 0x8000 // replace with the link_out phoneme if the next phoneme is a pause
  48. #define phNONSYLLABIC 0x100000 // don't count this vowel as a syllable when finding the stress position
  49. #define phLONG 0x200000
  50. #define phLENGTHENSTOP 0x400000 // make the pre-pause slightly longer
  51. #define phRHOTIC 0x800000 // bit 23
  52. #define phNOPAUSE 0x1000000
  53. #define phPREVOICE 0x2000000 // for voiced stops
  54. #define phFLAG1 0x10000000
  55. #define phFLAG2 0x20000000
  56. #define phFLAG3 0x40000000
  57. #define phLOCAL 0x80000000 // used during compilation
  58. // fixed phoneme code numbers, these can be used from the program code
  59. #define phonCONTROL 1
  60. #define phonSTRESS_U 2
  61. #define phonSTRESS_D 3
  62. #define phonSTRESS_2 4
  63. #define phonSTRESS_3 5
  64. #define phonSTRESS_P 6
  65. #define phonSTRESS_P2 7 // priority stress within a word
  66. #define phonSTRESS_PREV 8
  67. #define phonPAUSE 9
  68. #define phonPAUSE_SHORT 10
  69. #define phonPAUSE_NOLINK 11
  70. #define phonLENGTHEN 12
  71. #define phonSCHWA 13
  72. #define phonSCHWA_SHORT 14
  73. #define phonEND_WORD 15
  74. #define phonDEFAULTTONE 17
  75. #define phonCAPITAL 18
  76. #define phonGLOTTALSTOP 19
  77. #define phonSYLLABIC 20
  78. #define phonSWITCH 21
  79. #define phonX1 22 // a language specific action
  80. #define phonPAUSE_VSHORT 23
  81. #define phonPAUSE_LONG 24
  82. #define phonT_REDUCED 25
  83. #define phonSTRESS_TONIC 26
  84. #define phonPAUSE_CLAUSE 27
  85. #define phonVOWELTYPES 28 // 28 to 33
  86. extern const unsigned char pause_phonemes[8]; // 0, vshort, short, pause, long, glottalstop
  87. // place of articulation
  88. #define phPLACE 0xf0000
  89. #define phPLACE_blb 0x10000
  90. #define phPLACE_pla 0x60000
  91. #define N_PHONEME_TABS 100 // number of phoneme tables
  92. #define N_PHONEME_TAB 256 // max phonemes in a phoneme table
  93. #define N_PHONEME_TAB_NAME 32 // must be multiple of 4
  94. // main table of phonemes, index by phoneme number (1-254)
  95. typedef struct {
  96. unsigned int mnemonic; // 1st char is in the l.s.byte
  97. unsigned int phflags; // bits 16-19 place of articulation
  98. unsigned short program;
  99. unsigned char code; // the phoneme number
  100. unsigned char type; // phVOWEL, phPAUSE, phSTOP etc
  101. unsigned char start_type;
  102. unsigned char end_type;
  103. unsigned char std_length; // for vowels, in mS/2; for phSTRESS, the stress/tone type
  104. unsigned char length_mod; // a length_mod group number, used to access length_mod_tab
  105. } PHONEME_TAB;
  106. // Several phoneme tables may be loaded into memory. phoneme_tab points to
  107. // one for the current voice
  108. extern int n_phoneme_tab;
  109. extern int current_phoneme_table;
  110. extern PHONEME_TAB *phoneme_tab[N_PHONEME_TAB];
  111. extern unsigned char phoneme_tab_flags[N_PHONEME_TAB]; // bit 0: not inherited
  112. typedef struct {
  113. char name[N_PHONEME_TAB_NAME];
  114. PHONEME_TAB *phoneme_tab_ptr;
  115. int n_phonemes;
  116. int includes; // also include the phonemes from this other phoneme table
  117. int equivalence_tables; // lists of equivalent phonemes to match other languages, byte index into phondata
  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. // Table of phoneme programs and lengths. Used by MakeVowelLists
  129. typedef struct {
  130. unsigned int addr;
  131. unsigned int length;
  132. } PHONEME_PROG_LOG;
  133. #define PH(c1,c2) (c2<<8)+c1 // combine two characters into an integer for phoneme name
  134. #define PH3(c1,c2,c3) (c3<<16)+(c2<<8)+c1
  135. #define PhonemeCode2(c1,c2) PhonemeCode((c2<<8)+c1)
  136. int LookupPhonemeString(const char *string);
  137. int PhonemeCode(unsigned int mnem);
  138. char *EncodePhonemes(char *p, char *outptr, unsigned char *bad_phoneme);
  139. void DecodePhonemes(const char *inptr, char *outptr);
  140. extern const char *WordToString(unsigned int word);
  141. extern PHONEME_TAB_LIST phoneme_tab_list[N_PHONEME_TABS];
  142. extern int phoneme_tab_number;