| 1 |
/*************************************************************************/ |
| 2 |
/* */ |
| 3 |
/* Language Technologies Institute */ |
| 4 |
/* Carnegie Mellon University */ |
| 5 |
/* Copyright (c) 1999-2011 */ |
| 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: November 2011 */ |
| 35 |
/*************************************************************************/ |
| 36 |
/* */ |
| 37 |
/* Kal diphone, rebuilt with g721 encoded residuals to save 500K */ |
| 38 |
/* */ |
| 39 |
/*************************************************************************/ |
| 40 |
|
| 41 |
#include "flite.h" |
| 42 |
#include "cst_diphone.h" |
| 43 |
#include "usenglish.h" |
| 44 |
#include "cmu_lex.h" |
| 45 |
|
| 46 |
static cst_utterance *cmu_us_kal_postlex(cst_utterance *u); |
| 47 |
extern cst_diphone_db cmu_us_kal_db; |
| 48 |
|
| 49 |
cst_voice *cmu_us_kal_diphone = NULL; |
| 50 |
|
| 51 |
cst_voice *register_cmu_us_kal(const char *voxdir) |
| 52 |
{ |
| 53 |
cst_voice *v; |
| 54 |
cst_lexicon *lex; |
| 55 |
|
| 56 |
if (cmu_us_kal_diphone) |
| 57 |
return cmu_us_kal_diphone; /* Already registered */ |
| 58 |
|
| 59 |
v = new_voice(); |
| 60 |
v->name = "kal"; |
| 61 |
|
| 62 |
/* Set up basic values for synthesizing with this voice */ |
| 63 |
usenglish_init(v); |
| 64 |
flite_feat_set_string(v->features,"name","cmu_us_kal_diphone"); |
| 65 |
|
| 66 |
/* Lexicon */ |
| 67 |
lex = cmu_lex_init(); |
| 68 |
flite_feat_set(v->features,"lexicon",lexicon_val(lex)); |
| 69 |
|
| 70 |
/* Intonation */ |
| 71 |
flite_feat_set_float(v->features,"int_f0_target_mean",95.0); |
| 72 |
flite_feat_set_float(v->features,"int_f0_target_stddev",11.0); |
| 73 |
|
| 74 |
flite_feat_set_float(v->features,"duration_stretch",1.1); |
| 75 |
|
| 76 |
/* Post lexical rules */ |
| 77 |
flite_feat_set(v->features,"postlex_func",uttfunc_val(&cmu_us_kal_postlex)); |
| 78 |
|
| 79 |
/* Waveform synthesis: diphone_synth */ |
| 80 |
flite_feat_set(v->features,"wave_synth_func",uttfunc_val(&diphone_synth)); |
| 81 |
flite_feat_set(v->features,"diphone_db",diphone_db_val(&cmu_us_kal_db)); |
| 82 |
flite_feat_set_int(v->features,"sample_rate",cmu_us_kal_db.sts->sample_rate); |
| 83 |
flite_feat_set_string(v->features,"resynth_type","fixed"); |
| 84 |
flite_feat_set_string(v->features,"join_type","modified_lpc"); |
| 85 |
|
| 86 |
cmu_us_kal_diphone = v; |
| 87 |
|
| 88 |
return cmu_us_kal_diphone; |
| 89 |
} |
| 90 |
|
| 91 |
void unregister_cmu_us_kal(cst_voice *v) |
| 92 |
{ |
| 93 |
if (v != cmu_us_kal_diphone) |
| 94 |
return; |
| 95 |
delete_voice(v); |
| 96 |
cmu_us_kal_diphone = NULL; |
| 97 |
} |
| 98 |
|
| 99 |
static void fix_ah(cst_utterance *u) |
| 100 |
{ |
| 101 |
/* This should really be done in the index itself */ |
| 102 |
const cst_item *s; |
| 103 |
|
| 104 |
for (s=relation_head(utt_relation(u,"Segment")); s; s=item_next(s)) |
| 105 |
if (cst_streq(item_feat_string(s,"name"),"ah")) |
| 106 |
item_set_string(s,"name","aa"); |
| 107 |
} |
| 108 |
|
| 109 |
static cst_utterance *cmu_us_kal_postlex(cst_utterance *u) |
| 110 |
{ |
| 111 |
cmu_postlex(u); |
| 112 |
fix_ah(u); |
| 113 |
|
| 114 |
return u; |
| 115 |
} |
| 116 |
|