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

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