cmu_time_awb.c 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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 clunits/ldom voice defintion */
  38. /* */
  39. /*************************************************************************/
  40. #include <string.h>
  41. #include "flite.h"
  42. #include "cst_clunits.h"
  43. #include "usenglish.h"
  44. #include "cmu_lex.h"
  45. int cmu_syl_boundary(const cst_item *i,const cst_val *rest);
  46. static char *cmu_time_awb_unit_name(cst_item *s);
  47. extern cst_clunit_db cmu_time_awb_db;
  48. extern const int cmu_time_awb_lex_entry[];
  49. extern const unsigned char cmu_time_awb_lex_data[];
  50. extern const int cmu_time_awb_num_entries;
  51. extern const int cmu_time_awb_num_bytes;
  52. extern const char * const cmu_time_awb_lex_phone_table[36];
  53. extern const char * const cmu_time_awb_lex_phones_huff_table[];
  54. extern const char * const cmu_time_awb_lex_entries_huff_table[];
  55. cst_lexicon cmu_time_awb_lex;
  56. cst_voice *cmu_time_awb_ldom = NULL;
  57. cst_voice *register_cmu_time_awb(const char *voxdir)
  58. {
  59. cst_voice *v = new_voice();
  60. v->name = "awb_time";
  61. /* Sets up language specific parameters in the voice. */
  62. usenglish_init(v);
  63. /* Things that weren't filled in already. */
  64. flite_feat_set_string(v->features,"name","cmu_time_awb");
  65. /* Lexicon */
  66. cmu_time_awb_lex.name = "cmu_time_awb";
  67. cmu_time_awb_lex.num_entries = cmu_time_awb_num_entries;
  68. cmu_time_awb_lex.num_bytes = cmu_time_awb_num_bytes;
  69. cmu_time_awb_lex.data = (unsigned char*) cmu_time_awb_lex_data;
  70. cmu_time_awb_lex.phone_table = (char**) cmu_time_awb_lex_phone_table;
  71. cmu_time_awb_lex.syl_boundary = cmu_syl_boundary;
  72. cmu_time_awb_lex.lts_rule_set = NULL;
  73. cmu_time_awb_lex.phone_hufftable = cmu_time_awb_lex_phones_huff_table;
  74. cmu_time_awb_lex.entry_hufftable = cmu_time_awb_lex_entries_huff_table;
  75. flite_feat_set(v->features,"lexicon",lexicon_val(&cmu_time_awb_lex));
  76. /* Waveform synthesis */
  77. flite_feat_set(v->features,"wave_synth_func",uttfunc_val(&clunits_synth));
  78. flite_feat_set(v->features,"clunit_db",clunit_db_val(&cmu_time_awb_db));
  79. flite_feat_set_int(v->features,"sample_rate",cmu_time_awb_db.sts->sample_rate);
  80. flite_feat_set_string(v->features,"join_type","simple_join");
  81. flite_feat_set_string(v->features,"resynth_type","fixed");
  82. /* Unit selection */
  83. cmu_time_awb_db.unit_name_func = cmu_time_awb_unit_name;
  84. cmu_time_awb_ldom = v;
  85. return cmu_time_awb_ldom;
  86. }
  87. void unregister_cmu_time_awb(cst_voice *vox)
  88. {
  89. if (vox != cmu_time_awb_ldom)
  90. return;
  91. delete_voice(vox);
  92. cmu_time_awb_ldom = NULL;
  93. }
  94. static char *cmu_time_awb_unit_name(cst_item *s)
  95. {
  96. return clunits_ldom_phone_word(s);
  97. }