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

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