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.

klatt.h 4.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. #ifdef __cplusplus
  2. extern "C"
  3. {
  4. #endif
  5. #define CASCADE_PARALLEL 1 /* Type of synthesis model */
  6. #define ALL_PARALLEL 2
  7. #define IMPULSIVE 1 /* Type of voicing source */
  8. #define NATURAL 2
  9. #define SAMPLED 3
  10. #define SAMPLED2 4
  11. #define PI 3.1415927
  12. /* typedef's that need to be exported */
  13. typedef long flag;
  14. /* Resonator Structure */
  15. typedef struct
  16. {
  17. double a;
  18. double b;
  19. double c;
  20. double p1;
  21. double p2;
  22. double a_inc;
  23. double b_inc;
  24. double c_inc;
  25. } resonator_t, *resonator_ptr;
  26. /* Structure for Klatt Globals */
  27. typedef struct
  28. {
  29. flag synthesis_model; /* cascade-parallel or all-parallel */
  30. flag outsl; /* Output waveform selector */
  31. long samrate; /* Number of output samples per second */
  32. long FLPhz ; /* Frequeny of glottal downsample low-pass filter */
  33. long BLPhz ; /* Bandwidth of glottal downsample low-pass filter */
  34. flag glsource; /* Type of glottal source */
  35. int f0_flutter; /* Percentage of f0 flutter 0-100 */
  36. long nspfr; /* number of samples per frame */
  37. long nper; /* Counter for number of samples in a pitch period */
  38. long ns;
  39. long T0; /* Fundamental period in output samples times 4 */
  40. long nopen; /* Number of samples in open phase of period */
  41. long nmod; /* Position in period to begin noise amp. modul */
  42. long nrand; /* Varible used by random number generator */
  43. double pulse_shape_a; /* Makes waveshape of glottal pulse when open */
  44. double pulse_shape_b; /* Makes waveshape of glottal pulse when open */
  45. double minus_pi_t;
  46. double two_pi_t;
  47. double onemd;
  48. double decay;
  49. double amp_bypas; /* AB converted to linear gain */
  50. double amp_voice; /* AVdb converted to linear gain */
  51. double par_amp_voice; /* AVpdb converted to linear gain */
  52. double amp_aspir; /* AP converted to linear gain */
  53. double amp_frica; /* AF converted to linear gain */
  54. double amp_breth; /* ATURB converted to linear gain */
  55. double amp_gain0; /* G0 converted to linear gain */
  56. int num_samples; /* number of glottal samples */
  57. double sample_factor; /* multiplication factor for glottal samples */
  58. short *natural_samples; /* pointer to an array of glottal samples */
  59. long original_f0; /* original value of f0 not modified by flutter */
  60. int fadeout; // set to 64 to cause fadeout over 64 samples
  61. int scale_wav; // depends on the voicing source
  62. #define N_RSN 20
  63. #define Rnz 0 // nasal zero, anti-resonator
  64. #define R1c 1
  65. #define R2c 2
  66. #define R3c 3
  67. #define R4c 4
  68. #define R5c 5
  69. #define R6c 6
  70. #define R7c 7
  71. #define R8c 8
  72. #define Rnpc 9 // nasal pole
  73. #define Rparallel 10
  74. #define Rnpp 10
  75. #define R1p 11
  76. #define R2p 12
  77. #define R3p 13
  78. #define R4p 14
  79. #define R5p 15
  80. #define R6p 16
  81. #define RGL 17
  82. #define RLP 18
  83. #define Rout 19
  84. resonator_t rsn[N_RSN]; // internal storage for resonators
  85. resonator_t rsn_next[N_RSN];
  86. } klatt_global_t, *klatt_global_ptr;
  87. /* Structure for Klatt Parameters */
  88. #define F_NZ 0 // nasal zero formant
  89. #define F1 1
  90. #define F2 2
  91. #define F3 3
  92. #define F4 4
  93. #define F5 5
  94. #define F6 6
  95. #define F_NP 9 // nasal pole formant
  96. typedef struct
  97. {
  98. int F0hz10; /* Voicing fund freq in Hz */
  99. int AVdb; /* Amp of voicing in dB, 0 to 70 */
  100. int Fhz[10]; // formant Hz, F_NZ to F6 to F_NP
  101. int Bhz[10];
  102. int Ap[10]; /* Amp of parallel formants in dB, 0 to 80 */
  103. int Bphz[10]; /* Parallel formants bw in Hz, 40 to 1000 */
  104. int ASP; /* Amp of aspiration in dB, 0 to 70 */
  105. int Kopen; /* # of samples in open period, 10 to 65 */
  106. int Aturb; /* Breathiness in voicing, 0 to 80 */
  107. int TLTdb; /* Voicing spectral tilt in dB, 0 to 24 */
  108. int AF; /* Amp of frication in dB, 0 to 80 */
  109. int Kskew; /* Skewness of alternate periods, 0 to 40 in sample#/2 */
  110. int AB; /* Amp of bypass fric. in dB, 0 to 80 */
  111. int AVpdb; /* Amp of voicing, par in dB, 0 to 70 */
  112. int Gain0; /* Overall gain, 60 dB is unity, 0 to 60 */
  113. int AVdb_tmp; //copy of AVdb, which is changed within parwave()
  114. int Fhz_next[10]; // Fhz for the next chunk, so we can do interpolation of resonator (a,b,c) parameters
  115. int Bhz_next[10];
  116. } klatt_frame_t, *klatt_frame_ptr;
  117. typedef struct {
  118. int freq; // Hz
  119. int bw; // klatt bandwidth
  120. int ap; // parallel amplitude
  121. int bp; // parallel bandwidth
  122. DOUBLEX freq1; // floating point versions of the above
  123. DOUBLEX bw1;
  124. DOUBLEX ap1;
  125. DOUBLEX bp1;
  126. DOUBLEX freq_inc; // increment by this every 64 samples
  127. DOUBLEX bw_inc;
  128. DOUBLEX ap_inc;
  129. DOUBLEX bp_inc;
  130. } klatt_peaks_t;
  131. #ifdef __cplusplus
  132. }
  133. #endif