flite.h 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. /*************************************************************************/
  2. /* */
  3. /* Language Technologies Institute */
  4. /* Carnegie Mellon University */
  5. /* Copyright (c) 1999 */
  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: December 1999 */
  35. /*************************************************************************/
  36. /* */
  37. /* Light weight run-time speech synthesis system, public API */
  38. /* */
  39. /*************************************************************************/
  40. #ifndef _FLITE_H__
  41. #define _FLITE_H__
  42. #ifdef __cplusplus
  43. extern "C" {
  44. #endif /* __cplusplus */
  45. #include "cst_string.h"
  46. #include "cst_regex.h"
  47. #include "cst_val.h"
  48. #include "cst_features.h"
  49. #include "cst_item.h"
  50. #include "cst_relation.h"
  51. #include "cst_utterance.h"
  52. #include "cst_wave.h"
  53. #include "cst_track.h"
  54. #include "cst_cart.h"
  55. #include "cst_phoneset.h"
  56. #include "cst_voice.h"
  57. #include "cst_audio.h"
  58. #include "cst_utt_utils.h"
  59. #include "cst_lexicon.h"
  60. #include "cst_synth.h"
  61. #include "cst_units.h"
  62. #include "cst_tokenstream.h"
  63. extern cst_val *flite_voice_list;
  64. extern cst_lang flite_lang_list[20];
  65. /* Public functions */
  66. int flite_init();
  67. /* General top level functions */
  68. cst_voice *flite_voice_select(const char *name);
  69. cst_voice *flite_voice_load(const char *voice_filename);
  70. int flite_voice_dump(cst_voice *voice, const char *voice_filename);
  71. float flite_file_to_speech(const char *filename,
  72. cst_voice *voice,
  73. const char *outtype);
  74. float flite_text_to_speech(const char *text,
  75. cst_voice *voice,
  76. const char *outtype);
  77. float flite_phones_to_speech(const char *text,
  78. cst_voice *voice,
  79. const char *outtype);
  80. float flite_ssml_file_to_speech(const char *filename,
  81. cst_voice *voice,
  82. const char *outtype);
  83. float flite_ssml_text_to_speech(const char *text,
  84. cst_voice *voice,
  85. const char *outtype);
  86. int flite_voice_add_lex_addenda(cst_voice *v, const cst_string *lexfile);
  87. /* Lower lever user functions */
  88. cst_wave *flite_text_to_wave(const char *text,cst_voice *voice);
  89. cst_utterance *flite_synth_text(const char *text,cst_voice *voice);
  90. cst_utterance *flite_synth_phones(const char *phones,cst_voice *voice);
  91. float flite_ts_to_speech(cst_tokenstream *ts,
  92. cst_voice *voice,
  93. const char *outtype);
  94. cst_utterance *flite_do_synth(cst_utterance *u,
  95. cst_voice *voice,
  96. cst_uttfunc synth);
  97. float flite_process_output(cst_utterance *u,
  98. const char *outtype,
  99. int append);
  100. /* for voices with external voxdata */
  101. int flite_mmap_clunit_voxdata(const char *voxdir, cst_voice *voice);
  102. int flite_munmap_clunit_voxdata(cst_voice *voice);
  103. /* flite public export wrappers for features access */
  104. int flite_get_param_int(const cst_features *f, const char *name,int def);
  105. float flite_get_param_float(const cst_features *f, const char *name, float def);
  106. const char *flite_get_param_string(const cst_features *f, const char *name, const char *def);
  107. const cst_val *flite_get_param_val(const cst_features *f, const char *name, cst_val *def);
  108. void flite_feat_set_int(cst_features *f, const char *name, int v);
  109. void flite_feat_set_float(cst_features *f, const char *name, float v);
  110. void flite_feat_set_string(cst_features *f, const char *name, const char *v);
  111. void flite_feat_set(cst_features *f, const char *name,const cst_val *v);
  112. int flite_feat_remove(cst_features *f, const char *name);
  113. const char *flite_ffeature_string(const cst_item *item,const char *featpath);
  114. int flite_ffeature_int(const cst_item *item,const char *featpath);
  115. float flite_ffeature_float(const cst_item *item,const char *featpath);
  116. const cst_val *flite_ffeature(const cst_item *item,const char *featpath);
  117. cst_item* flite_path_to_item(const cst_item *item,const char *featpath);
  118. /* These functions are *not* thread-safe, they are designed to be called */
  119. /* before the initial synthesis occurs */
  120. int flite_add_voice(cst_voice *voice);
  121. int flite_add_lang(const char *langname,
  122. void (*lang_init)(cst_voice *vox),
  123. cst_lexicon *(*lex_init)());
  124. /* These are init functions for generic grapheme based voices */
  125. void utf8_grapheme_lang_init(cst_voice *v);
  126. cst_lexicon *utf8_grapheme_lex_init(void);
  127. #ifdef __cplusplus
  128. } /* extern "C" */
  129. #endif /* __cplusplus */
  130. #endif