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

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