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

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