VOICE_cg.c 4.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /*************************************************************************/
  2. /* */
  3. /* Language Technologies Institute */
  4. /* Carnegie Mellon University */
  5. /* Copyright (c) 1999-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. /* A clustergen voice defintion */
  38. /* */
  39. /*************************************************************************/
  40. #include <string.h>
  41. #include "flite.h"
  42. #include "cst_cg.h"
  43. #include "__FLITELANG__.h"
  44. #include "__FLITELEX__.h"
  45. extern cst_cg_db __VOICENAME___cg_db;
  46. cst_voice *__VOICENAME___cg = NULL;
  47. cst_voice *register___VOICENAME__(const char *voxdir)
  48. {
  49. cst_voice *vox;
  50. cst_lexicon *lex;
  51. if (__VOICENAME___cg)
  52. return __VOICENAME___cg; /* Already registered */
  53. vox = new_voice();
  54. vox->name = "__NICKNAME__";
  55. /* Sets up language specific parameters in the __VOICENAME__. */
  56. __FLITELANG___init(vox);
  57. /* Things that weren't filled in already. */
  58. flite_feat_set_string(vox->features,"name","__VOICENAME__");
  59. /* Lexicon */
  60. lex = __FLITELEX___init();
  61. flite_feat_set(vox->features,"lexicon",lexicon_val(lex));
  62. flite_feat_set(vox->features,"postlex_func",uttfunc_val(lex->postlex));
  63. /* No standard segment durations are needed as its done at the */
  64. /* HMM state level */
  65. flite_feat_set_string(vox->features,"no_segment_duration_model","1");
  66. flite_feat_set_string(vox->features,"no_f0_target_model","1");
  67. /* Waveform synthesis */
  68. flite_feat_set(vox->features,"wave_synth_func",uttfunc_val(&cg_synth));
  69. flite_feat_set(vox->features,"cg_db",cg_db_val(&__VOICENAME___cg_db));
  70. flite_feat_set_int(vox->features,"sample_rate",__VOICENAME___cg_db.sample_rate);
  71. __VOICENAME___cg = vox;
  72. return __VOICENAME___cg;
  73. }
  74. void unregister___VOICENAME__(cst_voice *vox)
  75. {
  76. if (vox != __VOICENAME___cg)
  77. return;
  78. delete_voice(vox);
  79. __VOICENAME___cg = NULL;
  80. }