| 1 |
/*************************************************************************/ |
| 2 |
/* */ |
| 3 |
/* Language Technologies Institute */ |
| 4 |
/* Carnegie Mellon University */ |
| 5 |
/* Copyright (c) 2007-2017 */ |
| 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 2007 */ |
| 35 |
/*************************************************************************/ |
| 36 |
/* */ |
| 37 |
/* clustergen db */ |
| 38 |
/* */ |
| 39 |
/* A statistical corpus based synthesizer. */ |
| 40 |
/* See Black, A. (2006), CLUSTERGEN: A Statistical Parametric */ |
| 41 |
/* Synthesizer using Trajectory Modeling", Interspeech 2006 - ICSLP, */ |
| 42 |
/* Pittsburgh, PA. */ |
| 43 |
/* http://www.cs.cmu.edu/~awb/papers/is2006/IS061394.PDF */ |
| 44 |
/* */ |
| 45 |
/*************************************************************************/ |
| 46 |
#ifndef _CST_CG_H__ |
| 47 |
#define _CST_CG_H__ |
| 48 |
|
| 49 |
#include "cst_cart.h" |
| 50 |
#include "cst_track.h" |
| 51 |
#include "cst_wave.h" |
| 52 |
#include "cst_audio.h" |
| 53 |
#include "cst_synth.h" /* for dur_stat */ |
| 54 |
#include "cst_phoneset.h" |
| 55 |
|
| 56 |
/* The parameters in the spectral model(s) may be encoded in various ways */ |
| 57 |
/* mostly to preserve space. The decoder can be dependent on the shape type */ |
| 58 |
/* This needs to be coordinated with the model creation in make_cg.scm */ |
| 59 |
/* This is currently very BIG_HAMMER-like and hard coded */ |
| 60 |
|
| 61 |
/* Original rf3 (and before) encoding stddev follows mean in pairs: |
| 62 |
F0 (1), MCEP_STATIC (25), MCEP_DELTA (25), ME (5), Voicing (1) (114 shorts) |
| 63 |
Encoded as linear range in unsigned short from min over range */ |
| 64 |
#define CST_CG_MODEL_SHAPE_BASE_MINRANGE 1 |
| 65 |
/* Quantized rf3, encode everything as two 8 bit values in each short. |
| 66 |
Good generic quantized version, but the next one is used for most models |
| 67 |
(57 shorts) |
| 68 |
*/ |
| 69 |
#define CST_CG_MODEL_SHAPE_QUANTIZED_PARAMS 2 |
| 70 |
/* Quantized rf3, (mostly stddev follows mean in pairs -- except deltas |
| 71 |
no F0, MCEP_STATIC (50) MCEP_DELTAS stddev (25), ME (5), Voice (2) |
| 72 |
Encoded as unsigned chars that index into qtable. we don't include |
| 73 |
the mcep_deltas means, they aren't needed. They are still held as shorts |
| 74 |
so you need to sub index them see cst_cg_quantized_params_index() |
| 75 |
(41 shorts) */ |
| 76 |
#define CST_CG_MODEL_SHAPE_QUANTIZED_PARAMS_41 3 |
| 77 |
|
| 78 |
typedef struct cst_cg_db_struct { |
| 79 |
/* Please do not change this structure, but if you do, only add things |
| 80 |
to the end of the struct. If do you change it , please modify |
| 81 |
dump/load voice too (in cst_cg_dump_voice and cst_cg_map) */ |
| 82 |
const char *name; |
| 83 |
const char * const *types; |
| 84 |
int num_types; |
| 85 |
|
| 86 |
int sample_rate; |
| 87 |
|
| 88 |
float f0_mean, f0_stddev; |
| 89 |
|
| 90 |
/* Cluster trees */ |
| 91 |
int num_f0_models; |
| 92 |
const cst_cart ***f0_trees; |
| 93 |
|
| 94 |
int num_param_models; |
| 95 |
const cst_cart *** param_trees; |
| 96 |
|
| 97 |
const cst_cart *spamf0_accent_tree; /* spam accent tree */ |
| 98 |
const cst_cart *spamf0_phrase_tree; /* spam phrase tree */ |
| 99 |
|
| 100 |
/* Model params e.g. mceps, deltas intersliced with stddevs */ |
| 101 |
/* may be compressed/quantized based on value of model_shape */ |
| 102 |
int *num_channels; |
| 103 |
int *num_frames; |
| 104 |
const unsigned short *** model_vectors; |
| 105 |
|
| 106 |
int num_channels_spamf0_accent; |
| 107 |
int num_frames_spamf0_accent; |
| 108 |
const float * const * spamf0_accent_vectors; |
| 109 |
|
| 110 |
/* Currently shared between different models */ |
| 111 |
const float *model_min; /* for vector coeffs encoding */ |
| 112 |
const float *model_range; /* for vector coeffs encoding */ |
| 113 |
|
| 114 |
const float ***qtable; /* q(uantization) tables for each model */ |
| 115 |
|
| 116 |
int model_shape; /* model compression technique */ |
| 117 |
|
| 118 |
float frame_advance; |
| 119 |
|
| 120 |
/* duration models (cart + phonedurs) */ |
| 121 |
int num_dur_models; |
| 122 |
const dur_stat *** dur_stats; |
| 123 |
const cst_cart ** dur_cart; |
| 124 |
|
| 125 |
/* phone to states map */ |
| 126 |
const char * const * const *phone_states; |
| 127 |
|
| 128 |
/* Other parameters */ |
| 129 |
int do_mlpg; /* implies deltas are in the model_vectors */ |
| 130 |
float *dynwin; |
| 131 |
int dynwinsize; |
| 132 |
|
| 133 |
float mlsa_alpha; |
| 134 |
float mlsa_beta; |
| 135 |
|
| 136 |
int multimodel; |
| 137 |
int mixed_excitation; |
| 138 |
|
| 139 |
/* filters for Mixed Excitation */ |
| 140 |
int ME_num; |
| 141 |
int ME_order; |
| 142 |
const double * const *me_h; |
| 143 |
|
| 144 |
int spamf0; |
| 145 |
float gain; |
| 146 |
|
| 147 |
/* If its a "grapheme" voice there will be a phoneset and a char_map */ |
| 148 |
const cst_phoneset *phoneset; |
| 149 |
const char * const *char_sym_map; /* Unicode char to symbol map */ |
| 150 |
const char * const *sym_phone_map; /* symbol to phone map */ |
| 151 |
|
| 152 |
int freeable; /* doesn't get dumped, but 1 when this a freeable struct */ |
| 153 |
|
| 154 |
} cst_cg_db; |
| 155 |
|
| 156 |
CST_VAL_USER_TYPE_DCLS(cg_db,cst_cg_db) |
| 157 |
void delete_cg_db(cst_cg_db *db); |
| 158 |
|
| 159 |
cst_utterance *cg_synth(cst_utterance *utt); |
| 160 |
cst_wave *mlsa_resynthesis(const cst_track *t, |
| 161 |
const cst_track *str, |
| 162 |
cst_cg_db *cg_db, |
| 163 |
cst_audio_streaming_info *asc, |
| 164 |
int mlsa_speech_param); |
| 165 |
cst_track *mlpg(const cst_track *param_track, cst_cg_db *cg_db); |
| 166 |
|
| 167 |
cst_voice *cst_cg_load_voice(const char *voxdir, |
| 168 |
const cst_lang lang_table[]); |
| 169 |
int cst_cg_dump_voice(const cst_voice *v,const cst_string *filename); |
| 170 |
|
| 171 |
#endif |