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 2.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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 T_AMPLITUDE 308
  32. #define T_AV 312
  33. #define T_FNZ 321
  34. #define FILEID1_SPECTSEQ 0x43455053
  35. #define FILEID2_SPECTSEQ 0x51455354 // for eSpeak sequence
  36. #define FILEID2_SPECTSEK 0x4b455354 // for Klatt sequence
  37. #define FILEID2_SPECTSQ2 0x32515354 // with Klatt data
  38. typedef struct {
  39. unsigned short pitch1;
  40. unsigned short pitch2;
  41. unsigned char env[128];
  42. } PitchEnvelope;
  43. typedef struct {
  44. short freq;
  45. short bandw;
  46. } formant_t;
  47. typedef struct {
  48. short pkfreq;
  49. short pkheight;
  50. short pkwidth;
  51. short pkright;
  52. short klt_bw;
  53. short klt_ap;
  54. short klt_bp;
  55. } peak_t;
  56. typedef struct {
  57. int keyframe;
  58. short amp_adjust;
  59. float length_adjust;
  60. double rms;
  61. float time;
  62. float pitch;
  63. float length;
  64. float dx;
  65. unsigned short nx;
  66. short markers;
  67. int max_y;
  68. unsigned short *spect; // sqrt of harmonic amplitudes, 1-nx at 'pitch'
  69. short klatt_param[N_KLATTP2];
  70. formant_t formants[N_PEAKS]; // this is just the estimate given by Praat
  71. peak_t peaks[N_PEAKS];
  72. } SpectFrame;
  73. double GetFrameRms(SpectFrame *frame, int amp);
  74. typedef struct {
  75. int numframes;
  76. short amplitude;
  77. int spare;
  78. char *name;
  79. SpectFrame **frames;
  80. PitchEnvelope pitchenv;
  81. int pitch1;
  82. int pitch2;
  83. int duration;
  84. int grid;
  85. int bass_reduction;
  86. int max_x;
  87. short max_y;
  88. int file_format;
  89. } SpectSeq;
  90. SpectSeq *SpectSeqCreate(void);
  91. void SpectSeqDestroy(SpectSeq *spect);
  92. espeak_ng_STATUS LoadSpectSeq(SpectSeq *spect, const char *filename);
  93. #ifdef __cplusplus
  94. }
  95. #endif
  96. #endif