VOICE_diphone.c 4.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /*************************************************************************/
  2. /* */
  3. /* Language Technologies Institute */
  4. /* Carnegie Mellon University */
  5. /* Copyright (c) 1999-2000 */
  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: April 2001 */
  35. /*************************************************************************/
  36. /* */
  37. /* A simple diphone voice defintion */
  38. /* */
  39. /*************************************************************************/
  40. #include <string.h>
  41. #include "flite.h"
  42. #include "cst_diphone.h"
  43. #include "usenglish.h"
  44. #include "cmu_lex.h"
  45. extern cst_diphone_db __VOICENAME___db;
  46. cst_voice *__VOICENAME___diphone = NULL;
  47. cst_voice *register___VOICENAME__(const char *voxdir)
  48. {
  49. cst_voice *v;
  50. cst_lexicon *lex;
  51. if (__VOICENAME___diphone)
  52. return __VOICENAME___diphone; /* Already registered */
  53. v = new_voice();
  54. v->name = "__NICKNAME__";
  55. /* Sets up language specific parameters in the __VOICENAME__. */
  56. usenglish_init(v);
  57. feat_set_string(v->features,"name","__VOICENAME__");
  58. feat_set_float(v->features,"int_f0_target_mean",110.0);
  59. feat_set_float(v->features,"int_f0_target_stddev",15.0);
  60. feat_set_float(v->features,"duration_stretch",1.0);
  61. /* Lexicon */
  62. lex = cmu_lex_init();
  63. feat_set(v->features,"lexicon",lexicon_val(lex));
  64. feat_set(v->features,"postlex_func",uttfunc_val(lex->postlex));
  65. /* Waveform synthesis */
  66. feat_set(v->features,"wave_synth_func",uttfunc_val(&diphone_synth));
  67. feat_set(v->features,"diphone_db",diphone_db_val(&__VOICENAME___db));
  68. feat_set_int(v->features,"sample_rate",__VOICENAME___db.sts->sample_rate);
  69. /* feat_set_string(v->features,"join_type","simple_join"); */
  70. feat_set_string(v->features,"join_type","modified_lpc");
  71. feat_set_string(v->features,"resynth_type","fixed");
  72. __VOICENAME___diphone = v;
  73. return __VOICENAME___diphone;
  74. }
  75. void unregister___VOICENAME__(cst_voice *vox)
  76. {
  77. if (vox != __VOICENAME___diphone)
  78. return;
  79. delete_voice(vox);
  80. __VOICENAME___diphone = NULL;
  81. }