cst_cg.h 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. /*************************************************************************/
  2. /* */
  3. /* Language Technologies Institute */
  4. /* Carnegie Mellon University */
  5. /* Copyright (c) 2007 */
  6. /* All Rights Reserved. */
  7. /* */
  8. /* Permission is hereby granted, free of charge, to use and distribute */
  9. /* this software and its documentation without restriction, including */
  10. /* without limitation the rights to use, copy, modify, merge, publish, */
  11. /* distribute, sublicense, and/or sell copies of this work, and to */
  12. /* permit persons to whom this work is furnished to do so, subject to */
  13. /* the following conditions: */
  14. /* 1. The code must retain the above copyright notice, this list of */
  15. /* conditions and the following disclaimer. */
  16. /* 2. Any modifications must be clearly marked as such. */
  17. /* 3. Original authors' names are not deleted. */
  18. /* 4. The authors' names are not used to endorse or promote products */
  19. /* derived from this software without specific prior written */
  20. /* permission. */
  21. /* */
  22. /* CARNEGIE MELLON UNIVERSITY AND THE CONTRIBUTORS TO THIS WORK */
  23. /* DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING */
  24. /* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT */
  25. /* SHALL CARNEGIE MELLON UNIVERSITY NOR THE CONTRIBUTORS BE LIABLE */
  26. /* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES */
  27. /* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN */
  28. /* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, */
  29. /* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF */
  30. /* THIS SOFTWARE. */
  31. /* */
  32. /*************************************************************************/
  33. /* Author: Alan W Black (awb@cs.cmu.edu) */
  34. /* Date: November 2007 */
  35. /*************************************************************************/
  36. /* */
  37. /* clustergen db */
  38. /* */
  39. /* A statistical corpus based synthesizer. */
  40. /* See Black, A. (2006), CLUSTERGEN: A Statistical Parametric */
  41. /* Synthesizer using Trajectory Modeling", Interspeech 2006 - ICSLP, */
  42. /* Pittsburgh, PA. */
  43. /* http://www.cs.cmu.edu/~awb/papers/is2006/IS061394.PDF */
  44. /* */
  45. /*************************************************************************/
  46. #ifndef _CST_CG_H__
  47. #define _CST_CG_H__
  48. #include "cst_cart.h"
  49. #include "cst_track.h"
  50. #include "cst_wave.h"
  51. #include "cst_audio.h"
  52. #include "cst_synth.h" /* for dur_stat */
  53. typedef struct cst_cg_db_struct {
  54. /* Please do not change this structure, but if you do only add things
  55. to the end of the struct. If you change please modify dump/load
  56. voice too (in cst_cg_dump_voice and cst_cg_map) */
  57. const char *name;
  58. const char * const *types;
  59. int num_types;
  60. int sample_rate;
  61. float f0_mean, f0_stddev;
  62. /* Cluster trees */
  63. const cst_cart * const *f0_trees;
  64. int num_param_models;
  65. const cst_cart *** param_trees;
  66. const cst_cart *spamf0_accent_tree; /* spam accent tree */
  67. const cst_cart *spamf0_phrase_tree; /* spam phrase tree */
  68. /* Model params e.g. mceps, deltas intersliced with stddevs */
  69. int *num_channels;
  70. int *num_frames;
  71. const unsigned short *** model_vectors;
  72. int num_channels_spamf0_accent;
  73. int num_frames_spamf0_accent;
  74. const float * const * spamf0_accent_vectors;
  75. /* Currently shared between different models */
  76. const float *model_min; /* for vector coeffs encoding */
  77. const float *model_range; /* for vector coeffs encoding */
  78. float frame_advance;
  79. /* duration models (cart + phonedurs) */
  80. int num_dur_models;
  81. const dur_stat *** dur_stats;
  82. const cst_cart ** dur_cart;
  83. /* phone to states map */
  84. const char * const * const *phone_states;
  85. /* Other parameters */
  86. int do_mlpg; /* implies deltas are in the model_vectors */
  87. float *dynwin;
  88. int dynwinsize;
  89. float mlsa_alpha;
  90. float mlsa_beta;
  91. int multimodel;
  92. int mixed_excitation;
  93. /* filters for Mixed Excitation */
  94. int ME_num;
  95. int ME_order;
  96. const double * const *me_h;
  97. int spamf0;
  98. float gain;
  99. int freeable; /* doesn't get dumped, but 1 when this a freeable struct */
  100. } cst_cg_db;
  101. /* Access model parameters, unpacking them as required */
  102. #define CG_MODEL_VECTOR(M,N,X,Y) \
  103. (M->model_min[Y]+((float)(M->N[X][Y])/65535.0*M->model_range[Y]))
  104. CST_VAL_USER_TYPE_DCLS(cg_db,cst_cg_db)
  105. void delete_cg_db(cst_cg_db *db);
  106. cst_utterance *cg_synth(cst_utterance *utt);
  107. cst_wave *mlsa_resynthesis(const cst_track *t,
  108. const cst_track *str,
  109. cst_cg_db *cg_db,
  110. cst_audio_streaming_info *asc);
  111. cst_track *mlpg(const cst_track *param_track, cst_cg_db *cg_db);
  112. cst_voice *cst_cg_load_voice(const char *voxdir,
  113. const cst_lang lang_table[]);
  114. int cst_cg_dump_voice(const cst_voice *v,const cst_string *filename);
  115. #endif