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.

voice.h 5.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. /*
  2. * Copyright (C) 2005 to 2007 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. #ifndef ESPEAK_NG_VOICE_H
  20. #define ESPEAK_NG_VOICE_H
  21. #include <espeak-ng/espeak_ng.h>
  22. #include "mnemonics.h"
  23. #include "translate.h"
  24. #ifdef __cplusplus
  25. extern "C"
  26. {
  27. #endif
  28. #define N_PEAKS 9
  29. typedef struct {
  30. char v_name[40];
  31. char language_name[20];
  32. int phoneme_tab_ix; // phoneme table number
  33. int pitch_base; // Hz<<12
  34. int pitch_range; // standard = 0x1000
  35. int speedf1;
  36. int speedf2;
  37. int speedf3;
  38. int speed_percent; // adjust the WPM speed by this percentage
  39. int flutter;
  40. int roughness;
  41. int echo_delay;
  42. int echo_amp;
  43. int n_harmonic_peaks; // highest formant which is formed from adding harmonics
  44. int peak_shape; // alternative shape for formant peaks (0=standard 1=squarer)
  45. int voicing; // 100% = 64, level of formant-synthesized sound
  46. int formant_factor; // adjust nominal formant frequencies by this because of the voice's pitch (256ths)
  47. int consonant_amp; // amplitude of unvoiced consonants
  48. int consonant_ampv; // amplitude of the noise component of voiced consonants
  49. int samplerate;
  50. int klattv[8];
  51. // parameters used by Wavegen
  52. short freq[N_PEAKS]; // 100% = 256
  53. short height[N_PEAKS]; // 100% = 256
  54. short width[N_PEAKS]; // 100% = 256
  55. short freqadd[N_PEAKS]; // Hz
  56. // copies without temporary adjustments from embedded commands
  57. short freq2[N_PEAKS]; // 100% = 256
  58. short height2[N_PEAKS]; // 100% = 256
  59. int breath[N_PEAKS]; // amount of breath for each formant. breath[0] indicates whether any are set.
  60. int breathw[N_PEAKS]; // width of each breath formant
  61. // This table provides the opportunity for tone control.
  62. // Adjustment of harmonic amplitudes, steps of 8Hz
  63. // value of 128 means no change
  64. #define N_TONE_ADJUST 1000
  65. unsigned char tone_adjust[N_TONE_ADJUST]; // 8Hz steps * 1000 = 8kHz
  66. } voice_t;
  67. extern espeak_VOICE current_voice_selected;
  68. extern voice_t *voice;
  69. extern int tone_points[12];
  70. typedef enum {
  71. V_NAME = 1,
  72. V_LANGUAGE,
  73. V_GENDER,
  74. V_PHONEMES,
  75. V_DICTIONARY,
  76. V_VARIANTS,
  77. V_MAINTAINER,
  78. V_STATUS,
  79. // these affect voice quality, are independent of language
  80. V_FORMANT,
  81. V_PITCH,
  82. V_ECHO,
  83. V_FLUTTER,
  84. V_ROUGHNESS,
  85. V_CLARITY,
  86. V_TONE,
  87. V_VOICING,
  88. V_BREATH,
  89. V_BREATHW,
  90. // these override defaults set by the translator
  91. V_LOWERCASE_SENTENCE,
  92. V_WORDGAP,
  93. V_INTONATION,
  94. V_TUNES,
  95. V_STRESSLENGTH,
  96. V_STRESSAMP,
  97. V_STRESSADD,
  98. V_DICTRULES,
  99. V_STRESSRULE,
  100. V_STRESSOPT,
  101. V_NUMBERS,
  102. V_MBROLA,
  103. V_KLATT,
  104. V_FAST,
  105. V_SPEED,
  106. V_DICTMIN,
  107. // these need a phoneme table to have been specified
  108. V_REPLACE,
  109. V_CONSONANTS
  110. } VOICELANGATTRIBUTES;
  111. static const MNEM_TAB langopts_tab[] = {
  112. { "dictrules", V_DICTRULES },
  113. { "intonation", V_INTONATION },
  114. { "l_dieresis", 0x100+LOPT_DIERESES },
  115. { "l_prefix", 0x100+LOPT_PREFIXES },
  116. { "l_regressive_v", 0x100+LOPT_REGRESSIVE_VOICING },
  117. { "l_unpronouncable", 0x100+LOPT_UNPRONOUNCABLE },
  118. { "l_sonorant_min", 0x100+LOPT_SONORANT_MIN },
  119. { "lowercaseSentence", V_LOWERCASE_SENTENCE },
  120. { "numbers", V_NUMBERS },
  121. { "stressAdd", V_STRESSADD },
  122. { "stressAmp", V_STRESSAMP },
  123. { "stressLength", V_STRESSLENGTH },
  124. { "stressOpt", V_STRESSOPT },
  125. { "stressRule", V_STRESSRULE },
  126. { "tunes", V_TUNES },
  127. { "words", V_WORDGAP },
  128. { "maintainer", V_MAINTAINER },
  129. { "status", V_STATUS },
  130. { NULL, 0 }
  131. };
  132. static const MNEM_TAB keyword_tab[] = {
  133. { "name", V_NAME },
  134. { "language", V_LANGUAGE },
  135. { "gender", V_GENDER },
  136. { "variants", V_VARIANTS },
  137. { "formant", V_FORMANT },
  138. { "pitch", V_PITCH },
  139. { "phonemes", V_PHONEMES },
  140. { "dictionary", V_DICTIONARY },
  141. { "replace", V_REPLACE },
  142. { "echo", V_ECHO },
  143. { "flutter", V_FLUTTER },
  144. { "roughness", V_ROUGHNESS },
  145. { "clarity", V_CLARITY },
  146. { "tone", V_TONE },
  147. { "voicing", V_VOICING },
  148. { "breath", V_BREATH },
  149. { "breathw", V_BREATHW },
  150. { "mbrola", V_MBROLA },
  151. { "consonants", V_CONSONANTS },
  152. { "klatt", V_KLATT },
  153. { "fast_test2", V_FAST },
  154. { "speed", V_SPEED },
  155. { "dict_min", V_DICTMIN },
  156. { "apostrophe", 0x100+LOPT_APOSTROPHE },
  157. { "brackets", 0x100+LOPT_BRACKET_PAUSE },
  158. { "bracketsAnnounced", 0x100+LOPT_BRACKET_PAUSE_ANNOUNCED },
  159. { NULL, 0 }
  160. };
  161. const char *SelectVoice(espeak_VOICE *voice_select, int *found);
  162. espeak_VOICE *SelectVoiceByName(espeak_VOICE **voices, const char *name);
  163. voice_t *LoadVoice(const char *voice_name, int control);
  164. voice_t *LoadVoiceVariant(const char *voice_name, int variant);
  165. espeak_ng_STATUS DoVoiceChange(voice_t *v);
  166. void WavegenSetVoice(voice_t *v);
  167. void ReadNumbers(char *p, int *flags, int maxValue, const MNEM_TAB *keyword_tab, int key);
  168. int Read8Numbers(char *data_in, int data[8]);
  169. void ReadTonePoints(char *string, int *tone_pts);
  170. void VoiceReset(int control);
  171. void FreeVoiceList(void);
  172. #ifdef __cplusplus
  173. }
  174. #endif
  175. #endif