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.2KB

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