| 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 ([email protected]) */ |
| 34 | /* Date: December 2000 */ |
| 35 | /*************************************************************************/ |
| 36 | /* */ |
| 37 | /* A simple voice defintion */ |
| 38 | /* */ |
| 39 | /*************************************************************************/ |
| 40 | |
| 41 | /* ----------------------------------------------------------------- */ |
| 42 | /* The English TTS System "Flite+hts_engine" */ |
| 43 | /* developed by HTS Working Group */ |
| 44 | /* http://hts-engine.sourceforge.net/ */ |
| 45 | /* ----------------------------------------------------------------- */ |
| 46 | /* */ |
| 47 | /* Copyright (c) 2005-2013 Nagoya Institute of Technology */ |
| 48 | /* Department of Computer Science */ |
| 49 | /* */ |
| 50 | /* 2005-2008 Tokyo Institute of Technology */ |
| 51 | /* Interdisciplinary Graduate School of */ |
| 52 | /* Science and Engineering */ |
| 53 | /* */ |
| 54 | /* All rights reserved. */ |
| 55 | /* */ |
| 56 | /* Redistribution and use in source and binary forms, with or */ |
| 57 | /* without modification, are permitted provided that the following */ |
| 58 | /* conditions are met: */ |
| 59 | /* */ |
| 60 | /* - Redistributions of source code must retain the above copyright */ |
| 61 | /* notice, this list of conditions and the following disclaimer. */ |
| 62 | /* - Redistributions in binary form must reproduce the above */ |
| 63 | /* copyright notice, this list of conditions and the following */ |
| 64 | /* disclaimer in the documentation and/or other materials provided */ |
| 65 | /* with the distribution. */ |
| 66 | /* - Neither the name of the HTS working group nor the names of its */ |
| 67 | /* contributors may be used to endorse or promote products derived */ |
| 68 | /* from this software without specific prior written permission. */ |
| 69 | /* */ |
| 70 | /* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND */ |
| 71 | /* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, */ |
| 72 | /* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF */ |
| 73 | /* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE */ |
| 74 | /* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS */ |
| 75 | /* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, */ |
| 76 | /* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED */ |
| 77 | /* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, */ |
| 78 | /* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON */ |
| 79 | /* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, */ |
| 80 | /* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY */ |
| 81 | /* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */ |
| 82 | /* POSSIBILITY OF SUCH DAMAGE. */ |
| 83 | /* ----------------------------------------------------------------- */ |
| 84 | |
| 85 | #include "flite.h" |
| 86 | #ifndef FLITE_PLUS_HTS_ENGINE |
| 87 | #include "cst_diphone.h" |
| 88 | #endif /* !FLITE_PLUS_HTS_ENGINE */ |
| 89 | #include "usenglish.h" |
| 90 | #include "cmu_lex.h" |
| 91 | |
| 92 | static cst_utterance *cmu_us_kal_postlex(cst_utterance *u); |
| 93 | #ifndef FLITE_PLUS_HTS_ENGINE |
| 94 | extern cst_diphone_db cmu_us_kal_db; |
| 95 | #endif /* !FLITE_PLUS_HTS_ENGINE */ |
| 96 | |
| 97 | cst_voice *cmu_us_kal_diphone = NULL; |
| 98 | |
| 99 | cst_voice *register_cmu_us_kal(const char *voxdir) |
| 100 | { |
| 101 | cst_voice *v; |
| 102 | cst_lexicon *lex; |
| 103 | |
| 104 | if (cmu_us_kal_diphone) |
| 105 | return cmu_us_kal_diphone; /* Already registered */ |
| 106 | |
| 107 | v = new_voice(); |
| 108 | v->name = "kal"; |
| 109 | |
| 110 | /* Set up basic values for synthesizing with this voice */ |
| 111 | usenglish_init(v); |
| 112 | #ifndef FLITE_PLUS_HTS_ENGINE |
| 113 | flite_feat_set_string(v->features,"name","cmu_us_kal_diphone"); |
| 114 | #endif /* !FLITE_PLUS_HTS_ENGINE */ |
| 115 | |
| 116 | /* Lexicon */ |
| 117 | lex = cmu_lex_init(); |
| 118 | flite_feat_set(v->features,"lexicon",lexicon_val(lex)); |
| 119 | |
| 120 | #ifndef FLITE_PLUS_HTS_ENGINE |
| 121 | /* Intonation */ |
| 122 | flite_feat_set_float(v->features,"int_f0_target_mean",95.0); |
| 123 | flite_feat_set_float(v->features,"int_f0_target_stddev",11.0); |
| 124 | |
| 125 | flite_feat_set_float(v->features,"duration_stretch",1.1); |
| 126 | #endif /* !FLITE_PLUS_HTS_ENGINE */ |
| 127 | |
| 128 | /* Post lexical rules */ |
| 129 | flite_feat_set(v->features,"postlex_func",uttfunc_val(&cmu_us_kal_postlex)); |
| 130 | |
| 131 | #ifndef FLITE_PLUS_HTS_ENGINE |
| 132 | /* Waveform synthesis: diphone_synth */ |
| 133 | flite_feat_set(v->features,"wave_synth_func",uttfunc_val(&diphone_synth)); |
| 134 | flite_feat_set(v->features,"diphone_db",diphone_db_val(&cmu_us_kal_db)); |
| 135 | flite_feat_set_int(v->features,"sample_rate",cmu_us_kal_db.sts->sample_rate); |
| 136 | flite_feat_set_string(v->features,"resynth_type","fixed"); |
| 137 | flite_feat_set_string(v->features,"join_type","modified_lpc"); |
| 138 | #endif /* !FLITE_PLUS_HTS_ENGINE */ |
| 139 | |
| 140 | cmu_us_kal_diphone = v; |
| 141 | |
| 142 | return cmu_us_kal_diphone; |
| 143 | } |
| 144 | |
| 145 | void unregister_cmu_us_kal(cst_voice *v) |
| 146 | { |
| 147 | if (v != cmu_us_kal_diphone) |
| 148 | return; |
| 149 | delete_voice(v); |
| 150 | cmu_us_kal_diphone = NULL; |
| 151 | } |
| 152 | |
| 153 | #ifndef FLITE_PLUS_HTS_ENGINE |
| 154 | static void fix_ah(cst_utterance *u) |
| 155 | { |
| 156 | /* This should really be done in the index itself */ |
| 157 | const cst_item *s; |
| 158 | |
| 159 | for (s=relation_head(utt_relation(u,"Segment")); s; s=item_next(s)) |
| 160 | if (cst_streq(item_feat_string(s,"name"),"ah")) |
| 161 | item_set_string(s,"name","aa"); |
| 162 | } |
| 163 | #endif /* !FLITE_PLUS_HTS_ENGINE */ |
| 164 | |
| 165 | static cst_utterance *cmu_us_kal_postlex(cst_utterance *u) |
| 166 | { |
| 167 | cmu_postlex(u); |
| 168 | #ifndef FLITE_PLUS_HTS_ENGINE |
| 169 | fix_ah(u); |
| 170 | #endif /* !FLITE_PLUS_HTS_ENGINE */ |
| 171 | |
| 172 | return u; |
| 173 | } |