@@ -1,4 +1,10 @@
/*************************************************************************/
/* This code has been modified for Bellbird. */
/* See COPYING for more copyright details. */
/* The unmodified source code copyright notice */
/* is included below. */
/*************************************************************************/
/*************************************************************************/
/* */
/* Language Technologies Institute */
/* Carnegie Mellon University */
@@ -40,7 +46,7 @@
#ifndef _UTT_UTILS_H__
#define _UTT_UTILS_H__

#include "cst_hrg.h"
#include "cst_utterance.h"
#include "cst_wave.h"

int utt_set_wave(cst_utterance *u, cst_wave *w);
@@ -49,16 +55,14 @@ cst_wave *utt_wave(cst_utterance *u);
const char *utt_input_text(cst_utterance *u);
int utt_set_input_text(cst_utterance *u,const char *text);

#define utt_feat_string(U,F) (feat_string((U)->features,F))
#define utt_feat_int(U,F) (feat_int((U)->features,F))
#define utt_feat_float(U,F) (feat_float((U)->features,F))
#define utt_feat_val(U,F) (feat_val((U)->features,F))
#define UTT_FEAT_STRING(U,F) (feat_string((U)->features,F))
#define UTT_FEAT_INT(U,F) (feat_int((U)->features,F))
#define UTT_FEAT_VAL(U,F) (feat_val((U)->features,F))

#define utt_set_feat_string(U,F,V) (feat_set_string((U)->features,F,V))
#define utt_set_feat_int(U,F,V) (feat_set_int((U)->features,F,V))
#define utt_set_feat_float(U,F,V) (feat_set_float((U)->features,F,V))
#define utt_set_feat(U,F,V) (feat_set((U)->features,F,V))
#define UTT_SET_FEAT_STRING(U,F,V) (feat_set_string((U)->features,F,V))
#define UTT_SET_FEAT_INT(U,F,V) (feat_set_int((U)->features,F,V))
#define UTT_SET_FEAT(U,F,V) (feat_set((U)->features,F,V))

#define utt_rel_head(U,R) (relation_head(utt_relation((U),R)))
#define UTT_REL_HEAD(U,R) (relation_head(utt_relation((U),R)))

#endif
@@ -1,4 +1,10 @@
/*************************************************************************/
/* This code has been modified for Bellbird. */
/* See COPYING for more copyright details. */
/* The unmodified source code copyright notice */
/* is included below. */
/*************************************************************************/
/*************************************************************************/
/* */
/* Language Technologies Institute */
/* Carnegie Mellon University */
@@ -40,18 +46,15 @@
#ifndef _CST_UTTERANCE_H__
#define _CST_UTTERANCE_H__

#include "cst_file.h"
#include "cst_val.h"
#include "cst_features.h"
#include "cst_item.h"
#include "cst_features.h"
#include "cst_relation.h"
#include "cst_alloc.h"
#include "cst_val.h"

struct cst_utterance_struct {
cst_features *features;
cst_features *ffunctions;
cst_ffunction *ffunctions; // Pointer to voice's features functions array
cst_features *relations;
cst_alloc_context ctx;
};

/* Constructor functions */
@@ -60,15 +63,8 @@ void delete_utterance(cst_utterance *u);

cst_relation *utt_relation(const cst_utterance *u,const char *name);
cst_relation *utt_relation_create(cst_utterance *u,const char *name);
int utt_relation_delete(cst_utterance *u,const char *name);
int utt_relation_present(cst_utterance *u,const char *name);

typedef cst_utterance *(*cst_uttfunc)(cst_utterance *i);
CST_VAL_USER_FUNCPTR_DCLS(uttfunc,cst_uttfunc)

/* Allocate memory "locally" to an utterance, on platforms that
support/require this (currently only WinCE) */
#define cst_utt_alloc(UTT,TYPE,SIZE) ((TYPE *)cst_local_alloc((UTT)->ctx,sizeof(TYPE)*(SIZE)))
#define cst_utt_free(UTT,PTR) cst_local_free((UTT)->ctx,(PTR))

#endif
@@ -1,4 +1,10 @@
/*************************************************************************/
/* This code has been modified for Bellbird. */
/* See COPYING for more copyright details. */
/* The unmodified source code copyright notice */
/* is included below. */
/*************************************************************************/
/*************************************************************************/
/* */
/* Language Technologies Institute */
/* Carnegie Mellon University */
@@ -42,8 +48,6 @@

#include "cst_file.h"
#include "cst_string.h"
#include "cst_error.h"
#include "cst_alloc.h"
#include "cst_val_defs.h"

/* Only CONS can be an even number */
@@ -52,7 +56,6 @@
#define CST_VAL_TYPE_FLOAT 3
#define CST_VAL_TYPE_STRING 5
#define CST_VAL_TYPE_FIRST_FREE 7
#define CST_VAL_TYPE_MAX 54

typedef struct cst_val_cons_struct {
struct cst_val_struct *car;
@@ -64,7 +67,7 @@ typedef struct cst_val_atom_struct {
short ref_count;
short type; /* order is here important */
#else
#if (defined(__x86_64__) || defined(_M_X64))
#if _M_X64
int type; /* order is here important */
int ref_count;
#else
@@ -74,7 +77,7 @@ typedef struct cst_val_atom_struct {
#endif
union
{
#if (defined(__x86_64__) || defined(_M_X64))
#if _M_X64
double fval;
long long ival;
void *vval;
@@ -108,59 +111,34 @@ cst_val *cons_val(const cst_val *a, const cst_val *b);

/* Derefence and delete val if no other references */
void delete_val(cst_val *val);
void delete_val_list(cst_val *val);

/* Accessor functions */
int val_int(const cst_val *v);
float val_float(const cst_val *v);
const char *val_string(const cst_val *v);
void *val_void(const cst_val *v);
void *val_generic(const cst_val *v, int type, const char *stype);
const cst_val *val_car(const cst_val *v);
const cst_val *val_cdr(const cst_val *v);

const cst_val *set_cdr(cst_val *v1, const cst_val *v2);
const cst_val *set_car(cst_val *v1, const cst_val *v2);

int cst_val_consp(const cst_val *v);

/* Unsafe accessor function -- for the brave and foolish */
#define CST_VAL_STRING_LVAL(X) ((X)->c.a.v.vval)
#define CST_VAL_TYPE(X) ((X)->c.a.type)
#define CST_VAL_INT(X) ((X)->c.a.v.ival)
#define CST_VAL_FLOAT(X) ((X)->c.a.v.fval)
#define CST_VAL_STRING(X) ((const char *)(CST_VAL_STRING_LVAL(X)))
#define CST_VAL_VOID(X) ((X)->c.a.v.vval)
#define CST_VAL_CAR(X) ((X)->c.cc.car)
#define CST_VAL_CDR(X) ((X)->c.cc.cdr)

#define CST_VAL_REFCOUNT(X) ((X)->c.a.ref_count)

/* Some standard function */
int val_equal(const cst_val *a, const cst_val *b);
int val_less(const cst_val *a, const cst_val *b);
int val_greater(const cst_val *a, const cst_val *b);
int val_member(const cst_val *a, const cst_val *b);
int val_member_string (const char *a, const cst_val *b);
int val_stringp(const cst_val *a);
const cst_val *val_assoc_string(const char *v1,const cst_val *al);

void val_print(cst_file fd,const cst_val *v);
#if defined(CART_DEBUG) || defined(SSML_DEBUG)
void val_print(const cst_val *v);
#endif // defined(CART_DEBUG) || defined(SSML_DEBUG)

cst_val *val_readlist_string(const char *str);

cst_val *val_reverse(cst_val *v);
cst_val *val_append(cst_val *a,cst_val *b);
int val_length(const cst_val *l);
cst_val *cst_utf8_explode(const cst_string *utf8string);
cst_string *cst_implode(const cst_val *string_list);

cst_val *cst_utf8_ord(const cst_val *utf8_char);
cst_val *cst_utf8_chr(const cst_val *ord);

int cst_utf8_ord_string(const char *utf8_char);

/* make sure you know what you are doing before you call these */
int val_dec_refcount(const cst_val *b);
cst_val *val_inc_refcount(const cst_val *b);

#include "cst_val_const.h"
@@ -1,4 +1,10 @@
/*************************************************************************/
/* This code has been modified for Bellbird. */
/* See COPYING for more copyright details. */
/* The unmodified source code copyright notice */
/* is included below. */
/*************************************************************************/
/*************************************************************************/
/* */
/* Language Technologies Institute */
/* Carnegie Mellon University */
@@ -54,76 +60,32 @@
/* initialization of unions. There is one in the C99 standard and GCC */
/* already supports it, but other compilers do not so I can't use that */
/* */
/* So I need a way to make an object that will have the right 8 bytes */
/* for ints, floats, strings and cons cells that will work on any C */
/* compiler and will be of type const cst_val. That unfortunately */
/* isn't trivial. */
/* */
/* For the time being ignoring byte order, and address size, which */
/* will be ignored in the particular discuss (though dealt with below) */
/* I'd like to do something like */
/* */
/* const cst_val fredi = { CST_VAL_TYPE_INT,-1, 42 }; */
/* const cst_val fredf = { CST_VAL_TYPE_FLOAT,-1, 4.2 }; */
/* const cst_val freds = { CST_VAL_TYPE_STRING,-1, "42" }; */
/* */
/* Even if you accept warnings this isn't going to work, if you add */
/* extra {} you can get rid of some warnings but the fval/ival/ *vval */
/* part isn't going to work, the compiler *may* try to take the value */
/* and assign it using the type of the first field defined in the */
/* union. This could be made to work for ints and void* as pointers */
/* can be used as ints (even of 64 bit architectures) but the float */
/* isn't going to work. Casting will cause the float to be changed to */
/* an int by CPP which isn't what you want, what you want is that the */
/* four byte region gets filled with the four bytes that represent the */
/* float itself. Now you could get the four byte represention of the */
/* float and pretend that is an int (0xbfff9a4 for 4.2 on intel), that */
/* would work but that doesn't seem satifying and I'd need to have a */
/* preprocessor that could convert that. You could make atoms always */
/* have a pointer to another piece of memory, but that would take up */
/* another 4 bytes not just for these constants but all other cst_vals */
/* create */
/* */
/* So you could do */
/* */
/* const cst_val_int fredi = { CST_VAL_TYPE_INT,-1, 42 }; */
/* const cst_val_float fredf = { CST_VAL_TYPE_FLOAT,-1, 4.2 }; */
/* const cst_val_string freds = { CST_VAL_TYPE_STRING,-1, "42" }; */
/* */
/* Though that's a slippery slope I don't want to have these explicit */
/* new types, the first short defines the type perfectly adequately */
/* and the whole point of runtime types is that there is one object */
/* type. */
/* */
/* Well just initialize them at runtime, but, that isn't thread safe, */
/* slows down startup, requires a instance implicitly in the code and */
/* on the heap. As these are const, they should go in ROM. */
/* */
/* At this moment, I think the second version is the least problematic */
/* though it makes defining val_consts more unpleasant than they should */
/* be and forces changes elsewhere in the code even when the compiler */
/* does support initialization of unions */
/* BELLBIRD NOTE:- As of Dec 2013 even MS-VS 2013 supports designated */
/* initializers so the legacy option has now been removed */
/* */
/* For legacy reasons val_consts are more unpleasant than they should */
/* be and force changes elsewhere in the code even when the compiler */
/* does support initialization of unions. This may be changed in the */
/* future. */
/* */
/*************************************************************************/
#ifndef _CST_VAL_CONSTS_H__
#define _CST_VAL_CONSTS_H__

#include "cst_val_defs.h"
#ifndef _CST_VAL_CONST_H__
#define _CST_VAL_CONST_H__

/* There is built-in int to string conversions here for numbers */
/* up to 20, note if you make this bigger you have to hand change */
/* other things too */
#define CST_CONST_INT_MAX 19

#ifndef NO_UNION_INITIALIZATION

/* This is the simple way when initialization of unions is supported */

#define DEF_CONST_VAL_INT(N,V) const cst_val N = {{.a={.type=CST_VAL_TYPE_INT,.ref_count=-1,.v={.ival=V}}}}
#define DEF_CONST_VAL_STRING(N,S) const cst_val N = {{.a={.type=CST_VAL_TYPE_STRING,.ref_count=-1,.v={.vval= (void *)S}}}}
#define DEF_CONST_VAL_FLOAT(N,F) const cst_val N = {{.a={.type=CST_VAL_TYPE_FLOAT,.ref_count=-1,.v={.fval=F}}}}
#define DEF_CONST_VAL_CONS(N,A,D) const cst_val N = {{.cc={.car=A,.cdr=D }}}

#define DEF_STATIC_CONST_VAL_INT(N,V) static DEF_CONST_VAL_INT(N,V)
#define DEF_STATIC_CONST_VAL_STRING(N,S) static DEF_CONST_VAL_STRING(N,S)
#define DEF_STATIC_CONST_VAL_FLOAT(N,F) static DEF_CONST_VAL_FLOAT(N,F)

extern const cst_val val_int_0;
extern const cst_val val_int_1;
@@ -145,11 +107,6 @@ extern const cst_val val_int_16;
extern const cst_val val_int_17;
extern const cst_val val_int_18;
extern const cst_val val_int_19;
extern const cst_val val_int_20;
extern const cst_val val_int_21;
extern const cst_val val_int_22;
extern const cst_val val_int_23;
extern const cst_val val_int_24;

extern const cst_val val_string_0;
extern const cst_val val_string_1;
@@ -171,211 +128,9 @@ extern const cst_val val_string_16;
extern const cst_val val_string_17;
extern const cst_val val_string_18;
extern const cst_val val_string_19;
extern const cst_val val_string_20;
extern const cst_val val_string_21;
extern const cst_val val_string_22;
extern const cst_val val_string_23;
extern const cst_val val_string_24;

#else
/* Only GCC seems to currently support the C99 standard for giving */
/* explicit names for fields for initializing unions, because we want */
/* things to be const, and to be small structures this is really useful */
/* thus for compilers not supporting no_union_initization we use other */
/* structure that we know (hope ?) are the same size and use agressive */
/* casting. The goal here is wholly justified but the method here isn't */
/* pretty */

/* These structures are defined *solely* to get round initialization */
/* problems if you need to use these in any code you are using, you are */
/* unquestionably doing the wrong thing */
typedef struct cst_val_atom_struct_float {
#ifdef WORDS_BIGENDIAN
short ref_count;
short type; /* order is here important */
#else
#if (defined(__x86_64__) || defined(_M_X64))
int type; /* order is here important */
int ref_count;
#else
short type; /* order is here important */
short ref_count;
#endif
#endif
#if (defined(__x86_64__) || defined(_M_X64))
double fval;
#else
float fval;
#endif
} cst_val_float;

typedef struct cst_val_atom_struct_int {
#ifdef WORDS_BIGENDIAN
short ref_count;
short type; /* order is here important (and unintuitive) */
#else
#if (defined(__x86_64__) || defined(_M_X64))
int type; /* order is here important */
int ref_count;
#else
short type; /* order is here important */
short ref_count;
#endif
#endif
#if (defined(__x86_64__) || defined(_M_X64))
long long ival;
#else
int ival;
#endif
} cst_val_int;

typedef struct cst_val_atom_struct_void {
#ifdef WORDS_BIGENDIAN
short ref_count;
short type; /* order is here important */
#else
#if (defined(__x86_64__) || defined(_M_X64))
int type; /* order is here important */
int ref_count;
#else
short type; /* order is here important */
short ref_count;
#endif
#endif
void *vval;
} cst_val_void;

#ifdef WORDS_BIGENDIAN
#define DEF_CONST_VAL_INT(N,V) const cst_val_int N={-1, CST_VAL_TYPE_INT, V}
#define DEF_CONST_VAL_STRING(N,S) const cst_val_void N={-1,CST_VAL_TYPE_STRING,(void *)S}
#define DEF_CONST_VAL_FLOAT(N,F) const cst_val_float N={-1,CST_VAL_TYPE_FLOAT,(float)F}
#else
#define DEF_CONST_VAL_INT(N,V) const cst_val_int N={CST_VAL_TYPE_INT,-1,V}
#define DEF_CONST_VAL_STRING(N,S) const cst_val_void N={CST_VAL_TYPE_STRING,-1,(void *)S}
#define DEF_CONST_VAL_FLOAT(N,F) const cst_val_float N={CST_VAL_TYPE_FLOAT,-1,(float)F}
#endif
#define DEF_CONST_VAL_CONS(N,A,D) const cst_val_cons N={A,D}

/* in the non-union intialization version we these consts have to be */
/* more typed than need, we'll cast the back later */
extern const cst_val_int val_int_0;
extern const cst_val_int val_int_1;
extern const cst_val_int val_int_2;
extern const cst_val_int val_int_3;
extern const cst_val_int val_int_4;
extern const cst_val_int val_int_5;
extern const cst_val_int val_int_6;
extern const cst_val_int val_int_7;
extern const cst_val_int val_int_8;
extern const cst_val_int val_int_9;
extern const cst_val_int val_int_10;
extern const cst_val_int val_int_11;
extern const cst_val_int val_int_12;
extern const cst_val_int val_int_13;
extern const cst_val_int val_int_14;
extern const cst_val_int val_int_15;
extern const cst_val_int val_int_16;
extern const cst_val_int val_int_17;
extern const cst_val_int val_int_18;
extern const cst_val_int val_int_19;
extern const cst_val_int val_int_20;
extern const cst_val_int val_int_21;
extern const cst_val_int val_int_22;
extern const cst_val_int val_int_23;
extern const cst_val_int val_int_24;

extern const cst_val_void val_string_0;
extern const cst_val_void val_string_1;
extern const cst_val_void val_string_2;
extern const cst_val_void val_string_3;
extern const cst_val_void val_string_4;
extern const cst_val_void val_string_5;
extern const cst_val_void val_string_6;
extern const cst_val_void val_string_7;
extern const cst_val_void val_string_8;
extern const cst_val_void val_string_9;
extern const cst_val_void val_string_10;
extern const cst_val_void val_string_11;
extern const cst_val_void val_string_12;
extern const cst_val_void val_string_13;
extern const cst_val_void val_string_14;
extern const cst_val_void val_string_15;
extern const cst_val_void val_string_16;
extern const cst_val_void val_string_17;
extern const cst_val_void val_string_18;
extern const cst_val_void val_string_19;
extern const cst_val_void val_string_20;
extern const cst_val_void val_string_21;
extern const cst_val_void val_string_22;
extern const cst_val_void val_string_23;
extern const cst_val_void val_string_24;

#endif

#define DEF_STATIC_CONST_VAL_INT(N,V) static DEF_CONST_VAL_INT(N,V)
#define DEF_STATIC_CONST_VAL_STRING(N,S) static DEF_CONST_VAL_STRING(N,S)
#define DEF_STATIC_CONST_VAL_FLOAT(N,F) static DEF_CONST_VAL_FLOAT(N,F)
#define DEF_STATIC_CONST_VAL_CONS(N,A,D) static DEF_CONST_VAL_CONS(N,A,D)

/* Some actual val consts */
/* The have casts as in the non-union intialize case the casts are necessary */
/* but in the union initial case these casts are harmless */

#define VAL_INT_0 (cst_val *)&val_int_0
#define VAL_INT_1 (cst_val *)&val_int_1
#define VAL_INT_2 (cst_val *)&val_int_2
#define VAL_INT_3 (cst_val *)&val_int_3
#define VAL_INT_4 (cst_val *)&val_int_4
#define VAL_INT_5 (cst_val *)&val_int_5
#define VAL_INT_6 (cst_val *)&val_int_6
#define VAL_INT_7 (cst_val *)&val_int_7
#define VAL_INT_8 (cst_val *)&val_int_8
#define VAL_INT_9 (cst_val *)&val_int_9
#define VAL_INT_10 (cst_val *)&val_int_10
#define VAL_INT_11 (cst_val *)&val_int_11
#define VAL_INT_12 (cst_val *)&val_int_12
#define VAL_INT_13 (cst_val *)&val_int_13
#define VAL_INT_14 (cst_val *)&val_int_14
#define VAL_INT_15 (cst_val *)&val_int_15
#define VAL_INT_16 (cst_val *)&val_int_16
#define VAL_INT_17 (cst_val *)&val_int_17
#define VAL_INT_18 (cst_val *)&val_int_18
#define VAL_INT_19 (cst_val *)&val_int_19
#define VAL_INT_20 (cst_val *)&val_int_20
#define VAL_INT_21 (cst_val *)&val_int_21
#define VAL_INT_22 (cst_val *)&val_int_22
#define VAL_INT_23 (cst_val *)&val_int_23
#define VAL_INT_24 (cst_val *)&val_int_24

const cst_val *val_int_n(int n);

#define VAL_STRING_0 (cst_val *)&val_string_0
#define VAL_STRING_1 (cst_val *)&val_string_1
#define VAL_STRING_2 (cst_val *)&val_string_2
#define VAL_STRING_3 (cst_val *)&val_string_3
#define VAL_STRING_4 (cst_val *)&val_string_4
#define VAL_STRING_5 (cst_val *)&val_string_5
#define VAL_STRING_6 (cst_val *)&val_string_6
#define VAL_STRING_7 (cst_val *)&val_string_7
#define VAL_STRING_8 (cst_val *)&val_string_8
#define VAL_STRING_9 (cst_val *)&val_string_9
#define VAL_STRING_10 (cst_val *)&val_string_10
#define VAL_STRING_11 (cst_val *)&val_string_11
#define VAL_STRING_12 (cst_val *)&val_string_12
#define VAL_STRING_13 (cst_val *)&val_string_13
#define VAL_STRING_14 (cst_val *)&val_string_14
#define VAL_STRING_15 (cst_val *)&val_string_15
#define VAL_STRING_16 (cst_val *)&val_string_16
#define VAL_STRING_17 (cst_val *)&val_string_17
#define VAL_STRING_18 (cst_val *)&val_string_18
#define VAL_STRING_19 (cst_val *)&val_string_19
#define VAL_STRING_20 (cst_val *)&val_string_20
#define VAL_STRING_21 (cst_val *)&val_string_21
#define VAL_STRING_22 (cst_val *)&val_string_22
#define VAL_STRING_23 (cst_val *)&val_string_23
#define VAL_STRING_24 (cst_val *)&val_string_24

const cst_val *val_string_n(int n);


#endif
@@ -1,4 +1,10 @@
/*************************************************************************/
/* This code has been modified for Bellbird. */
/* See COPYING for more copyright details. */
/* The unmodified source code copyright notice */
/* is included below. */
/*************************************************************************/
/*************************************************************************/
/* */
/* Language Technologies Institute */
/* Carnegie Mellon University */
@@ -69,11 +75,6 @@ cst_val *NAME##_val(const TYPE *v) \
(void *)v); \
} \

#define CST_VAL_REG_TD_TYPE(NAME,TYPE,NUM) \
extern const int cst_val_type_##NAME; \
const int cst_val_type_##NAME=NUM; \
void val_delete_##NAME(void *v); \

/* When objects of this type can never be owned by vals */
#define CST_VAL_REGISTER_TYPE_NODEL(NAME,TYPE) \
TYPE *val_##NAME(const cst_val *v) \
@@ -87,11 +88,6 @@ cst_val *NAME##_val(const TYPE *v) \
(void *)v); \
} \

#define CST_VAL_REG_TD_TYPE_NODEL(NAME,TYPE,NUM) \
extern const int cst_val_type_##NAME; \
const int cst_val_type_##NAME=NUM; \
void val_delete_##NAME(void *v) { (void)v; } \

#define CST_VAL_REGISTER_FUNCPTR(NAME,TYPE) \
TYPE val_##NAME(const cst_val *v) \
{ \
@@ -104,9 +100,4 @@ cst_val *NAME##_val(const TYPE v) \
(void *)v); \
} \

#define CST_VAL_REG_TD_FUNCPTR(NAME,TYPE,NUM) \
extern const int cst_val_type_##NAME; \
const int cst_val_type_##NAME=NUM; \
void val_delete_##NAME(void *v) { (void)v; } \

#endif

This file was deleted.

@@ -1,4 +1,10 @@
/*************************************************************************/
/* This code has been modified for Bellbird. */
/* See COPYING for more copyright details. */
/* The unmodified source code copyright notice */
/* is included below. */
/*************************************************************************/
/*************************************************************************/
/* */
/* Language Technologies Institute */
/* Carnegie Mellon University */
@@ -40,18 +46,16 @@
#ifndef _CST_VOICE_H__
#define _CST_VOICE_H__

#include "cst_file.h"
#include "cst_val.h"
#include "cst_features.h"
#include "cst_utterance.h"
#include "cst_relation.h"
#include "cst_lexicon.h"

struct cst_voice_struct {
const char *name;

cst_features *features;
cst_features *ffunctions;
cst_ffunction *ffunctions; // Array for indexed access of features functions

/* This hook is called (from utt_init()) after the input text (if
any) has been set and voice features have been copied in, but
@@ -1,4 +1,10 @@
/*************************************************************************/
/* This code has been modified for Bellbird. */
/* See COPYING for more copyright details. */
/* The unmodified source code copyright notice */
/* is included below. */
/*************************************************************************/
/*************************************************************************/
/* */
/* Language Technologies Institute */
/* Carnegie Mellon University */
@@ -40,124 +46,42 @@
#ifndef _CST_WAVE_H__
#define _CST_WAVE_H__

#include "cst_file.h"
#include "cst_error.h"
#include "cst_alloc.h"
#include "cst_endian.h"
#include <stdint.h>
#include "cst_file.h"
#include "cst_val.h"

typedef struct cst_wave_struct {
const char *type;
int sample_rate;
int num_samples;
int num_channels;
short *samples;
int16_t *samples;
} cst_wave;

typedef struct cst_wave_header_struct {
const char *type;
int hsize;
int num_bytes;
int sample_rate;
int num_samples;
int num_channels;
} cst_wave_header;

cst_wave *new_wave();
cst_wave *copy_wave(const cst_wave *w);
void delete_wave(cst_wave *val);
cst_wave *concat_wave(cst_wave *dest, const cst_wave *src);

#define cst_wave_num_samples(w) (w?w->num_samples:0)
#define cst_wave_num_channels(w) (w?w->num_channels:0)
#define cst_wave_sample_rate(w) (w?w->sample_rate:0)
#define cst_wave_samples(w) (w->samples)
#define CST_WAVE_NUM_SAMPLES(w) (w?w->num_samples:0)
#define CST_WAVE_NUM_CHANNELS(w) (w?w->num_channels:0)
#define CST_WAVE_SAMPLE_RATE(w) (w?w->sample_rate:0)
#define CST_WAVE_SAMPLES(w) (w->samples)

#define CST_WAVE_SET_NUM_SAMPLES(w,s) w->num_samples=s
#define CST_WAVE_SET_SAMPLE_RATE(w,s) w->sample_rate=s

#define cst_wave_set_num_samples(w,s) w->num_samples=s
#define cst_wave_set_num_channels(w,s) w->num_channels=s
#define cst_wave_set_sample_rate(w,s) w->sample_rate=s
#define BELL_IO_SUCCESS 0
#define BELL_IO_ERROR -1

int cst_wave_save(cst_wave *w, const char *filename, const char *type);
int cst_wave_save_riff(cst_wave *w, const char *filename);
int cst_wave_save_raw(cst_wave *w, const char *filename);
int cst_wave_append_riff(cst_wave *w,const char *filename);

int cst_wave_save_riff_fd(cst_wave *w, cst_file fd);
int cst_wave_save_raw_fd(cst_wave *w, cst_file fd);

int cst_wave_load(cst_wave *w, const char *filename, const char *type);
int cst_wave_load_riff(cst_wave *w, const char *filename);
int cst_wave_load_raw(cst_wave *w, const char *filename,
const char *bo, int sample_rate);

int cst_wave_load_riff_header(cst_wave_header *header,cst_file fd);
int cst_wave_load_riff_fd(cst_wave *w, cst_file fd);
int cst_wave_load_raw_fd (cst_wave *w, cst_file fd,
const char *bo, int sample_rate);

void cst_wave_resize(cst_wave *w,int samples, int num_channels);
void cst_wave_resample(cst_wave *w, int sample_rate);
void cst_wave_rescale(cst_wave *w, int factor);

/* Resampling code */
typedef struct cst_rateconv_struct {
int channels; /* what do you think? */
int up, down; /* up/down sampling ratio */

double gain; /* output gain */
int lag; /* lag time (in samples) */
int *sin, *sout, *coep; /* filter buffers, coefficients */

/* n.b. outsize is the minimum buffer size for
cst_rateconv_out() when streaming */
int insize, outsize; /* size of filter buffers */
int incount; /* amount of input data */
int len; /* size of filter */

/* internal foo coefficients */
double fsin, fgk, fgg;
/* internal counters */
int inbaseidx, inoffset, cycctr, outidx;
} cst_rateconv;

cst_rateconv * new_rateconv(int up, int down, int channels);
void delete_rateconv(cst_rateconv *filt);
int cst_rateconv_in(cst_rateconv *filt, const short *inptr, int max);
int cst_rateconv_leadout(cst_rateconv *filt);
int cst_rateconv_out(cst_rateconv *filt, short *outptr, int max);

/* File format cruft. */

#define RIFF_FORMAT_PCM 0x0001
#define RIFF_FORMAT_ADPCM 0x0002
#define RIFF_FORMAT_MULAW 0x0006
#define RIFF_FORMAT_ALAW 0x0007

/* Sun/Next header, short and sweet, note its always BIG_ENDIAN though */
typedef struct {
unsigned int magic; /* magic number */
unsigned int hdr_size; /* size of this header */
int data_size; /* length of data (optional) */
unsigned int encoding; /* data encoding format */
unsigned int sample_rate; /* samples per second */
unsigned int channels; /* number of interleaved channels */
} snd_header;

#define CST_SND_MAGIC (unsigned int)0x2e736e64
#define CST_SND_ULAW 1
#define CST_SND_UCHAR 2
#define CST_SND_SHORT 3

/* Convertion functions */
unsigned char cst_short_to_ulaw(short sample);
short cst_ulaw_to_short(unsigned char ulawbyte);

#define CST_G721_LEADIN 8
unsigned char *cst_g721_decode(int *actual_size,int size,
const unsigned char *packed_residual);
unsigned char *cst_g721_encode(int *packed_size,int actual_size,
const unsigned char *unpacked_residual);

CST_VAL_USER_TYPE_DCLS(wave,cst_wave)

This file was deleted.

@@ -1,4 +1,10 @@
/*************************************************************************/
/* This code has been modified for Bellbird. */
/* See COPYING for more copyright details. */
/* The unmodified source code copyright notice */
/* is included below. */
/*************************************************************************/
/*************************************************************************/
/* */
/* Language Technologies Institute */
/* Carnegie Mellon University */
@@ -44,99 +50,39 @@
extern "C" {
#endif /* __cplusplus */

#include "cst_string.h"
#include "cst_regex.h"
#include "cst_val.h"
#include "cst_features.h"
#include "cst_item.h"
#include "cst_relation.h"
#include "cst_lexicon.h"
#include "cst_string.h"
#include "cst_tokenstream.h"
#include "cst_utterance.h"
#include "cst_wave.h"
#include "cst_track.h"

#include "cst_cart.h"
#include "cst_phoneset.h"
#include "cst_voice.h"
#include "cst_audio.h"

#include "cst_utt_utils.h"
#include "cst_lexicon.h"
#include "cst_synth.h"
#include "cst_units.h"
#include "cst_tokenstream.h"

extern cst_val *flite_voice_list;
extern cst_lang flite_lang_list[20];

/* Public functions */
int flite_init();

/* General top level functions */
cst_voice *flite_voice_select(const char *name);
cst_voice *flite_voice_load(const char *voice_filename);
int flite_voice_dump(cst_voice *voice, const char *voice_filename);
float flite_file_to_speech(const char *filename,
cst_voice *voice,
float flite_text_to_speech(const char *text, cst_voice *voice,
const char *outtype);
float flite_text_to_speech(const char *text,
cst_voice *voice,
const char *outtype);
float flite_phones_to_speech(const char *text,
cst_voice *voice,
const char *outtype);
float flite_ssml_file_to_speech(const char *filename,
cst_voice *voice,
float flite_ssml_file_to_speech(const char *filename, cst_voice *voice,
const char *outtype);
float flite_ssml_text_to_speech(const char *text,
cst_voice *voice,
float flite_ssml_text_to_speech(const char *text, cst_voice *voice,
const char *outtype);
int flite_voice_add_lex_addenda(cst_voice *v, const cst_string *lexfile);

/* Lower lever user functions */
cst_wave *flite_text_to_wave(const char *text,cst_voice *voice);
cst_utterance *flite_synth_text(const char *text,cst_voice *voice);
cst_utterance *flite_synth_phones(const char *phones,cst_voice *voice);

float flite_ts_to_speech(cst_tokenstream *ts,
cst_voice *voice,
/* Lower level user functions */
float flite_ts_to_speech(cst_tokenstream *ts, cst_voice *voice,
const char *outtype);
cst_utterance *flite_do_synth(cst_utterance *u,
cst_voice *voice,
cst_utterance *flite_do_synth(cst_utterance *u, cst_voice *voice,
cst_uttfunc synth);
float flite_process_output(cst_utterance *u,
const char *outtype,
float flite_process_output(cst_utterance *u, const char *outtype,
int append);

/* for voices with external voxdata */
int flite_mmap_clunit_voxdata(const char *voxdir, cst_voice *voice);
int flite_munmap_clunit_voxdata(cst_voice *voice);

/* flite public export wrappers for features access */
int flite_get_param_int(const cst_features *f, const char *name,int def);
float flite_get_param_float(const cst_features *f, const char *name, float def);
const char *flite_get_param_string(const cst_features *f, const char *name, const char *def);
const cst_val *flite_get_param_val(const cst_features *f, const char *name, cst_val *def);
void flite_feat_set_int(cst_features *f, const char *name, int v);
void flite_feat_set_float(cst_features *f, const char *name, float v);
void flite_feat_set_string(cst_features *f, const char *name, const char *v);
void flite_feat_set(cst_features *f, const char *name,const cst_val *v);
int flite_feat_remove(cst_features *f, const char *name);

const char *flite_ffeature_string(const cst_item *item,const char *featpath);
int flite_ffeature_int(const cst_item *item,const char *featpath);
float flite_ffeature_float(const cst_item *item,const char *featpath);
const cst_val *flite_ffeature(const cst_item *item,const char *featpath);
cst_item* flite_path_to_item(const cst_item *item,const char *featpath);

/* These functions are *not* thread-safe, they are designed to be called */
/* before the initial synthesis occurs */
int flite_add_voice(cst_voice *voice);
int flite_add_lang(const char *langname,
void (*lang_init)(cst_voice *vox),
int flite_add_lang(const char *langname, void (*lang_init)(cst_voice *vox),
cst_lexicon *(*lex_init)());
/* These are init functions for generic grapheme based voices */
void utf8_grapheme_lang_init(cst_voice *v);
cst_lexicon *utf8_grapheme_lex_init(void);

#ifdef __cplusplus
} /* extern "C" */
@@ -0,0 +1,24 @@
// Common structures for cg modules

typedef struct _DWin {
int num; // number of static + deltas
int **width; // width [0..num-1][0(left) 1(right)]
double **coef; // coefficient [0..num-1][length[0]..length[1]]
double **coef_ptrs; // pointers to the memory being allocated so they can be freed
int maxw[2]; // max width [0(left) 1(right)]
int max_L;
} DWin;

typedef struct _PStreamChol {
int vSize;
int order;
int T; // number of frames
int width;
DWin dw;
double **mseq; // sequence of mean vector
double **ivseq; // sequence of inversed variance vector
double **R;
double *r;
double *g;
double **c; // output parameter vector
} PStreamChol;

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.