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.c 5.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  1. /*
  2. * Copyright (C) 2017 Reece H. Dunn
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 3 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, see: <http://www.gnu.org/licenses/>.
  16. */
  17. #include "config.h"
  18. #include <errno.h>
  19. #include <stdint.h>
  20. #include <string.h>
  21. #include <espeak-ng/espeak_ng.h>
  22. #include <espeak-ng/speak_lib.h>
  23. #include "phoneme.h"
  24. phoneme_feature_t phoneme_feature_from_string(const char *feature)
  25. {
  26. if (!feature || strlen(feature) != 3)
  27. return inv;
  28. return (feature[0] << 16) | (feature[1] << 8) | feature[2];
  29. }
  30. espeak_ng_STATUS
  31. phoneme_add_feature(PHONEME_TAB *phoneme,
  32. phoneme_feature_t feature)
  33. {
  34. if (!phoneme) return EINVAL;
  35. switch (feature)
  36. {
  37. // manner of articulation
  38. case nas:
  39. phoneme->type = phNASAL;
  40. break;
  41. case stp:
  42. case afr: // FIXME: eSpeak treats 'afr' as 'stp'.
  43. phoneme->type = phSTOP;
  44. break;
  45. case frc:
  46. case apr: // FIXME: eSpeak is using this for [h], with 'liquid' used for [l] and [r].
  47. phoneme->type = phFRICATIVE;
  48. break;
  49. case flp: // FIXME: Why is eSpeak using a vstop (vcd + stp) for this?
  50. phoneme->type = phVSTOP;
  51. break;
  52. case trl: // FIXME: 'trill' should be the type; 'liquid' should be a flag (phoneme files specify both).
  53. phoneme->phflags |= phTRILL;
  54. break;
  55. case clk:
  56. case ejc:
  57. case imp:
  58. case lat:
  59. // Not supported by eSpeak.
  60. break;
  61. case vwl:
  62. phoneme->type = phVOWEL;
  63. break;
  64. case sib:
  65. phoneme->phflags |= phSIBILANT;
  66. break;
  67. // place of articulation
  68. case blb:
  69. phoneme->phflags &= ~phARTICULATION;
  70. phoneme->phflags |= phPLACE_BILABIAL << 16;
  71. break;
  72. case lbd:
  73. phoneme->phflags &= ~phARTICULATION;
  74. phoneme->phflags |= phPLACE_LABIODENTAL << 16;
  75. break;
  76. case dnt:
  77. phoneme->phflags &= ~phARTICULATION;
  78. phoneme->phflags |= phPLACE_DENTAL << 16;
  79. break;
  80. case alv:
  81. phoneme->phflags &= ~phARTICULATION;
  82. phoneme->phflags |= phPLACE_ALVEOLAR << 16;
  83. break;
  84. case rfx:
  85. phoneme->phflags &= ~phARTICULATION;
  86. phoneme->phflags |= phPLACE_RETROFLEX << 16;
  87. break;
  88. case pla:
  89. phoneme->phflags &= ~phARTICULATION;
  90. phoneme->phflags |= phPLACE_PALATO_ALVEOLAR << 16;
  91. break;
  92. case pal:
  93. phoneme->phflags &= ~phARTICULATION;
  94. phoneme->phflags |= phPLACE_PALATAL << 16;
  95. phoneme->phflags |= phPALATAL;
  96. break;
  97. case vel:
  98. phoneme->phflags &= ~phARTICULATION;
  99. phoneme->phflags |= phPLACE_VELAR << 16;
  100. break;
  101. case lbv:
  102. phoneme->phflags &= ~phARTICULATION;
  103. phoneme->phflags |= phPLACE_LABIO_VELAR << 16;
  104. break;
  105. case uvl:
  106. phoneme->phflags &= ~phARTICULATION;
  107. phoneme->phflags |= phPLACE_UVULAR << 16;
  108. break;
  109. case phr:
  110. phoneme->phflags &= ~phARTICULATION;
  111. phoneme->phflags |= phPLACE_PHARYNGEAL << 16;
  112. break;
  113. case glt:
  114. phoneme->phflags &= ~phARTICULATION;
  115. phoneme->phflags |= phPLACE_GLOTTAL << 16;
  116. break;
  117. case bld:
  118. phoneme->phflags &= ~phARTICULATION;
  119. phoneme->phflags |= phPLACE_BILABIAL << 16;
  120. break;
  121. case alp: // pla pzd
  122. phoneme->phflags &= ~phARTICULATION;
  123. phoneme->phflags |= phPLACE_PALATO_ALVEOLAR << 16;
  124. phoneme->phflags |= phPALATAL;
  125. break;
  126. // voice
  127. case vcd:
  128. phoneme->phflags |= phVOICED;
  129. break;
  130. case vls:
  131. phoneme->phflags |= phVOICELESS;
  132. break;
  133. // vowel height
  134. case hgh:
  135. case smh:
  136. case umd:
  137. case mid:
  138. case lmd:
  139. case sml:
  140. case low:
  141. // Not supported by eSpeak.
  142. break;
  143. // vowel backness
  144. case fnt:
  145. case cnt:
  146. case bck:
  147. // Not supported by eSpeak.
  148. break;
  149. // rounding
  150. case unr:
  151. case rnd:
  152. // Not supported by eSpeak.
  153. break;
  154. // articulation
  155. case lgl:
  156. case idt:
  157. case apc:
  158. case lmn:
  159. // Not supported by eSpeak.
  160. break;
  161. // air flow
  162. case egs:
  163. case igs:
  164. // Not supported by eSpeak.
  165. break;
  166. // phonation
  167. case brv:
  168. case slv:
  169. case stv:
  170. case crv:
  171. case glc:
  172. // Not supported by eSpeak.
  173. break;
  174. // rounding and labialization
  175. case ptr:
  176. case cmp:
  177. case mrd:
  178. case lrd:
  179. // Not supported by eSpeak.
  180. break;
  181. // syllabicity
  182. case syl:
  183. // Not supported by eSpeak.
  184. break;
  185. case nsy:
  186. phoneme->phflags |= phNONSYLLABIC;
  187. break;
  188. // consonant release
  189. case asp:
  190. case nrs:
  191. case lrs:
  192. case unx:
  193. // Not supported by eSpeak.
  194. break;
  195. // coarticulation
  196. case pzd:
  197. phoneme->phflags |= phPALATAL;
  198. break;
  199. case vzd:
  200. case fzd:
  201. case nzd:
  202. case rzd:
  203. // Not supported by eSpeak.
  204. break;
  205. // tongue root
  206. case atr:
  207. case rtr:
  208. // Not supported by eSpeak.
  209. break;
  210. // fortis and lenis
  211. case fts:
  212. case lns:
  213. // Not supported by eSpeak.
  214. break;
  215. // length
  216. case est:
  217. case hlg:
  218. // Not supported by eSpeak.
  219. break;
  220. case elg: // FIXME: Should be longer than 'lng'.
  221. case lng:
  222. phoneme->phflags |= phLONG;
  223. break;
  224. // invalid phoneme feature
  225. default:
  226. return ENS_UNKNOWN_PHONEME_FEATURE;
  227. }
  228. return ENS_OK;
  229. }