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.

spect.h 3.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. /*
  2. * Copyright (C) 2005 to 2007 by Jonathan Duddington
  3. * email: [email protected]
  4. * Copyright (C) 2013-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. #ifdef __cplusplus
  20. extern "C"
  21. {
  22. #endif
  23. #define FRAME_WIDTH 1000 // max width for 8000kHz frame
  24. #define MAX_DISPLAY_FREQ 9500
  25. #define FRAME_HEIGHT 240
  26. #define T_ZOOMOUT 301
  27. #define T_ZOOMIN 302
  28. #define T_USEPITCHENV 303
  29. #define T_SAMPRATE 304
  30. #define T_PITCH1 305
  31. #define T_PITCH2 306
  32. #define T_DURATION 307
  33. #define T_AMPLITUDE 308
  34. #define T_AMPFRAME 309
  35. #define T_TIMEFRAME 310
  36. #define T_TIMESEQ 311
  37. #define T_AV 312
  38. #define T_AVP 313
  39. #define T_FRIC 314
  40. #define T_FRICBP 315
  41. #define T_ASPR 316
  42. #define T_TURB 317
  43. #define T_SKEW 318
  44. #define T_TILT 319
  45. #define T_KOPEN 320
  46. #define T_FNZ 321
  47. #define FILEID1_SPECTSEQ 0x43455053
  48. #define FILEID2_SPECTSEQ 0x51455354 // for eSpeak sequence
  49. #define FILEID2_SPECTSEK 0x4b455354 // for Klatt sequence
  50. #define FILEID2_SPECTSQ2 0x32515354 // with Klatt data
  51. #define FILEID1_SPC2 0x32435053 // an old format for spectrum files
  52. #define FILEID1_PITCHENV 0x43544950
  53. #define FILEID2_PITCHENV 0x564e4548
  54. #define FILEID1_PRAATSEQ 0x41415250
  55. #define FILEID2_PRAATSEQ 0x51455354
  56. typedef struct {
  57. unsigned short pitch1;
  58. unsigned short pitch2;
  59. unsigned char env[128];
  60. } PitchEnvelope;
  61. typedef struct {
  62. short freq;
  63. short bandw;
  64. } formant_t;
  65. typedef struct {
  66. short pkfreq;
  67. short pkheight;
  68. short pkwidth;
  69. short pkright;
  70. short klt_bw;
  71. short klt_ap;
  72. short klt_bp;
  73. } peak_t;
  74. typedef struct {
  75. int keyframe;
  76. short amp_adjust;
  77. float length_adjust;
  78. double rms;
  79. float time;
  80. float pitch;
  81. float length;
  82. float dx;
  83. unsigned short nx;
  84. short markers;
  85. int max_y;
  86. USHORT *spect; // sqrt of harmonic amplitudes, 1-nx at 'pitch'
  87. short klatt_param[N_KLATTP2];
  88. formant_t formants[N_PEAKS]; // this is just the estimate given by Praat
  89. peak_t peaks[N_PEAKS];
  90. } SpectFrame;
  91. double GetFrameRms(SpectFrame *frame, int amp);
  92. typedef struct {
  93. int numframes;
  94. short amplitude;
  95. int spare;
  96. char *name;
  97. SpectFrame **frames;
  98. PitchEnvelope pitchenv;
  99. int pitch1;
  100. int pitch2;
  101. int duration;
  102. int grid;
  103. int bass_reduction;
  104. int max_x;
  105. short max_y;
  106. int file_format;
  107. } SpectSeq;
  108. SpectSeq *SpectSeqCreate();
  109. void SpectSeqDestroy(SpectSeq *spect);
  110. int LoadSpectSeq(SpectSeq *spect, const char *filename);
  111. #ifdef __cplusplus
  112. }
  113. #endif