first commit
This commit is contained in:
@@ -0,0 +1,82 @@
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* Language Technologies Institute */
|
||||
/* Carnegie Mellon University */
|
||||
/* Copyright (c) 1999 */
|
||||
/* All Rights Reserved. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to use and distribute */
|
||||
/* this software and its documentation without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of this work, and to */
|
||||
/* permit persons to whom this work is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* 1. The code must retain the above copyright notice, this list of */
|
||||
/* conditions and the following disclaimer. */
|
||||
/* 2. Any modifications must be clearly marked as such. */
|
||||
/* 3. Original authors' names are not deleted. */
|
||||
/* 4. The authors' names are not used to endorse or promote products */
|
||||
/* derived from this software without specific prior written */
|
||||
/* permission. */
|
||||
/* */
|
||||
/* CARNEGIE MELLON UNIVERSITY AND THE CONTRIBUTORS TO THIS WORK */
|
||||
/* DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING */
|
||||
/* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT */
|
||||
/* SHALL CARNEGIE MELLON UNIVERSITY NOR THE CONTRIBUTORS BE LIABLE */
|
||||
/* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES */
|
||||
/* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN */
|
||||
/* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, */
|
||||
/* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF */
|
||||
/* THIS SOFTWARE. */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
/* Author: Alan W Black (awb@cs.cmu.edu) */
|
||||
/* Date: July 1999 */
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* Basic wraparounds for malloc and free */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
#ifndef __CST_ALLOC_H__
|
||||
#define __CST_ALLOC_H__
|
||||
|
||||
#ifndef TRUE
|
||||
#define TRUE (1==1)
|
||||
#endif
|
||||
#ifndef FALSE
|
||||
#define FALSE (1==0)
|
||||
#endif
|
||||
|
||||
/* Global allocation (the only kind on Unix) */
|
||||
void *cst_safe_alloc(int size);
|
||||
void *cst_safe_calloc(int size);
|
||||
void *cst_safe_realloc(void *p,int size);
|
||||
|
||||
/* Allocate on local heap (needed on WinCE for various reasons) */
|
||||
#ifdef UNDER_CE
|
||||
#include <windows.h>
|
||||
typedef HANDLE cst_alloc_context;
|
||||
|
||||
cst_alloc_context new_alloc_context(int size);
|
||||
void delete_alloc_context(cst_alloc_context ctx);
|
||||
|
||||
void *cst_local_alloc(cst_alloc_context ctx, int size);
|
||||
void cst_local_free(cst_alloc_context ctx, void *p);
|
||||
#else /* not UNDER_CE */
|
||||
typedef void * cst_alloc_context;
|
||||
#define new_alloc_context(size) (NULL)
|
||||
#define delete_alloc_context(ctx)
|
||||
#define cst_local_alloc(ctx,size) cst_safe_alloc(size)
|
||||
#define cst_local_free(cst,p) cst_free(p)
|
||||
#endif /* UNDER_CE */
|
||||
|
||||
/* The public interface to the alloc functions */
|
||||
|
||||
/* Note the underlying call is calloc, so everything is zero'd */
|
||||
#define cst_alloc(TYPE,SIZE) ((TYPE *)cst_safe_alloc(sizeof(TYPE)*(SIZE)))
|
||||
#define cst_calloc(TYPE,SIZE) ((TYPE *)cst_safe_calloc(sizeof(TYPE)*(SIZE)))
|
||||
#define cst_realloc(P,TYPE,SIZE) ((TYPE *)cst_safe_realloc((void *)(P),sizeof(TYPE)*(SIZE)))
|
||||
|
||||
void cst_free(void *p);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,49 @@
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* Language Technologies Institute */
|
||||
/* Carnegie Mellon University */
|
||||
/* Copyright (c) 2001 */
|
||||
/* All Rights Reserved. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to use and distribute */
|
||||
/* this software and its documentation without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of this work, and to */
|
||||
/* permit persons to whom this work is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* 1. The code must retain the above copyright notice, this list of */
|
||||
/* conditions and the following disclaimer. */
|
||||
/* 2. Any modifications must be clearly marked as such. */
|
||||
/* 3. Original authors' names are not deleted. */
|
||||
/* 4. The authors' names are not used to endorse or promote products */
|
||||
/* derived from this software without specific prior written */
|
||||
/* permission. */
|
||||
/* */
|
||||
/* CARNEGIE MELLON UNIVERSITY AND THE CONTRIBUTORS TO THIS WORK */
|
||||
/* DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING */
|
||||
/* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT */
|
||||
/* SHALL CARNEGIE MELLON UNIVERSITY NOR THE CONTRIBUTORS BE LIABLE */
|
||||
/* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES */
|
||||
/* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN */
|
||||
/* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, */
|
||||
/* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF */
|
||||
/* THIS SOFTWARE. */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
/* Author: Alan W Black (awb@cs.cmu.edu) */
|
||||
/* Date: November 2001 */
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* parse args */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
#ifndef _CST_ARGS_H__
|
||||
#define _CST_ARGS_H__
|
||||
|
||||
#include "cst_features.h"
|
||||
|
||||
cst_val *cst_args(char **argv, int argc,
|
||||
const char *description,
|
||||
cst_features *args);
|
||||
|
||||
#endif
|
||||
+118
@@ -0,0 +1,118 @@
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* Language Technologies Institute */
|
||||
/* Carnegie Mellon University */
|
||||
/* Copyright (c) 2000 */
|
||||
/* All Rights Reserved. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to use and distribute */
|
||||
/* this software and its documentation without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of this work, and to */
|
||||
/* permit persons to whom this work is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* 1. The code must retain the above copyright notice, this list of */
|
||||
/* conditions and the following disclaimer. */
|
||||
/* 2. Any modifications must be clearly marked as such. */
|
||||
/* 3. Original authors' names are not deleted. */
|
||||
/* 4. The authors' names are not used to endorse or promote products */
|
||||
/* derived from this software without specific prior written */
|
||||
/* permission. */
|
||||
/* */
|
||||
/* CARNEGIE MELLON UNIVERSITY AND THE CONTRIBUTORS TO THIS WORK */
|
||||
/* DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING */
|
||||
/* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT */
|
||||
/* SHALL CARNEGIE MELLON UNIVERSITY NOR THE CONTRIBUTORS BE LIABLE */
|
||||
/* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES */
|
||||
/* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN */
|
||||
/* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, */
|
||||
/* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF */
|
||||
/* THIS SOFTWARE. */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
/* Author: Alan W Black (awb@cs.cmu.edu) */
|
||||
/* Date: August 2000 */
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* Audio */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
#ifndef _CST_AUDIO_H__
|
||||
#define _CST_AUDIO_H__
|
||||
|
||||
#include "cst_wave.h"
|
||||
#include "cst_hrg.h"
|
||||
|
||||
#ifdef CST_AUDIO_WIN32
|
||||
#define CST_AUDIOBUFFSIZE 8092
|
||||
#else
|
||||
#define CST_AUDIOBUFFSIZE 128
|
||||
#endif
|
||||
|
||||
#define CST_AUDIO_DEFAULT_PORT 1746
|
||||
#define CST_AUDIO_DEFAULT_SERVER "localhost"
|
||||
#define CST_AUDIO_DEFAULT_ENCODING "short"
|
||||
|
||||
typedef enum {
|
||||
CST_AUDIO_LINEAR16 = 0,
|
||||
CST_AUDIO_LINEAR8,
|
||||
CST_AUDIO_MULAW
|
||||
} cst_audiofmt;
|
||||
/* Returns the number of bytes per sample for a given audio format */
|
||||
int audio_bps(cst_audiofmt fmt);
|
||||
|
||||
typedef struct cst_audiodev_struct {
|
||||
int sps, real_sps;
|
||||
int channels, real_channels;
|
||||
cst_audiofmt fmt, real_fmt;
|
||||
int byteswap;
|
||||
cst_rateconv *rateconv;
|
||||
void *platform_data;
|
||||
} cst_audiodev;
|
||||
|
||||
/* Generic audio functions */
|
||||
cst_audiodev *audio_open(int sps, int channels, cst_audiofmt fmt);
|
||||
int audio_close(cst_audiodev *ad);
|
||||
int audio_write(cst_audiodev *ad, void *buff, int num_bytes);
|
||||
int audio_flush(cst_audiodev *ad); /* wait for buffers to empty */
|
||||
int audio_drain(cst_audiodev *ad); /* empty buffers now */
|
||||
|
||||
/* Generic high level audio functions */
|
||||
int play_wave(cst_wave *w);
|
||||
int play_wave_sync(cst_wave *w, cst_relation *rel,
|
||||
int (*call_back)(cst_item *));
|
||||
int play_wave_client(cst_wave *w, const char *servername, int port,
|
||||
const char *encoding);
|
||||
int auserver(int port);
|
||||
|
||||
/* Play wave to specified device */
|
||||
int play_wave_device(cst_wave *w, cst_audiodev *ad);
|
||||
|
||||
/* Output to a file as if its an audio device */
|
||||
cst_audiodev *audio_open_file(int sps, int channels, cst_audiofmt fmt,
|
||||
const char *filename);
|
||||
int audio_close_file(cst_audiodev *ad);
|
||||
int audio_write_file(cst_audiodev *ad, void *buff, int num_bytes);
|
||||
int audio_drain_file(cst_audiodev *ad);
|
||||
int audio_flush_file(cst_audiodev *ad);
|
||||
|
||||
/* For audio streaming */
|
||||
#define CST_AUDIO_STREAM_STOP -1
|
||||
#define CST_AUDIO_STREAM_CONT 0
|
||||
typedef int (*cst_audio_stream_callback)(const cst_wave *w,int start,int size,
|
||||
int last, void *user);
|
||||
typedef struct cst_audio_streaming_info_struct
|
||||
{
|
||||
int min_buffsize;
|
||||
cst_audio_stream_callback asc;
|
||||
void *userdata;
|
||||
} cst_audio_streaming_info;
|
||||
cst_audio_streaming_info *new_audio_streaming_info();
|
||||
void delete_audio_streaming_info(cst_audio_streaming_info *asi);
|
||||
CST_VAL_USER_TYPE_DCLS(audio_streaming_info,cst_audio_streaming_info)
|
||||
|
||||
/* An example audio streaming callback function src/audio/au_streaming.c */
|
||||
int audio_stream_chunk(const cst_wave *w, int start, int size,
|
||||
int last, void *user);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,77 @@
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* Language Technologies Institute */
|
||||
/* Carnegie Mellon University */
|
||||
/* Copyright (c) 2000 */
|
||||
/* All Rights Reserved. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to use and distribute */
|
||||
/* this software and its documentation without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of this work, and to */
|
||||
/* permit persons to whom this work is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* 1. The code must retain the above copyright notice, this list of */
|
||||
/* conditions and the following disclaimer. */
|
||||
/* 2. Any modifications must be clearly marked as such. */
|
||||
/* 3. Original authors' names are not deleted. */
|
||||
/* 4. The authors' names are not used to endorse or promote products */
|
||||
/* derived from this software without specific prior written */
|
||||
/* permission. */
|
||||
/* */
|
||||
/* CARNEGIE MELLON UNIVERSITY AND THE CONTRIBUTORS TO THIS WORK */
|
||||
/* DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING */
|
||||
/* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT */
|
||||
/* SHALL CARNEGIE MELLON UNIVERSITY NOR THE CONTRIBUTORS BE LIABLE */
|
||||
/* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES */
|
||||
/* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN */
|
||||
/* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, */
|
||||
/* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF */
|
||||
/* THIS SOFTWARE. */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
/* Author: Alan W Black (awb@cs.cmu.edu) */
|
||||
/* Date: January 2000 */
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* CART tree support */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
#ifndef _CST_CART_H__
|
||||
#define _CST_CART_H__
|
||||
|
||||
#include "cst_file.h"
|
||||
#include "cst_val.h"
|
||||
#include "cst_features.h"
|
||||
#include "cst_item.h"
|
||||
#include "cst_relation.h"
|
||||
|
||||
#define CST_CART_OP_NONE 255
|
||||
#define CST_CART_OP_LEAF 255
|
||||
#define CST_CART_OP_IS 0
|
||||
#define CST_CART_OP_IN 1
|
||||
#define CST_CART_OP_LESS 2
|
||||
#define CST_CART_OP_GREATER 3
|
||||
#define CST_CART_OP_MATCHES 4
|
||||
#define CST_CART_OP_EQUALS 5
|
||||
|
||||
typedef struct cst_cart_node_struct {
|
||||
unsigned char feat;
|
||||
unsigned char op;
|
||||
/* yes is always the next node */
|
||||
unsigned short no_node; /* or answer index */
|
||||
const cst_val *val;
|
||||
} cst_cart_node;
|
||||
|
||||
typedef struct cst_cart_struct {
|
||||
const cst_cart_node *rule_table;
|
||||
const char * const *feat_table;
|
||||
} cst_cart;
|
||||
|
||||
void delete_cart(cst_cart *c);
|
||||
|
||||
CST_VAL_USER_TYPE_DCLS(cart,cst_cart)
|
||||
|
||||
const cst_val *cart_interpret(cst_item *item, const cst_cart *tree);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,70 @@
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* Language Technologies Institute */
|
||||
/* Carnegie Mellon University */
|
||||
/* Copyright (c) 1999 */
|
||||
/* All Rights Reserved. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to use and distribute */
|
||||
/* this software and its documentation without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of this work, and to */
|
||||
/* permit persons to whom this work is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* 1. The code must retain the above copyright notice, this list of */
|
||||
/* conditions and the following disclaimer. */
|
||||
/* 2. Any modifications must be clearly marked as such. */
|
||||
/* 3. Original authors' names are not deleted. */
|
||||
/* 4. The authors' names are not used to endorse or promote products */
|
||||
/* derived from this software without specific prior written */
|
||||
/* permission. */
|
||||
/* */
|
||||
/* CARNEGIE MELLON UNIVERSITY AND THE CONTRIBUTORS TO THIS WORK */
|
||||
/* DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING */
|
||||
/* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT */
|
||||
/* SHALL CARNEGIE MELLON UNIVERSITY NOR THE CONTRIBUTORS BE LIABLE */
|
||||
/* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES */
|
||||
/* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN */
|
||||
/* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, */
|
||||
/* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF */
|
||||
/* THIS SOFTWARE. */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
/* Author: Alan W Black (awb@cs.cmu.edu) */
|
||||
/* Date: August 2000 */
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* endianness */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
#ifndef __CST_ENDIAN_H__
|
||||
#define __CST_ENDIAN_H__
|
||||
|
||||
extern const int cst_endian_loc;
|
||||
/* Sun, HP, SGI Mips, M68000 */
|
||||
#define CST_BIG_ENDIAN (((char *)&cst_endian_loc)[0] == 0)
|
||||
/* Intel, Alpha, DEC Mips, Vax, Arm, Other MIPS (Casio etc) */
|
||||
#define CST_LITTLE_ENDIAN (((char *)&cst_endian_loc)[0] != 0)
|
||||
|
||||
/* EST byte order strings */
|
||||
#define BYTE_ORDER_BIG "10"
|
||||
#define BYTE_ORDER_LITTLE "01"
|
||||
|
||||
#define SWAPINT(x) ((((unsigned int)x) & 0xff) << 24 | \
|
||||
(((unsigned int)x) & 0xff00) << 8 | \
|
||||
(((unsigned int)x) & 0xff0000) >> 8 | \
|
||||
(((unsigned int)x) & 0xff000000) >> 24)
|
||||
/* For m68k we want to be a little more explicit */
|
||||
#define SWAPLONG(x) ((((unsigned long)x) & 0xff) << 24 | \
|
||||
(((unsigned long)x) & 0xff00) << 8 | \
|
||||
(((unsigned long)x) & 0xff0000) >> 8 | \
|
||||
(((unsigned long)x) & 0xff000000) >> 24)
|
||||
#define SWAPSHORT(x) ((((unsigned short)x) & 0xff) << 8 | \
|
||||
(((unsigned short)x) & 0xff00) >> 8)
|
||||
|
||||
void swap_bytes_short(short * b,int n);
|
||||
|
||||
void swapdouble(double *d);
|
||||
void swapfloat(float *f);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,78 @@
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* Language Technologies Institute */
|
||||
/* Carnegie Mellon University */
|
||||
/* Copyright (c) 1999 */
|
||||
/* All Rights Reserved. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to use and distribute */
|
||||
/* this software and its documentation without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of this work, and to */
|
||||
/* permit persons to whom this work is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* 1. The code must retain the above copyright notice, this list of */
|
||||
/* conditions and the following disclaimer. */
|
||||
/* 2. Any modifications must be clearly marked as such. */
|
||||
/* 3. Original authors' names are not deleted. */
|
||||
/* 4. The authors' names are not used to endorse or promote products */
|
||||
/* derived from this software without specific prior written */
|
||||
/* permission. */
|
||||
/* */
|
||||
/* CARNEGIE MELLON UNIVERSITY AND THE CONTRIBUTORS TO THIS WORK */
|
||||
/* DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING */
|
||||
/* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT */
|
||||
/* SHALL CARNEGIE MELLON UNIVERSITY NOR THE CONTRIBUTORS BE LIABLE */
|
||||
/* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES */
|
||||
/* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN */
|
||||
/* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, */
|
||||
/* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF */
|
||||
/* THIS SOFTWARE. */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
/* Author: Alan W Black (awb@cs.cmu.edu) */
|
||||
/* Date: December 1999 */
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* Error handler */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
#ifndef _CST_ERROR_H__
|
||||
#define _CST_ERROR_H__
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifdef DIE_ON_ERROR
|
||||
# ifdef UNDER_CE
|
||||
# define cst_error() *(int *)0=0
|
||||
# else
|
||||
# define cst_error() abort()
|
||||
# endif
|
||||
#elif __palmos__
|
||||
#ifdef __ARM_ARCH_4T__
|
||||
|
||||
typedef long *jmp_buf[10]; /* V1-V8, SP, LR (see po_setjmp.c) */
|
||||
extern jmp_buf *cst_errjmp;
|
||||
extern char cst_error_msg[];
|
||||
int setjmp(register jmp_buf env);
|
||||
void longjmp(register jmp_buf env, register int value);
|
||||
|
||||
# define cst_error() (cst_errjmp ? longjmp(*cst_errjmp,1) : 0)
|
||||
#else /* m68K */
|
||||
/* I've never tested this or even compiled it (Flite is ARM compiled) */
|
||||
# define cst_error() ErrFatalDisplayIf(-1, "cst_error")
|
||||
#endif
|
||||
#else /* not palmos */
|
||||
#include <setjmp.h>
|
||||
extern jmp_buf *cst_errjmp;
|
||||
# define cst_error() (cst_errjmp ? longjmp(*cst_errjmp,1) : exit(-1))
|
||||
#endif
|
||||
|
||||
/* WinCE sometimes doesn't have stdio, so this is a wrapper for
|
||||
fprintf(stderr, ...) */
|
||||
int cst_errmsg(const char *fmt, ...);
|
||||
#define cst_dbgmsg cst_errmsg
|
||||
|
||||
/* Need macros to help set catches */
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,89 @@
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* Language Technologies Institute */
|
||||
/* Carnegie Mellon University */
|
||||
/* Copyright (c) 1999 */
|
||||
/* All Rights Reserved. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to use and distribute */
|
||||
/* this software and its documentation without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of this work, and to */
|
||||
/* permit persons to whom this work is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* 1. The code must retain the above copyright notice, this list of */
|
||||
/* conditions and the following disclaimer. */
|
||||
/* 2. Any modifications must be clearly marked as such. */
|
||||
/* 3. Original authors' names are not deleted. */
|
||||
/* 4. The authors' names are not used to endorse or promote products */
|
||||
/* derived from this software without specific prior written */
|
||||
/* permission. */
|
||||
/* */
|
||||
/* CARNEGIE MELLON UNIVERSITY AND THE CONTRIBUTORS TO THIS WORK */
|
||||
/* DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING */
|
||||
/* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT */
|
||||
/* SHALL CARNEGIE MELLON UNIVERSITY NOR THE CONTRIBUTORS BE LIABLE */
|
||||
/* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES */
|
||||
/* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN */
|
||||
/* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, */
|
||||
/* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF */
|
||||
/* THIS SOFTWARE. */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
/* Author: Alan W Black (awb@cs.cmu.edu) */
|
||||
/* Date: December 1999 */
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* feature-values lists */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
#ifndef _CST_FEATURES_H__
|
||||
#define _CST_FEATURES_H__
|
||||
|
||||
#include "cst_alloc.h"
|
||||
#include "cst_val.h"
|
||||
#include "cst_string.h"
|
||||
|
||||
typedef struct cst_featvalpair_struct {
|
||||
const char *name;
|
||||
cst_val *val;
|
||||
struct cst_featvalpair_struct *next;
|
||||
} cst_featvalpair;
|
||||
|
||||
typedef struct cst_features_struct {
|
||||
struct cst_featvalpair_struct *head;
|
||||
cst_alloc_context ctx;
|
||||
} cst_features;
|
||||
|
||||
/* Constructor functions */
|
||||
cst_features *new_features(void);
|
||||
cst_features *new_features_local(cst_alloc_context ctx);
|
||||
void delete_features(cst_features *f);
|
||||
|
||||
/* Accessor functions */
|
||||
int feat_int(const cst_features *f, const char *name);
|
||||
float feat_float(const cst_features *f, const char *name);
|
||||
const char *feat_string(const cst_features *f, const char *name);
|
||||
const cst_val *feat_val(const cst_features *f, const char *name);
|
||||
|
||||
int get_param_int(const cst_features *f, const char *name,int def);
|
||||
float get_param_float(const cst_features *f, const char *name, float def);
|
||||
const char *get_param_string(const cst_features *f, const char *name, const char *def);
|
||||
const cst_val *get_param_val(const cst_features *f, const char *name, cst_val *def);
|
||||
|
||||
/* Setting functions */
|
||||
void feat_set_int(cst_features *f, const char *name, int v);
|
||||
void feat_set_float(cst_features *f, const char *name, float v);
|
||||
void feat_set_string(cst_features *f, const char *name, const char *v);
|
||||
void feat_set(cst_features *f, const char *name,const cst_val *v);
|
||||
|
||||
int feat_remove(cst_features *f,const char *name);
|
||||
int feat_present(const cst_features *f,const char *name);
|
||||
int feat_length(const cst_features *f);
|
||||
|
||||
CST_VAL_USER_TYPE_DCLS(features,cst_features)
|
||||
|
||||
int feat_copy_into(const cst_features *from,cst_features *to);
|
||||
int feat_print(cst_file fd,const cst_features *f);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,65 @@
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* Language Technologies Institute */
|
||||
/* Carnegie Mellon University */
|
||||
/* Copyright (c) 2007 */
|
||||
/* All Rights Reserved. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to use and distribute */
|
||||
/* this software and its documentation without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of this work, and to */
|
||||
/* permit persons to whom this work is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* 1. The code must retain the above copyright notice, this list of */
|
||||
/* conditions and the following disclaimer. */
|
||||
/* 2. Any modifications must be clearly marked as such. */
|
||||
/* 3. Original authors' names are not deleted. */
|
||||
/* 4. The authors' names are not used to endorse or promote products */
|
||||
/* derived from this software without specific prior written */
|
||||
/* permission. */
|
||||
/* */
|
||||
/* CARNEGIE MELLON UNIVERSITY AND THE CONTRIBUTORS TO THIS WORK */
|
||||
/* DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING */
|
||||
/* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT */
|
||||
/* SHALL CARNEGIE MELLON UNIVERSITY NOR THE CONTRIBUTORS BE LIABLE */
|
||||
/* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES */
|
||||
/* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN */
|
||||
/* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, */
|
||||
/* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF */
|
||||
/* THIS SOFTWARE. */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
/* Author: Alan W Black (awb@cs.cmu.edu) */
|
||||
/* Date: November 2007 */
|
||||
/*************************************************************************/
|
||||
/* Language independant feature functions */
|
||||
/*************************************************************************/
|
||||
|
||||
#ifndef _CST_FFEATURES_H
|
||||
#define _CST_FFEATURES_H
|
||||
|
||||
#include "cst_val.h"
|
||||
#include "cst_item.h"
|
||||
|
||||
const cst_val *ph_vc(const cst_item *p);
|
||||
const cst_val *ph_vlng(const cst_item *p);
|
||||
const cst_val *ph_vheight(const cst_item *p);
|
||||
const cst_val *ph_vrnd(const cst_item *p);
|
||||
const cst_val *ph_vfront(const cst_item *p);
|
||||
const cst_val *ph_ctype(const cst_item *p);
|
||||
const cst_val *ph_cplace(const cst_item *p);
|
||||
const cst_val *ph_cvox(const cst_item *p);
|
||||
|
||||
const cst_val *cg_duration(const cst_item *p);
|
||||
const cst_val *cg_state_pos(const cst_item *p);
|
||||
const cst_val *cg_state_place(const cst_item *p);
|
||||
const cst_val *cg_state_index(const cst_item *p);
|
||||
const cst_val *cg_state_rindex(const cst_item *p);
|
||||
const cst_val *cg_phone_place(const cst_item *p);
|
||||
const cst_val *cg_phone_index(const cst_item *p);
|
||||
const cst_val *cg_phone_rindex(const cst_item *p);
|
||||
|
||||
void basic_ff_register(cst_features *ffunctions);
|
||||
|
||||
#endif /* _CST_FFEATURES_H */
|
||||
+170
@@ -0,0 +1,170 @@
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* Language Technologies Institute */
|
||||
/* Carnegie Mellon University */
|
||||
/* Copyright (c) 1999 */
|
||||
/* All Rights Reserved. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to use and distribute */
|
||||
/* this software and its documentation without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of this work, and to */
|
||||
/* permit persons to whom this work is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* 1. The code must retain the above copyright notice, this list of */
|
||||
/* conditions and the following disclaimer. */
|
||||
/* 2. Any modifications must be clearly marked as such. */
|
||||
/* 3. Original authors' names are not deleted. */
|
||||
/* 4. The authors' names are not used to endorse or promote products */
|
||||
/* derived from this software without specific prior written */
|
||||
/* permission. */
|
||||
/* */
|
||||
/* CARNEGIE MELLON UNIVERSITY AND THE CONTRIBUTORS TO THIS WORK */
|
||||
/* DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING */
|
||||
/* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT */
|
||||
/* SHALL CARNEGIE MELLON UNIVERSITY NOR THE CONTRIBUTORS BE LIABLE */
|
||||
/* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES */
|
||||
/* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN */
|
||||
/* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, */
|
||||
/* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF */
|
||||
/* THIS SOFTWARE. */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
/* Author: Alan W Black (awb@cs.cmu.edu) */
|
||||
/* Date: August 2000 */
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* Some File stuff */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
|
||||
/* ----------------------------------------------------------------- */
|
||||
/* The English TTS System "Flite+hts_engine" */
|
||||
/* developed by HTS Working Group */
|
||||
/* http://hts-engine.sourceforge.net/ */
|
||||
/* ----------------------------------------------------------------- */
|
||||
/* */
|
||||
/* Copyright (c) 2005-2013 Nagoya Institute of Technology */
|
||||
/* Department of Computer Science */
|
||||
/* */
|
||||
/* 2005-2008 Tokyo Institute of Technology */
|
||||
/* Interdisciplinary Graduate School of */
|
||||
/* Science and Engineering */
|
||||
/* */
|
||||
/* All rights reserved. */
|
||||
/* */
|
||||
/* Redistribution and use in source and binary forms, with or */
|
||||
/* without modification, are permitted provided that the following */
|
||||
/* conditions are met: */
|
||||
/* */
|
||||
/* - Redistributions of source code must retain the above copyright */
|
||||
/* notice, this list of conditions and the following disclaimer. */
|
||||
/* - Redistributions in binary form must reproduce the above */
|
||||
/* copyright notice, this list of conditions and the following */
|
||||
/* disclaimer in the documentation and/or other materials provided */
|
||||
/* with the distribution. */
|
||||
/* - Neither the name of the HTS working group nor the names of its */
|
||||
/* contributors may be used to endorse or promote products derived */
|
||||
/* from this software without specific prior written permission. */
|
||||
/* */
|
||||
/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND */
|
||||
/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, */
|
||||
/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF */
|
||||
/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE */
|
||||
/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS */
|
||||
/* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, */
|
||||
/* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED */
|
||||
/* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, */
|
||||
/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON */
|
||||
/* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, */
|
||||
/* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY */
|
||||
/* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */
|
||||
/* POSSIBILITY OF SUCH DAMAGE. */
|
||||
/* ----------------------------------------------------------------- */
|
||||
|
||||
#ifndef _CST_FILE_H__
|
||||
#define _CST_FILE_H__
|
||||
|
||||
#define CST_WRONG_FORMAT -2
|
||||
#define CST_ERROR_FORMAT -1
|
||||
#define CST_OK_FORMAT 0
|
||||
|
||||
#ifdef UNDER_CE
|
||||
/* File access stuff (WinCE 2.11 is really damaged) */
|
||||
#include <windows.h>
|
||||
#include <winbase.h>
|
||||
typedef HANDLE cst_file;
|
||||
#elif __palmos__
|
||||
#include <PalmOS.h>
|
||||
#include <System/StdIOPalm.h>
|
||||
typedef FILE * cst_file;
|
||||
#else
|
||||
#include <stdio.h>
|
||||
typedef FILE * cst_file;
|
||||
#endif
|
||||
|
||||
/* File mapping stuff */
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
typedef struct cst_filemap_struct {
|
||||
void *mem;
|
||||
cst_file fh;
|
||||
size_t mapsize;
|
||||
HANDLE h;
|
||||
} cst_filemap;
|
||||
#elif __palmos__
|
||||
typedef struct cst_filemap_struct {
|
||||
void *mem;
|
||||
cst_file fh;
|
||||
unsigned int mapsize;
|
||||
int fd;
|
||||
} cst_filemap;
|
||||
#else
|
||||
typedef struct cst_filemap_struct {
|
||||
void *mem;
|
||||
cst_file fh;
|
||||
size_t mapsize;
|
||||
int fd;
|
||||
} cst_filemap;
|
||||
#endif
|
||||
|
||||
#define CST_OPEN_WRITE (1<<0)
|
||||
#define CST_OPEN_READ (1<<1)
|
||||
#define CST_OPEN_APPEND (1<<2)
|
||||
#define CST_OPEN_BINARY (1<<3)
|
||||
|
||||
#define CST_SEEK_ABSOLUTE 0
|
||||
#define CST_SEEK_RELATIVE 1
|
||||
#define CST_SEEK_ENDREL 2
|
||||
|
||||
cst_file cst_fopen(const char *path, int mode);
|
||||
long cst_fwrite(cst_file fh, const void *buf, long size, long count);
|
||||
long cst_fread(cst_file fh, void *buf, long size, long count);
|
||||
int cst_fprintf(cst_file fh, char *fmt, ...);
|
||||
#ifdef FLITE_PLUS_HTS_ENGINE
|
||||
#define cst_sprintf sprintf
|
||||
#else
|
||||
int cst_sprintf(char *s, const char *fmt, ...);
|
||||
#endif /* FLITE_PLUS_HTS_ENGINE */
|
||||
#if defined(__palmos__)
|
||||
#include <stdarg.h>
|
||||
int cst_vsprintf(char *s, const char *fmt, va_list args);
|
||||
#endif
|
||||
int cst_fclose(cst_file fh);
|
||||
int cst_fgetc(cst_file fh);
|
||||
|
||||
/* These aren't LFS-compliant. I don't think we'll need >2G files. */
|
||||
long cst_ftell(cst_file fh);
|
||||
long cst_fseek(cst_file fh, long pos, int whence);
|
||||
long cst_filesize(cst_file fh);
|
||||
|
||||
cst_filemap *cst_mmap_file(const char *path);
|
||||
int cst_munmap_file(cst_filemap *map);
|
||||
|
||||
cst_filemap *cst_read_whole_file(const char *path);
|
||||
int cst_free_whole_file(cst_filemap *map);
|
||||
|
||||
cst_filemap *cst_read_part_file(const char *path);
|
||||
int cst_free_part_file(cst_filemap *map);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,50 @@
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* Language Technologies Institute */
|
||||
/* Carnegie Mellon University */
|
||||
/* Copyright (c) 1999 */
|
||||
/* All Rights Reserved. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to use and distribute */
|
||||
/* this software and its documentation without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of this work, and to */
|
||||
/* permit persons to whom this work is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* 1. The code must retain the above copyright notice, this list of */
|
||||
/* conditions and the following disclaimer. */
|
||||
/* 2. Any modifications must be clearly marked as such. */
|
||||
/* 3. Original authors' names are not deleted. */
|
||||
/* 4. The authors' names are not used to endorse or promote products */
|
||||
/* derived from this software without specific prior written */
|
||||
/* permission. */
|
||||
/* */
|
||||
/* CARNEGIE MELLON UNIVERSITY AND THE CONTRIBUTORS TO THIS WORK */
|
||||
/* DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING */
|
||||
/* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT */
|
||||
/* SHALL CARNEGIE MELLON UNIVERSITY NOR THE CONTRIBUTORS BE LIABLE */
|
||||
/* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES */
|
||||
/* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN */
|
||||
/* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, */
|
||||
/* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF */
|
||||
/* THIS SOFTWARE. */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
/* Author: Alan W Black (awb@cs.cmu.edu) */
|
||||
/* Date: December 1999 */
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* Heterogeneous Relation Graphs */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
#ifndef _CST_HRG_H__
|
||||
#define _CST_HRG_H__
|
||||
|
||||
#include "cst_file.h"
|
||||
#include "cst_val.h"
|
||||
#include "cst_features.h"
|
||||
#include "cst_item.h"
|
||||
#include "cst_relation.h"
|
||||
#include "cst_utterance.h"
|
||||
|
||||
#endif
|
||||
+135
@@ -0,0 +1,135 @@
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* Language Technologies Institute */
|
||||
/* Carnegie Mellon University */
|
||||
/* Copyright (c) 1999 */
|
||||
/* All Rights Reserved. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to use and distribute */
|
||||
/* this software and its documentation without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of this work, and to */
|
||||
/* permit persons to whom this work is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* 1. The code must retain the above copyright notice, this list of */
|
||||
/* conditions and the following disclaimer. */
|
||||
/* 2. Any modifications must be clearly marked as such. */
|
||||
/* 3. Original authors' names are not deleted. */
|
||||
/* 4. The authors' names are not used to endorse or promote products */
|
||||
/* derived from this software without specific prior written */
|
||||
/* permission. */
|
||||
/* */
|
||||
/* CARNEGIE MELLON UNIVERSITY AND THE CONTRIBUTORS TO THIS WORK */
|
||||
/* DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING */
|
||||
/* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT */
|
||||
/* SHALL CARNEGIE MELLON UNIVERSITY NOR THE CONTRIBUTORS BE LIABLE */
|
||||
/* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES */
|
||||
/* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN */
|
||||
/* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, */
|
||||
/* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF */
|
||||
/* THIS SOFTWARE. */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
/* Author: Alan W Black (awb@cs.cmu.edu) */
|
||||
/* Date: December 1999 */
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* Item */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
#ifndef _CST_ITEM_H__
|
||||
#define _CST_ITEM_H__
|
||||
|
||||
#include "cst_file.h"
|
||||
#include "cst_features.h"
|
||||
|
||||
/* Everyone needs these so forward define these */
|
||||
typedef struct cst_relation_struct cst_relation;
|
||||
typedef struct cst_utterance_struct cst_utterance;
|
||||
typedef struct cst_item_struct cst_item;
|
||||
|
||||
/* So items, relations and utterances can be used as vals */
|
||||
CST_VAL_USER_TYPE_DCLS(relation,cst_relation)
|
||||
CST_VAL_USER_TYPE_DCLS(item,cst_item)
|
||||
CST_VAL_USER_TYPE_DCLS(utterance,cst_utterance)
|
||||
|
||||
typedef struct cst_item_contents_struct {
|
||||
cst_features *features;
|
||||
cst_features *relations;
|
||||
} cst_item_contents;
|
||||
|
||||
struct cst_item_struct {
|
||||
cst_item_contents *contents; /* the shared part of an item */
|
||||
cst_relation *relation;
|
||||
cst_item *n;
|
||||
cst_item *p;
|
||||
cst_item *u;
|
||||
cst_item *d;
|
||||
};
|
||||
|
||||
/* Constructor functions */
|
||||
cst_item *new_item_relation(cst_relation *r,cst_item *i);
|
||||
cst_item_contents *new_item_contents(cst_item *i);
|
||||
|
||||
/* Remove this item from this references */
|
||||
void delete_item(cst_item *item);
|
||||
|
||||
void item_contents_set(cst_item *current, cst_item *i);
|
||||
void item_unref_contents(cst_item *i);
|
||||
|
||||
cst_item *item_as(const cst_item *i,const char *rname);
|
||||
|
||||
cst_utterance *item_utt(const cst_item *i);
|
||||
|
||||
/* List accessor/manipulator function */
|
||||
cst_item *item_next(const cst_item *i);
|
||||
cst_item *item_prev(const cst_item *i);
|
||||
|
||||
cst_item *item_append(cst_item *i,cst_item *new_item);
|
||||
cst_item *item_prepend(cst_item *i,cst_item *new_item);
|
||||
|
||||
/* Tree accessor/manipulator function */
|
||||
cst_item *item_parent(const cst_item *i);
|
||||
cst_item *item_nth_daughter(const cst_item *i,int n);
|
||||
cst_item *item_daughter(const cst_item *i);
|
||||
cst_item *item_last_daughter(const cst_item *i);
|
||||
|
||||
cst_item *item_add_daughter(cst_item *i,cst_item *new_item);
|
||||
cst_item *item_append_sibling(cst_item *i,cst_item *new_item);
|
||||
cst_item *item_prepend_sibling(cst_item *i,cst_item *new_item);
|
||||
|
||||
/* Feature accessor/manipulator functions */
|
||||
int item_feat_present(const cst_item *i,const char *name);
|
||||
int item_feat_remove(const cst_item *i,const char *name);
|
||||
cst_features *item_feats(const cst_item *i);
|
||||
const cst_val *item_feat(const cst_item *i,const char *name);
|
||||
int item_feat_int(const cst_item *i,const char *name);
|
||||
float item_feat_float(const cst_item *i,const char *name);
|
||||
const char *item_feat_string(const cst_item *i,const char *name);
|
||||
void item_set(const cst_item *i,const char *name,const cst_val *val);
|
||||
void item_set_int(const cst_item *i,const char *name,int val);
|
||||
void item_set_float(const cst_item *i,const char *name,float val);
|
||||
void item_set_string(const cst_item *i,const char *name,const char *val);
|
||||
|
||||
#define item_name(I) item_feat_string(I,"name")
|
||||
|
||||
int item_equal(const cst_item *a, const cst_item *b);
|
||||
|
||||
const char *ffeature_string(const cst_item *item,const char *featpath);
|
||||
int ffeature_int(const cst_item *item,const char *featpath);
|
||||
float ffeature_float(const cst_item *item,const char *featpath);
|
||||
const cst_val *ffeature(const cst_item *item,const char *featpath);
|
||||
cst_item* path_to_item(const cst_item *item,const char *featpath);
|
||||
|
||||
/* Feature function, for features that are derived algorithmically from others. */
|
||||
typedef const cst_val *(*cst_ffunction)(const cst_item *i);
|
||||
CST_VAL_USER_FUNCPTR_DCLS(ffunc,cst_ffunction)
|
||||
void ff_register(cst_features *ffeatures, const char *name,
|
||||
cst_ffunction f);
|
||||
void ff_unregister(cst_features *ffeatures, const char *name);
|
||||
|
||||
/* Generalized item hook function, like cst_uttfunc. */
|
||||
typedef cst_val *(*cst_itemfunc)(cst_item *i);
|
||||
CST_VAL_USER_FUNCPTR_DCLS(itemfunc,cst_itemfunc)
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,87 @@
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* Language Technologies Institute */
|
||||
/* Carnegie Mellon University */
|
||||
/* Copyright (c) 1999 */
|
||||
/* All Rights Reserved. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to use and distribute */
|
||||
/* this software and its documentation without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of this work, and to */
|
||||
/* permit persons to whom this work is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* 1. The code must retain the above copyright notice, this list of */
|
||||
/* conditions and the following disclaimer. */
|
||||
/* 2. Any modifications must be clearly marked as such. */
|
||||
/* 3. Original authors' names are not deleted. */
|
||||
/* 4. The authors' names are not used to endorse or promote products */
|
||||
/* derived from this software without specific prior written */
|
||||
/* permission. */
|
||||
/* */
|
||||
/* CARNEGIE MELLON UNIVERSITY AND THE CONTRIBUTORS TO THIS WORK */
|
||||
/* DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING */
|
||||
/* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT */
|
||||
/* SHALL CARNEGIE MELLON UNIVERSITY NOR THE CONTRIBUTORS BE LIABLE */
|
||||
/* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES */
|
||||
/* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN */
|
||||
/* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, */
|
||||
/* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF */
|
||||
/* THIS SOFTWARE. */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
/* Author: Alan W Black (awb@cs.cmu.edu) */
|
||||
/* Date: December 1999 */
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* Lexicon related functions */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
#ifndef _CST_LEXICON_H__
|
||||
#define _CST_LEXICON_H__
|
||||
|
||||
#include "cst_item.h"
|
||||
#include "cst_lts.h"
|
||||
|
||||
typedef struct lexicon_struct {
|
||||
char *name;
|
||||
int num_entries;
|
||||
/* Entries are centered around bytes with value 255 */
|
||||
/* entries and forward (compressed) pronunciations and backwards */
|
||||
/* each are terminated (preceeded in pron case) by 0 */
|
||||
/* This saves 4 bytes per entry for an index */
|
||||
unsigned char *data; /* the entries and phone strings */
|
||||
int num_bytes; /* the number of bytes in the data */
|
||||
char **phone_table;
|
||||
|
||||
cst_lts_rules *lts_rule_set;
|
||||
|
||||
int (*syl_boundary)(const cst_item *i,const cst_val *p);
|
||||
|
||||
cst_val *(*lts_function)(const struct lexicon_struct *l, const char *word, const char *pos);
|
||||
|
||||
char ***addenda;
|
||||
/* ngram frequency table used for packed entries */
|
||||
const char * const *phone_hufftable;
|
||||
const char * const *entry_hufftable;
|
||||
|
||||
cst_utterance *(*postlex)(cst_utterance *u);
|
||||
|
||||
cst_val *lex_addenda; /* For pronunciations added at run time */
|
||||
|
||||
} cst_lexicon;
|
||||
|
||||
cst_lexicon *new_lexicon();
|
||||
void delete_lexicon(cst_lexicon *lex);
|
||||
|
||||
cst_val *cst_lex_make_entry(const cst_lexicon *lex,
|
||||
const cst_string *entry);
|
||||
cst_val *cst_lex_load_addenda(const cst_lexicon *lex,
|
||||
const char *lexfile);
|
||||
|
||||
cst_val *lex_lookup(const cst_lexicon *l, const char *word, const char *pos);
|
||||
int in_lex(const cst_lexicon *l, const char *word, const char *pos);
|
||||
|
||||
CST_VAL_USER_TYPE_DCLS(lexicon,cst_lexicon)
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,78 @@
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* Language Technologies Institute */
|
||||
/* Carnegie Mellon University */
|
||||
/* Copyright (c) 1999 */
|
||||
/* All Rights Reserved. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to use and distribute */
|
||||
/* this software and its documentation without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of this work, and to */
|
||||
/* permit persons to whom this work is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* 1. The code must retain the above copyright notice, this list of */
|
||||
/* conditions and the following disclaimer. */
|
||||
/* 2. Any modifications must be clearly marked as such. */
|
||||
/* 3. Original authors' names are not deleted. */
|
||||
/* 4. The authors' names are not used to endorse or promote products */
|
||||
/* derived from this software without specific prior written */
|
||||
/* permission. */
|
||||
/* */
|
||||
/* CARNEGIE MELLON UNIVERSITY AND THE CONTRIBUTORS TO THIS WORK */
|
||||
/* DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING */
|
||||
/* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT */
|
||||
/* SHALL CARNEGIE MELLON UNIVERSITY NOR THE CONTRIBUTORS BE LIABLE */
|
||||
/* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES */
|
||||
/* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN */
|
||||
/* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, */
|
||||
/* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF */
|
||||
/* THIS SOFTWARE. */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
/* Author: Alan W Black (awb@cs.cmu.edu) */
|
||||
/* Date: December 1999 */
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* Letter to sound rules */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
#ifndef _CST_LTS_H__
|
||||
#define _CST_LTS_H__
|
||||
|
||||
#include "cst_val.h"
|
||||
|
||||
typedef unsigned short cst_lts_addr;
|
||||
typedef int cst_lts_phone;
|
||||
typedef unsigned char cst_lts_feat;
|
||||
typedef unsigned char cst_lts_letter;
|
||||
typedef unsigned char cst_lts_model;
|
||||
|
||||
/* end of rule value */
|
||||
#define CST_LTS_EOR 255
|
||||
|
||||
typedef struct cst_lts_rules_struct {
|
||||
char *name;
|
||||
const cst_lts_addr *letter_index; /* index into model first state */
|
||||
const cst_lts_model *models;
|
||||
const char * const * phone_table;
|
||||
int context_window_size;
|
||||
int context_extra_feats;
|
||||
const char * const * letter_table;
|
||||
} cst_lts_rules;
|
||||
|
||||
/* Note this is designed to be 6 bytes */
|
||||
typedef struct cst_lts_rule_struct {
|
||||
cst_lts_feat feat;
|
||||
cst_lts_letter val;
|
||||
cst_lts_addr qtrue;
|
||||
cst_lts_addr qfalse;
|
||||
} cst_lts_rule;
|
||||
|
||||
cst_lts_rules *new_lts_rules();
|
||||
|
||||
cst_val *lts_apply(const char *word,const char *feats,const cst_lts_rules *r);
|
||||
cst_val *lts_apply_val(const cst_val *wlist,const char *feats,const cst_lts_rules *r);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* Language Technologies Institute */
|
||||
/* Carnegie Mellon University */
|
||||
/* Copyright (c) 2002 */
|
||||
/* All Rights Reserved. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to use and distribute */
|
||||
/* this software and its documentation without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of this work, and to */
|
||||
/* permit persons to whom this work is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* 1. The code must retain the above copyright notice, this list of */
|
||||
/* conditions and the following disclaimer. */
|
||||
/* 2. Any modifications must be clearly marked as such. */
|
||||
/* 3. Original authors' names are not deleted. */
|
||||
/* 4. The authors' names are not used to endorse or promote products */
|
||||
/* derived from this software without specific prior written */
|
||||
/* permission. */
|
||||
/* */
|
||||
/* CARNEGIE MELLON UNIVERSITY AND THE CONTRIBUTORS TO THIS WORK */
|
||||
/* DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING */
|
||||
/* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT */
|
||||
/* SHALL CARNEGIE MELLON UNIVERSITY NOR THE CONTRIBUTORS BE LIABLE */
|
||||
/* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES */
|
||||
/* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN */
|
||||
/* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, */
|
||||
/* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF */
|
||||
/* THIS SOFTWARE. */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
/* Author: Alan W Black (awb@cs.cmu.edu) */
|
||||
/* Date: August 2002 */
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* Letter to sound rewrite rules */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
#ifndef _CST_LTS_REWRITES_H__
|
||||
#define _CST_LTS_REWRITES_H__
|
||||
|
||||
#include "cst_val.h"
|
||||
|
||||
typedef struct cst_lts_rewrites_struct {
|
||||
char *name;
|
||||
const cst_val *sets;
|
||||
const cst_val *rules;
|
||||
} cst_lts_rewrites;
|
||||
|
||||
cst_val *lts_rewrites(const cst_val *itape, const cst_lts_rewrites *r);
|
||||
cst_val *lts_rewrites_word(const char *word, const cst_lts_rewrites *r);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* Language Technologies Institute */
|
||||
/* Carnegie Mellon University */
|
||||
/* Copyright (c) 2004 */
|
||||
/* All Rights Reserved. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to use and distribute */
|
||||
/* this software and its documentation without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of this work, and to */
|
||||
/* permit persons to whom this work is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* 1. The code must retain the above copyright notice, this list of */
|
||||
/* conditions and the following disclaimer. */
|
||||
/* 2. Any modifications must be clearly marked as such. */
|
||||
/* 3. Original authors' names are not deleted. */
|
||||
/* 4. The authors' names are not used to endorse or promote products */
|
||||
/* derived from this software without specific prior written */
|
||||
/* permission. */
|
||||
/* */
|
||||
/* CARNEGIE MELLON UNIVERSITY AND THE CONTRIBUTORS TO THIS WORK */
|
||||
/* DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING */
|
||||
/* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT */
|
||||
/* SHALL CARNEGIE MELLON UNIVERSITY NOR THE CONTRIBUTORS BE LIABLE */
|
||||
/* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES */
|
||||
/* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN */
|
||||
/* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, */
|
||||
/* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF */
|
||||
/* THIS SOFTWARE. */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
/* Author: Alan W Black (awb@cs.cmu.edu) */
|
||||
/* Date: July 2004 */
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* Math wrapper */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
#ifndef _CST_MATH_H__
|
||||
#define _CST_MATH_H__
|
||||
|
||||
#if __palmos__
|
||||
/* Sun Microsystem's Free fdlibm */
|
||||
/* We actually don't use it but it allows the system to compile */
|
||||
/* #include <fdlibm.h> */
|
||||
#else
|
||||
#include <math.h>
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,76 @@
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* Language Technologies Institute */
|
||||
/* Carnegie Mellon University */
|
||||
/* Copyright (c) 1999 */
|
||||
/* All Rights Reserved. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to use and distribute */
|
||||
/* this software and its documentation without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of this work, and to */
|
||||
/* permit persons to whom this work is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* 1. The code must retain the above copyright notice, this list of */
|
||||
/* conditions and the following disclaimer. */
|
||||
/* 2. Any modifications must be clearly marked as such. */
|
||||
/* 3. Original authors' names are not deleted. */
|
||||
/* 4. The authors' names are not used to endorse or promote products */
|
||||
/* derived from this software without specific prior written */
|
||||
/* permission. */
|
||||
/* */
|
||||
/* CARNEGIE MELLON UNIVERSITY AND THE CONTRIBUTORS TO THIS WORK */
|
||||
/* DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING */
|
||||
/* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT */
|
||||
/* SHALL CARNEGIE MELLON UNIVERSITY NOR THE CONTRIBUTORS BE LIABLE */
|
||||
/* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES */
|
||||
/* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN */
|
||||
/* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, */
|
||||
/* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF */
|
||||
/* THIS SOFTWARE. */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
/* Author: Alan W Black (awb@cs.cmu.edu) */
|
||||
/* Date: December 2000 */
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* Phoneset functions */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
#ifndef _CST_PHONESET_H__
|
||||
#define _CST_PHONESET_H__
|
||||
|
||||
#include "cst_file.h"
|
||||
#include "cst_val.h"
|
||||
#include "cst_features.h"
|
||||
#include "cst_item.h"
|
||||
|
||||
struct cst_phoneset_struct {
|
||||
const char *name;
|
||||
const char * const * featnames;
|
||||
const cst_val * const *featvals;
|
||||
const char * const * phonenames;
|
||||
const char *silence;
|
||||
const int num_phones;
|
||||
const int * const * fvtable;
|
||||
};
|
||||
typedef struct cst_phoneset_struct cst_phoneset;
|
||||
|
||||
/* Constructor functions */
|
||||
cst_phoneset *new_phoneset();
|
||||
void delete_phoneset(cst_phoneset *u);
|
||||
|
||||
const cst_val *phone_feature(const cst_phoneset *ps,
|
||||
const char* phonename,
|
||||
const char *featname);
|
||||
const char *phone_feature_string(const cst_phoneset *ps,
|
||||
const char* phonename,
|
||||
const char *featname);
|
||||
int phone_id(const cst_phoneset *ps,const char* phonename);
|
||||
int phone_feat_id(const cst_phoneset *ps,const char* featname);
|
||||
|
||||
const cst_phoneset *item_phoneset(const cst_item *i);
|
||||
|
||||
CST_VAL_USER_TYPE_DCLS(phoneset,cst_phoneset)
|
||||
|
||||
#endif
|
||||
+160
@@ -0,0 +1,160 @@
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* Language Technologies Institute */
|
||||
/* Carnegie Mellon University */
|
||||
/* Copyright (c) 1999 */
|
||||
/* All Rights Reserved. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to use and distribute */
|
||||
/* this software and its documentation without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of this work, and to */
|
||||
/* permit persons to whom this work is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* 1. The code must retain the above copyright notice, this list of */
|
||||
/* conditions and the following disclaimer. */
|
||||
/* 2. Any modifications must be clearly marked as such. */
|
||||
/* 3. Original authors' names are not deleted. */
|
||||
/* 4. The authors' names are not used to endorse or promote products */
|
||||
/* derived from this software without specific prior written */
|
||||
/* permission. */
|
||||
/* */
|
||||
/* CARNEGIE MELLON UNIVERSITY AND THE CONTRIBUTORS TO THIS WORK */
|
||||
/* DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING */
|
||||
/* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT */
|
||||
/* SHALL CARNEGIE MELLON UNIVERSITY NOR THE CONTRIBUTORS BE LIABLE */
|
||||
/* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES */
|
||||
/* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN */
|
||||
/* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, */
|
||||
/* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF */
|
||||
/* THIS SOFTWARE. */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
/* Author: Alan W Black (awb@cs.cmu.edu) */
|
||||
/* Date: January 2000 */
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* cst front-end to Henry Spencer's regex code */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
|
||||
/* Includes portions or regexp.h, copyright follows: */
|
||||
/*
|
||||
* Copyright (c) 1986 by University of Toronto.
|
||||
* Copyright (c) 1989, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley
|
||||
* by Henry Spencer.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)regexp.h 8.1 (Berkeley) 6/2/93
|
||||
*/
|
||||
|
||||
#ifndef _CST_REGEX_H__
|
||||
#define _CST_REGEX_H__
|
||||
|
||||
#include "cst_file.h"
|
||||
#include "cst_string.h"
|
||||
|
||||
/*
|
||||
* The first byte of the regexp internal "program" is actually this magic
|
||||
* number; the start node begins in the second byte.
|
||||
*/
|
||||
#define CST_REGMAGIC 0234
|
||||
|
||||
typedef struct cst_regex_struct {
|
||||
char regstart; /* Internal use only. */
|
||||
char reganch; /* Internal use only. */
|
||||
char *regmust; /* Internal use only. */
|
||||
int regmlen; /* Internal use only. */
|
||||
int regsize;
|
||||
char *program;
|
||||
} cst_regex;
|
||||
|
||||
#define CST_NSUBEXP 10
|
||||
typedef struct cst_regstate_struct {
|
||||
const char *startp[CST_NSUBEXP];
|
||||
const char *endp[CST_NSUBEXP];
|
||||
const char *input;
|
||||
const char *bol;
|
||||
} cst_regstate;
|
||||
|
||||
cst_regex *new_cst_regex(const char *str);
|
||||
void delete_cst_regex(cst_regex *r);
|
||||
|
||||
int cst_regex_match(const cst_regex *r, const char *str);
|
||||
cst_regstate *cst_regex_match_return(const cst_regex *r, const char *str);
|
||||
|
||||
/* Internal functions from original HS code */
|
||||
cst_regex *hs_regcomp(const char *);
|
||||
cst_regstate *hs_regexec(const cst_regex *, const char *);
|
||||
void hs_regdelete(cst_regex *);
|
||||
|
||||
/* Works similarly to snprintf(3), in that at most max characters are
|
||||
written to out, including the trailing NUL, and the return value is
|
||||
the number of characters written, *excluding* the trailing NUL.
|
||||
Also works similarly to wcstombs(3) in that passing NULL as out
|
||||
will count the number of characters that would be written without
|
||||
doing any actual conversion, and ignoring max. So, you could use
|
||||
it like this:
|
||||
|
||||
rx = new_cst_regex("\\(.*\\)_\\(.*\\)");
|
||||
if ((rs = cst_regex_match_return(rx, "foo_bar")) != NULL) {
|
||||
size_t n;
|
||||
|
||||
n = cst_regsub(rs, "\\1_\\2_quux", NULL, 0) + 1;
|
||||
out = cst_alloc(char, n);
|
||||
cst_regsub(rs, "\\1_\\2_quux", out, n);
|
||||
} */
|
||||
size_t cst_regsub(const cst_regstate *r, const char *in, char *out, size_t max);
|
||||
|
||||
/* Initialize the regex engine and global regex constants */
|
||||
void cst_regex_init();
|
||||
|
||||
/* Regexps used in text processing (these are latin-alphabet specific
|
||||
and to some extent US English-specific) */
|
||||
extern const cst_regex * const cst_rx_white;
|
||||
extern const cst_regex * const cst_rx_alpha;
|
||||
extern const cst_regex * const cst_rx_uppercase;
|
||||
extern const cst_regex * const cst_rx_lowercase;
|
||||
extern const cst_regex * const cst_rx_alphanum;
|
||||
extern const cst_regex * const cst_rx_identifier;
|
||||
extern const cst_regex * const cst_rx_int;
|
||||
extern const cst_regex * const cst_rx_double;
|
||||
extern const cst_regex * const cst_rx_commaint;
|
||||
extern const cst_regex * const cst_rx_digits;
|
||||
extern const cst_regex * const cst_rx_dotted_abbrev;
|
||||
|
||||
/* Table of regexps used in CART trees (only one so far) */
|
||||
extern const cst_regex * const cst_regex_table[];
|
||||
#define CST_RX_dotted_abbrev_NUM 0
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,72 @@
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* Language Technologies Institute */
|
||||
/* Carnegie Mellon University */
|
||||
/* Copyright (c) 1999 */
|
||||
/* All Rights Reserved. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to use and distribute */
|
||||
/* this software and its documentation without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of this work, and to */
|
||||
/* permit persons to whom this work is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* 1. The code must retain the above copyright notice, this list of */
|
||||
/* conditions and the following disclaimer. */
|
||||
/* 2. Any modifications must be clearly marked as such. */
|
||||
/* 3. Original authors' names are not deleted. */
|
||||
/* 4. The authors' names are not used to endorse or promote products */
|
||||
/* derived from this software without specific prior written */
|
||||
/* permission. */
|
||||
/* */
|
||||
/* CARNEGIE MELLON UNIVERSITY AND THE CONTRIBUTORS TO THIS WORK */
|
||||
/* DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING */
|
||||
/* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT */
|
||||
/* SHALL CARNEGIE MELLON UNIVERSITY NOR THE CONTRIBUTORS BE LIABLE */
|
||||
/* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES */
|
||||
/* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN */
|
||||
/* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, */
|
||||
/* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF */
|
||||
/* THIS SOFTWARE. */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
/* Author: Alan W Black (awb@cs.cmu.edu) */
|
||||
/* Date: December 1999 */
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* Relation */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
#ifndef _CST_RELATION_H__
|
||||
#define _CST_RELATION_H__
|
||||
|
||||
#include "cst_file.h"
|
||||
#include "cst_val.h"
|
||||
#include "cst_features.h"
|
||||
#include "cst_item.h"
|
||||
#include "cst_utterance.h"
|
||||
|
||||
struct cst_relation_struct {
|
||||
char *name;
|
||||
cst_features *features;
|
||||
cst_utterance *utterance;
|
||||
cst_item *head;
|
||||
cst_item *tail;
|
||||
};
|
||||
|
||||
/* Constructor functions */
|
||||
cst_relation *new_relation(const char *name, cst_utterance *u);
|
||||
|
||||
void delete_relation(cst_relation *r);
|
||||
|
||||
cst_item *relation_head(cst_relation *r);
|
||||
cst_item *relation_tail(cst_relation *r);
|
||||
const char *relation_name(cst_relation *r);
|
||||
|
||||
cst_item *relation_append(cst_relation *r,cst_item *i);
|
||||
cst_item *relation_prepend(cst_relation *r,cst_item *i);
|
||||
|
||||
int relation_load(cst_relation *r, const char *filename);
|
||||
int relation_save(cst_relation *r, const char *filename);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,51 @@
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* Language Technologies Institute */
|
||||
/* Carnegie Mellon University */
|
||||
/* Copyright (c) 2001 */
|
||||
/* All Rights Reserved. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to use and distribute */
|
||||
/* this software and its documentation without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of this work, and to */
|
||||
/* permit persons to whom this work is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* 1. The code must retain the above copyright notice, this list of */
|
||||
/* conditions and the following disclaimer. */
|
||||
/* 2. Any modifications must be clearly marked as such. */
|
||||
/* 3. Original authors' names are not deleted. */
|
||||
/* 4. The authors' names are not used to endorse or promote products */
|
||||
/* derived from this software without specific prior written */
|
||||
/* permission. */
|
||||
/* */
|
||||
/* CARNEGIE MELLON UNIVERSITY AND THE CONTRIBUTORS TO THIS WORK */
|
||||
/* DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING */
|
||||
/* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT */
|
||||
/* SHALL CARNEGIE MELLON UNIVERSITY NOR THE CONTRIBUTORS BE LIABLE */
|
||||
/* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES */
|
||||
/* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN */
|
||||
/* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, */
|
||||
/* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF */
|
||||
/* THIS SOFTWARE. */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
/* Author: Alan W Black (awb@cs.cmu.edu) */
|
||||
/* Date: January 2001 */
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* Signal processing */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
#ifndef _CST_SIGPR_H__
|
||||
#define _CST_SIGPR_H__
|
||||
|
||||
#include "cst_file.h"
|
||||
#include "cst_val.h"
|
||||
#include "cst_sts.h"
|
||||
|
||||
cst_wave *lpc_resynth(cst_lpcres *lpcres);
|
||||
cst_wave *lpc_resynth_fixedpoint(cst_lpcres *lpcres);
|
||||
cst_wave *lpc_resynth_spike(cst_lpcres *lpcres);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,49 @@
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* Language Technologies Institute */
|
||||
/* Carnegie Mellon University */
|
||||
/* Copyright (c) 2000 */
|
||||
/* All Rights Reserved. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to use and distribute */
|
||||
/* this software and its documentation without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of this work, and to */
|
||||
/* permit persons to whom this work is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* 1. The code must retain the above copyright notice, this list of */
|
||||
/* conditions and the following disclaimer. */
|
||||
/* 2. Any modifications must be clearly marked as such. */
|
||||
/* 3. Original authors' names are not deleted. */
|
||||
/* 4. The authors' names are not used to endorse or promote products */
|
||||
/* derived from this software without specific prior written */
|
||||
/* permission. */
|
||||
/* */
|
||||
/* CARNEGIE MELLON UNIVERSITY AND THE CONTRIBUTORS TO THIS WORK */
|
||||
/* DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING */
|
||||
/* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT */
|
||||
/* SHALL CARNEGIE MELLON UNIVERSITY NOR THE CONTRIBUTORS BE LIABLE */
|
||||
/* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES */
|
||||
/* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN */
|
||||
/* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, */
|
||||
/* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF */
|
||||
/* THIS SOFTWARE. */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
/* Author: Alan W Black (awb@cs.cmu.edu) */
|
||||
/* Date: October 2000 */
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* General Socket code */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
#ifndef _CST_SOCKET_H__
|
||||
#define _CST_SOCKET_H__
|
||||
|
||||
int cst_socket_open(const char *host, int port);
|
||||
int cst_socket_close(int socket);
|
||||
|
||||
int cst_socket_server(const char *name, int port,
|
||||
int (process_client)(int name, int fd));
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,58 @@
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* Language Technologies Institute */
|
||||
/* Carnegie Mellon University */
|
||||
/* Copyright (c) 2001 */
|
||||
/* All Rights Reserved. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to use and distribute */
|
||||
/* this software and its documentation without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of this work, and to */
|
||||
/* permit persons to whom this work is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* 1. The code must retain the above copyright notice, this list of */
|
||||
/* conditions and the following disclaimer. */
|
||||
/* 2. Any modifications must be clearly marked as such. */
|
||||
/* 3. Original authors' names are not deleted. */
|
||||
/* 4. The authors' names are not used to endorse or promote products */
|
||||
/* derived from this software without specific prior written */
|
||||
/* permission. */
|
||||
/* */
|
||||
/* CARNEGIE MELLON UNIVERSITY AND THE CONTRIBUTORS TO THIS WORK */
|
||||
/* DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING */
|
||||
/* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT */
|
||||
/* SHALL CARNEGIE MELLON UNIVERSITY NOR THE CONTRIBUTORS BE LIABLE */
|
||||
/* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES */
|
||||
/* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN */
|
||||
/* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, */
|
||||
/* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF */
|
||||
/* THIS SOFTWARE. */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
/* Author: Alan W Black (awb@cs.cmu.edu) */
|
||||
/* Date: November 2001 */
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* sufficient statitsics */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
#ifndef _CST_SS_H__
|
||||
#define _CST_SS_H__
|
||||
|
||||
typedef struct cst_ss_struct {
|
||||
double num_samples;
|
||||
double sum;
|
||||
double sumx;
|
||||
} cst_ss;
|
||||
|
||||
cst_ss *new_ss();
|
||||
void delete_ss(cst_ss *ss);
|
||||
void ss_reset(cst_ss *ss);
|
||||
double ss_mean(cst_ss *ss);
|
||||
double ss_variance(cst_ss *ss);
|
||||
double ss_stddev(cst_ss *ss);
|
||||
void ss_cummulate(cst_ss *ss,double a);
|
||||
void ss_cummulate_n(cst_ss *ss,double a, double count);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,72 @@
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* Language Technologies Institute */
|
||||
/* Carnegie Mellon University */
|
||||
/* Copyright (c) 1999 */
|
||||
/* All Rights Reserved. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to use and distribute */
|
||||
/* this software and its documentation without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of this work, and to */
|
||||
/* permit persons to whom this work is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* 1. The code must retain the above copyright notice, this list of */
|
||||
/* conditions and the following disclaimer. */
|
||||
/* 2. Any modifications must be clearly marked as such. */
|
||||
/* 3. Original authors' names are not deleted. */
|
||||
/* 4. The authors' names are not used to endorse or promote products */
|
||||
/* derived from this software without specific prior written */
|
||||
/* permission. */
|
||||
/* */
|
||||
/* CARNEGIE MELLON UNIVERSITY AND THE CONTRIBUTORS TO THIS WORK */
|
||||
/* DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING */
|
||||
/* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT */
|
||||
/* SHALL CARNEGIE MELLON UNIVERSITY NOR THE CONTRIBUTORS BE LIABLE */
|
||||
/* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES */
|
||||
/* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN */
|
||||
/* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, */
|
||||
/* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF */
|
||||
/* THIS SOFTWARE. */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
/* Author: Alan W Black (awb@cs.cmu.edu) */
|
||||
/* Date: December 1999 */
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* String manipulation functions */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
#ifndef __CST_STRING_H__
|
||||
#define __CST_STRING_H__
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#if defined(UNDER_CE) && (UNDER_CE < 300)
|
||||
#define isalnum(a) iswalnum((wint_t)(a))
|
||||
#define isupper(a) iswupper((wint_t)(a))
|
||||
#define islower(a) iswlower((wint_t)(a))
|
||||
#endif
|
||||
|
||||
/* typedef unsigned char cst_string; */
|
||||
typedef char cst_string;
|
||||
|
||||
double cst_atof(const char *str);
|
||||
|
||||
cst_string *cst_strdup(const cst_string *s);
|
||||
cst_string *cst_strchr(const cst_string *s, int c);
|
||||
cst_string *cst_strrchr(const cst_string *str, int c);
|
||||
#define cst_strstr(h,n) \
|
||||
((cst_string *)strstr((const char *)h,(const char *)n))
|
||||
#define cst_strlen(s) (strlen((const char *)s))
|
||||
#define cst_streq(A,B) (strcmp(A,B) == 0)
|
||||
#define cst_streqn(A,B,N) (strncmp(A,B,N) == 0)
|
||||
int cst_member_string(const char *str, const char * const *slist);
|
||||
char *cst_substr(const char *str,int start, int length);
|
||||
|
||||
char *cst_string_before(const char *s,const char *c);
|
||||
|
||||
cst_string *cst_downcase(const cst_string *str);
|
||||
cst_string *cst_upcase(const cst_string *str);
|
||||
|
||||
#endif
|
||||
+127
@@ -0,0 +1,127 @@
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* Language Technologies Institute */
|
||||
/* Carnegie Mellon University */
|
||||
/* Copyright (c) 2001 */
|
||||
/* All Rights Reserved. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to use and distribute */
|
||||
/* this software and its documentation without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of this work, and to */
|
||||
/* permit persons to whom this work is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* 1. The code must retain the above copyright notice, this list of */
|
||||
/* conditions and the following disclaimer. */
|
||||
/* 2. Any modifications must be clearly marked as such. */
|
||||
/* 3. Original authors' names are not deleted. */
|
||||
/* 4. The authors' names are not used to endorse or promote products */
|
||||
/* derived from this software without specific prior written */
|
||||
/* permission. */
|
||||
/* */
|
||||
/* CARNEGIE MELLON UNIVERSITY AND THE CONTRIBUTORS TO THIS WORK */
|
||||
/* DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING */
|
||||
/* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT */
|
||||
/* SHALL CARNEGIE MELLON UNIVERSITY NOR THE CONTRIBUTORS BE LIABLE */
|
||||
/* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES */
|
||||
/* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN */
|
||||
/* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, */
|
||||
/* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF */
|
||||
/* THIS SOFTWARE. */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
/* Author: Alan W Black (awb@cs.cmu.edu) */
|
||||
/* Date: January 2001 */
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* Short term signals */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
#ifndef _CST_STS_H__
|
||||
#define _CST_STS_H__
|
||||
|
||||
/* Need some lower level functions in case we are doing streaming */
|
||||
#include "cst_wave.h"
|
||||
#include "cst_audio.h"
|
||||
|
||||
/* The short term signal (sts) structure is the basic unit data info */
|
||||
/* it may be diphones or general units. Indexes and names are held */
|
||||
/* else where, this information plus the indexes in the Unit relation */
|
||||
/* allow reconstruction of the signal itself */
|
||||
struct cst_sts_struct {
|
||||
const unsigned short *frame;
|
||||
const int size; /* in samples */
|
||||
const unsigned char *residual;
|
||||
};
|
||||
typedef struct cst_sts_struct cst_sts;
|
||||
|
||||
/* Because many C compilers can't compile when there are 100Ks of symbols */
|
||||
/* We store the sts in pages. Each page of stss gets compiled into an */
|
||||
/* array in separate files thus reducing the number of symbols -- but */
|
||||
/* introducing an extra dereference */
|
||||
struct cst_sts_paged_struct {
|
||||
const unsigned short frame_offset;
|
||||
const unsigned short res_size;
|
||||
const unsigned int res_offset;
|
||||
const unsigned short *frame_page;
|
||||
const unsigned char *res_page;
|
||||
};
|
||||
typedef struct cst_sts_paged_struct cst_sts_paged;
|
||||
|
||||
/* This represents a database of short-term signals. */
|
||||
struct cst_sts_list_struct {
|
||||
/* If the sts are compiled in, this will point to them. */
|
||||
const cst_sts *sts;
|
||||
/* Or if the data is paged in different structures */
|
||||
const cst_sts_paged *sts_paged;
|
||||
/* Or we could have these set (or set later) */
|
||||
const unsigned short *frames;
|
||||
const unsigned char *residuals;
|
||||
const unsigned int *resoffs;
|
||||
|
||||
int num_sts; /* But I don't think you need that number */
|
||||
int num_channels; /* typically lpc order */
|
||||
int sample_rate;
|
||||
float coeff_min; /* used for decoding the short representation */
|
||||
float coeff_range; /* for coefficients */
|
||||
};
|
||||
typedef struct cst_sts_list_struct cst_sts_list;
|
||||
|
||||
/* This is used to represent a newly constructed waveform to be synthed */
|
||||
struct cst_lpcres_struct {
|
||||
const unsigned short **frames;
|
||||
int *times;
|
||||
int num_frames;
|
||||
int num_channels;
|
||||
float lpc_min;
|
||||
float lpc_range;
|
||||
int num_samples;
|
||||
int sample_rate;
|
||||
int *sizes;
|
||||
unsigned char *residual;
|
||||
|
||||
/* Optional call back function */
|
||||
cst_audio_streaming_info *asi;
|
||||
};
|
||||
typedef struct cst_lpcres_struct cst_lpcres;
|
||||
|
||||
cst_lpcres *new_lpcres();
|
||||
void delete_lpcres(cst_lpcres *l);
|
||||
float lpcres_frame_shift(cst_lpcres *t, int frame);
|
||||
void lpcres_resize_frames(cst_lpcres *l,int num_frames);
|
||||
void lpcres_resize_samples(cst_lpcres *l,int num_samples);
|
||||
|
||||
cst_sts_list *new_sts_list();
|
||||
void delete_sts_list(cst_sts_list *l);
|
||||
|
||||
const unsigned short * get_sts_frame(const cst_sts_list *sts_list, int frame);
|
||||
const unsigned char * get_sts_residual(const cst_sts_list *sts_list, int frame);
|
||||
const unsigned char * get_sts_residual_fixed(const cst_sts_list *sts_list, int frame);
|
||||
|
||||
int get_frame_size(const cst_sts_list *sts_list, int frame);
|
||||
int get_unit_size(const cst_sts_list *s,int start, int end);
|
||||
|
||||
CST_VAL_USER_TYPE_DCLS(lpcres,cst_lpcres)
|
||||
CST_VAL_USER_TYPE_DCLS(sts_list,cst_sts_list)
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,93 @@
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* Language Technologies Institute */
|
||||
/* Carnegie Mellon University */
|
||||
/* Copyright (c) 2000 */
|
||||
/* All Rights Reserved. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to use and distribute */
|
||||
/* this software and its documentation without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of this work, and to */
|
||||
/* permit persons to whom this work is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* 1. The code must retain the above copyright notice, this list of */
|
||||
/* conditions and the following disclaimer. */
|
||||
/* 2. Any modifications must be clearly marked as such. */
|
||||
/* 3. Original authors' names are not deleted. */
|
||||
/* 4. The authors' names are not used to endorse or promote products */
|
||||
/* derived from this software without specific prior written */
|
||||
/* permission. */
|
||||
/* */
|
||||
/* CARNEGIE MELLON UNIVERSITY AND THE CONTRIBUTORS TO THIS WORK */
|
||||
/* DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING */
|
||||
/* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT */
|
||||
/* SHALL CARNEGIE MELLON UNIVERSITY NOR THE CONTRIBUTORS BE LIABLE */
|
||||
/* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES */
|
||||
/* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN */
|
||||
/* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, */
|
||||
/* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF */
|
||||
/* THIS SOFTWARE. */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
/* Author: Alan W Black (awb@cs.cmu.edu) */
|
||||
/* Date: September 2000 */
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* General synth functions */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
#ifndef _SYNTH_H__
|
||||
#define _SYNTH_H__
|
||||
|
||||
#include "cst_hrg.h"
|
||||
#include "cst_tokenstream.h"
|
||||
#include "cst_voice.h"
|
||||
|
||||
typedef int (*cst_breakfunc)(cst_tokenstream *ts,
|
||||
const char *token,
|
||||
cst_relation *tokens);
|
||||
CST_VAL_USER_FUNCPTR_DCLS(breakfunc,cst_breakfunc)
|
||||
int default_utt_break(cst_tokenstream *ts,
|
||||
const char *token, cst_relation *tokens);
|
||||
|
||||
/* You must call utt_init before any of the others. */
|
||||
cst_utterance *utt_init(cst_utterance *u, cst_voice *vox);
|
||||
cst_utterance *utt_synth(cst_utterance *u);
|
||||
cst_utterance *utt_synth_phones(cst_utterance *u);
|
||||
cst_utterance *utt_synth_tokens(cst_utterance *u);
|
||||
|
||||
typedef struct cst_dur_stats_struct {
|
||||
char *phone;
|
||||
float mean;
|
||||
float stddev;
|
||||
} dur_stat;
|
||||
typedef dur_stat *dur_stats; /* only one star, due to funky cst_val magic */
|
||||
CST_VAL_USER_TYPE_DCLS(dur_stats,dur_stats)
|
||||
|
||||
cst_utterance *default_segmentanalysis(cst_utterance *u);
|
||||
|
||||
cst_utterance *default_tokenization(cst_utterance *u);
|
||||
cst_utterance *default_textanalysis(cst_utterance *u);
|
||||
cst_val *default_tokentowords(cst_item *i);
|
||||
cst_utterance *default_phrasing(cst_utterance *u);
|
||||
cst_utterance *default_pos_tagger(cst_utterance *u);
|
||||
cst_utterance *default_lexical_insertion(cst_utterance *u);
|
||||
cst_utterance *default_pause_insertion(cst_utterance *u);
|
||||
|
||||
cst_utterance *cart_intonation(cst_utterance *u);
|
||||
cst_utterance *cart_duration(cst_utterance *u);
|
||||
|
||||
cst_utterance *flat_prosody(cst_utterance *u);
|
||||
|
||||
typedef struct cst_synth_module_struct {
|
||||
const char *hookname;
|
||||
cst_uttfunc defhook;
|
||||
} cst_synth_module;
|
||||
|
||||
cst_utterance *apply_synth_module(cst_utterance *u,
|
||||
const cst_synth_module *mod);
|
||||
cst_utterance *apply_synth_method(cst_utterance *u,
|
||||
const cst_synth_module meth[]);
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,120 @@
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* Language Technologies Institute */
|
||||
/* Carnegie Mellon University */
|
||||
/* Copyright (c) 1999 */
|
||||
/* All Rights Reserved. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to use and distribute */
|
||||
/* this software and its documentation without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of this work, and to */
|
||||
/* permit persons to whom this work is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* 1. The code must retain the above copyright notice, this list of */
|
||||
/* conditions and the following disclaimer. */
|
||||
/* 2. Any modifications must be clearly marked as such. */
|
||||
/* 3. Original authors' names are not deleted. */
|
||||
/* 4. The authors' names are not used to endorse or promote products */
|
||||
/* derived from this software without specific prior written */
|
||||
/* permission. */
|
||||
/* */
|
||||
/* CARNEGIE MELLON UNIVERSITY AND THE CONTRIBUTORS TO THIS WORK */
|
||||
/* DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING */
|
||||
/* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT */
|
||||
/* SHALL CARNEGIE MELLON UNIVERSITY NOR THE CONTRIBUTORS BE LIABLE */
|
||||
/* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES */
|
||||
/* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN */
|
||||
/* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, */
|
||||
/* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF */
|
||||
/* THIS SOFTWARE. */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
/* Author: Alan W Black (awb@cs.cmu.edu) */
|
||||
/* Date: July 1999 */
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* Tokenizer for strings and files */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
#ifndef _CST_TOKENSTREAM_H__
|
||||
#define _CST_TOKENSTREAM_H__
|
||||
|
||||
#include "cst_alloc.h"
|
||||
#include "cst_string.h"
|
||||
#include "cst_file.h"
|
||||
|
||||
typedef struct cst_tokenstream_struct {
|
||||
cst_file fd;
|
||||
int file_pos;
|
||||
int line_number;
|
||||
cst_string *string_buffer;
|
||||
|
||||
int current_char;
|
||||
|
||||
int token_pos;
|
||||
int ws_max;
|
||||
cst_string *whitespace;
|
||||
int prep_max;
|
||||
cst_string *prepunctuation;
|
||||
int token_max;
|
||||
cst_string *token;
|
||||
int postp_max;
|
||||
cst_string *postpunctuation;
|
||||
|
||||
/* Should only be set through set_charclasses as charclass table needs */
|
||||
/* to be updated when you reset these */
|
||||
const cst_string *p_whitespacesymbols;
|
||||
const cst_string *p_singlecharsymbols;
|
||||
const cst_string *p_prepunctuationsymbols;
|
||||
const cst_string *p_postpunctuationsymbols;
|
||||
|
||||
cst_string charclass[256];
|
||||
} cst_tokenstream;
|
||||
|
||||
#define TS_CHARCLASS_NONE 0
|
||||
#define TS_CHARCLASS_WHITESPACE 2
|
||||
#define TS_CHARCLASS_SINGLECHAR 4
|
||||
#define TS_CHARCLASS_PREPUNCT 8
|
||||
#define TS_CHARCLASS_POSTPUNCT 16
|
||||
#define TS_CHARCLASS_QUOTE 32
|
||||
|
||||
#define ts_charclass(C,CLASS,TS) ((TS)->charclass[(unsigned char)C] & CLASS)
|
||||
|
||||
extern const cst_string * const cst_ts_default_whitespacesymbols;
|
||||
extern const cst_string * const cst_ts_default_prepunctuationsymbols;
|
||||
extern const cst_string * const cst_ts_default_postpunctuationsymbols;
|
||||
extern const cst_string * const cst_ts_default_singlecharsymbols;
|
||||
|
||||
/* Public functions for tokenstream manipulation */
|
||||
cst_tokenstream *ts_open(const char *filename,
|
||||
const cst_string *whitespacesymbols,
|
||||
const cst_string *singlecharsymbols,
|
||||
const cst_string *prepunctsymbols,
|
||||
const cst_string *postpunctsymbols);
|
||||
cst_tokenstream *ts_open_string(const cst_string *string,
|
||||
const cst_string *whitespacesymbols,
|
||||
const cst_string *singlecharsymbols,
|
||||
const cst_string *prepunctsymbols,
|
||||
const cst_string *postpunctsymbols);
|
||||
void ts_close(cst_tokenstream *ts);
|
||||
|
||||
int ts_eof(cst_tokenstream *ts);
|
||||
const cst_string *ts_get(cst_tokenstream *ts);
|
||||
|
||||
const cst_string *ts_get_quoted_token(cst_tokenstream *ts,
|
||||
char quote,
|
||||
char escape);
|
||||
|
||||
void set_charclasses(cst_tokenstream *ts,
|
||||
const cst_string *whitespace,
|
||||
const cst_string *singlecharsymbols,
|
||||
const cst_string *prepunctuation,
|
||||
const cst_string *postpunctuation);
|
||||
|
||||
int ts_read(void *buff, int size, int num, cst_tokenstream *ts);
|
||||
|
||||
int ts_set_stream_pos(cst_tokenstream *ts,int pos);
|
||||
int ts_get_stream_pos(cst_tokenstream *ts);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,70 @@
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* Language Technologies Institute */
|
||||
/* Carnegie Mellon University */
|
||||
/* Copyright (c) 1999 */
|
||||
/* All Rights Reserved. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to use and distribute */
|
||||
/* this software and its documentation without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of this work, and to */
|
||||
/* permit persons to whom this work is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* 1. The code must retain the above copyright notice, this list of */
|
||||
/* conditions and the following disclaimer. */
|
||||
/* 2. Any modifications must be clearly marked as such. */
|
||||
/* 3. Original authors' names are not deleted. */
|
||||
/* 4. The authors' names are not used to endorse or promote products */
|
||||
/* derived from this software without specific prior written */
|
||||
/* permission. */
|
||||
/* */
|
||||
/* CARNEGIE MELLON UNIVERSITY AND THE CONTRIBUTORS TO THIS WORK */
|
||||
/* DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING */
|
||||
/* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT */
|
||||
/* SHALL CARNEGIE MELLON UNIVERSITY NOR THE CONTRIBUTORS BE LIABLE */
|
||||
/* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES */
|
||||
/* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN */
|
||||
/* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, */
|
||||
/* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF */
|
||||
/* THIS SOFTWARE. */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
/* Author: Alan W Black (awb@cs.cmu.edu) */
|
||||
/* Date: August 2000 */
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* Waveforms */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
#ifndef _CST_TRACK_H__
|
||||
#define _CST_TRACK_H__
|
||||
|
||||
#include "cst_file.h"
|
||||
#include "cst_error.h"
|
||||
#include "cst_alloc.h"
|
||||
#include "cst_endian.h"
|
||||
#include "cst_file.h"
|
||||
#include "cst_val.h"
|
||||
|
||||
typedef struct cst_track_struct {
|
||||
const char *type;
|
||||
int num_frames;
|
||||
int num_channels;
|
||||
float *times;
|
||||
float **frames;
|
||||
} cst_track;
|
||||
|
||||
cst_track *new_track();
|
||||
void delete_track(cst_track *val);
|
||||
|
||||
float track_frame_shift(cst_track *t, int frame);
|
||||
void cst_track_resize(cst_track *t,int num_frames, int num_channels);
|
||||
|
||||
int cst_track_save_est(cst_track *t, const char *filename);
|
||||
int cst_track_save_est_binary(cst_track *t, const char *filename);
|
||||
int cst_track_load_est(cst_track *t, const char *filename);
|
||||
|
||||
CST_VAL_USER_TYPE_DCLS(track,cst_track)
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,64 @@
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* Language Technologies Institute */
|
||||
/* Carnegie Mellon University */
|
||||
/* Copyright (c) 1999 */
|
||||
/* All Rights Reserved. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to use and distribute */
|
||||
/* this software and its documentation without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of this work, and to */
|
||||
/* permit persons to whom this work is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* 1. The code must retain the above copyright notice, this list of */
|
||||
/* conditions and the following disclaimer. */
|
||||
/* 2. Any modifications must be clearly marked as such. */
|
||||
/* 3. Original authors' names are not deleted. */
|
||||
/* 4. The authors' names are not used to endorse or promote products */
|
||||
/* derived from this software without specific prior written */
|
||||
/* permission. */
|
||||
/* */
|
||||
/* CARNEGIE MELLON UNIVERSITY AND THE CONTRIBUTORS TO THIS WORK */
|
||||
/* DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING */
|
||||
/* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT */
|
||||
/* SHALL CARNEGIE MELLON UNIVERSITY NOR THE CONTRIBUTORS BE LIABLE */
|
||||
/* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES */
|
||||
/* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN */
|
||||
/* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, */
|
||||
/* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF */
|
||||
/* THIS SOFTWARE. */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
/* Author: Alan W Black (awb@cs.cmu.edu) */
|
||||
/* Date: September 2000 */
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* Various utterance access/setting functions */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
#ifndef _UTT_UTILS_H__
|
||||
#define _UTT_UTILS_H__
|
||||
|
||||
#include "cst_hrg.h"
|
||||
#include "cst_wave.h"
|
||||
|
||||
int utt_set_wave(cst_utterance *u, cst_wave *w);
|
||||
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_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_rel_head(U,R) (relation_head(utt_relation((U),R)))
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,74 @@
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* Language Technologies Institute */
|
||||
/* Carnegie Mellon University */
|
||||
/* Copyright (c) 1999 */
|
||||
/* All Rights Reserved. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to use and distribute */
|
||||
/* this software and its documentation without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of this work, and to */
|
||||
/* permit persons to whom this work is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* 1. The code must retain the above copyright notice, this list of */
|
||||
/* conditions and the following disclaimer. */
|
||||
/* 2. Any modifications must be clearly marked as such. */
|
||||
/* 3. Original authors' names are not deleted. */
|
||||
/* 4. The authors' names are not used to endorse or promote products */
|
||||
/* derived from this software without specific prior written */
|
||||
/* permission. */
|
||||
/* */
|
||||
/* CARNEGIE MELLON UNIVERSITY AND THE CONTRIBUTORS TO THIS WORK */
|
||||
/* DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING */
|
||||
/* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT */
|
||||
/* SHALL CARNEGIE MELLON UNIVERSITY NOR THE CONTRIBUTORS BE LIABLE */
|
||||
/* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES */
|
||||
/* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN */
|
||||
/* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, */
|
||||
/* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF */
|
||||
/* THIS SOFTWARE. */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
/* Author: Alan W Black (awb@cs.cmu.edu) */
|
||||
/* Date: December 1999 */
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* Utterances */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
#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_relation.h"
|
||||
#include "cst_alloc.h"
|
||||
|
||||
struct cst_utterance_struct {
|
||||
cst_features *features;
|
||||
cst_features *ffunctions;
|
||||
cst_features *relations;
|
||||
cst_alloc_context ctx;
|
||||
};
|
||||
|
||||
/* Constructor functions */
|
||||
cst_utterance *new_utterance();
|
||||
void delete_utterance(cst_utterance *u);
|
||||
|
||||
cst_relation *utt_relation(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
|
||||
+210
@@ -0,0 +1,210 @@
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* Language Technologies Institute */
|
||||
/* Carnegie Mellon University */
|
||||
/* Copyright (c) 1999 */
|
||||
/* All Rights Reserved. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to use and distribute */
|
||||
/* this software and its documentation without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of this work, and to */
|
||||
/* permit persons to whom this work is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* 1. The code must retain the above copyright notice, this list of */
|
||||
/* conditions and the following disclaimer. */
|
||||
/* 2. Any modifications must be clearly marked as such. */
|
||||
/* 3. Original authors' names are not deleted. */
|
||||
/* 4. The authors' names are not used to endorse or promote products */
|
||||
/* derived from this software without specific prior written */
|
||||
/* permission. */
|
||||
/* */
|
||||
/* CARNEGIE MELLON UNIVERSITY AND THE CONTRIBUTORS TO THIS WORK */
|
||||
/* DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING */
|
||||
/* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT */
|
||||
/* SHALL CARNEGIE MELLON UNIVERSITY NOR THE CONTRIBUTORS BE LIABLE */
|
||||
/* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES */
|
||||
/* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN */
|
||||
/* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, */
|
||||
/* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF */
|
||||
/* THIS SOFTWARE. */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
/* Author: Alan W Black (awb@cs.cmu.edu) */
|
||||
/* Date: December 1999 */
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* Vals, typed objects */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
|
||||
/* ----------------------------------------------------------------- */
|
||||
/* The English TTS System "Flite+hts_engine" */
|
||||
/* developed by HTS Working Group */
|
||||
/* http://hts-engine.sourceforge.net/ */
|
||||
/* ----------------------------------------------------------------- */
|
||||
/* */
|
||||
/* Copyright (c) 2005-2013 Nagoya Institute of Technology */
|
||||
/* Department of Computer Science */
|
||||
/* */
|
||||
/* 2005-2008 Tokyo Institute of Technology */
|
||||
/* Interdisciplinary Graduate School of */
|
||||
/* Science and Engineering */
|
||||
/* */
|
||||
/* All rights reserved. */
|
||||
/* */
|
||||
/* Redistribution and use in source and binary forms, with or */
|
||||
/* without modification, are permitted provided that the following */
|
||||
/* conditions are met: */
|
||||
/* */
|
||||
/* - Redistributions of source code must retain the above copyright */
|
||||
/* notice, this list of conditions and the following disclaimer. */
|
||||
/* - Redistributions in binary form must reproduce the above */
|
||||
/* copyright notice, this list of conditions and the following */
|
||||
/* disclaimer in the documentation and/or other materials provided */
|
||||
/* with the distribution. */
|
||||
/* - Neither the name of the HTS working group nor the names of its */
|
||||
/* contributors may be used to endorse or promote products derived */
|
||||
/* from this software without specific prior written permission. */
|
||||
/* */
|
||||
/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND */
|
||||
/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, */
|
||||
/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF */
|
||||
/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE */
|
||||
/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS */
|
||||
/* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, */
|
||||
/* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED */
|
||||
/* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, */
|
||||
/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON */
|
||||
/* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, */
|
||||
/* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY */
|
||||
/* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */
|
||||
/* POSSIBILITY OF SUCH DAMAGE. */
|
||||
/* ----------------------------------------------------------------- */
|
||||
|
||||
#ifndef _CST_VAL_H__
|
||||
#define _CST_VAL_H__
|
||||
|
||||
#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 */
|
||||
#define CST_VAL_TYPE_CONS 0
|
||||
#define CST_VAL_TYPE_INT 1
|
||||
#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;
|
||||
struct cst_val_struct *cdr;
|
||||
} cst_val_cons;
|
||||
|
||||
typedef struct cst_val_atom_struct {
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
#if defined(SIZEOF_VOID_P) && SIZEOF_VOID_P == 8
|
||||
int ref_count;
|
||||
int type;
|
||||
#else
|
||||
short ref_count;
|
||||
short type; /* order is here important */
|
||||
#endif
|
||||
#else
|
||||
#if defined(SIZEOF_VOID_P) && SIZEOF_VOID_P == 8
|
||||
int type;
|
||||
int ref_count;
|
||||
#else
|
||||
short type; /* order is here important */
|
||||
short ref_count;
|
||||
#endif
|
||||
#endif
|
||||
union
|
||||
{
|
||||
float fval;
|
||||
int ival;
|
||||
void *vval;
|
||||
} v;
|
||||
} cst_val_atom;
|
||||
|
||||
typedef struct cst_val_struct {
|
||||
union
|
||||
{
|
||||
cst_val_cons cc;
|
||||
cst_val_atom a;
|
||||
} c;
|
||||
} cst_val;
|
||||
|
||||
typedef struct cst_val_def_struct {
|
||||
const char *name;
|
||||
void (*delete_function)(void *);
|
||||
} cst_val_def;
|
||||
|
||||
/* Constructor functions */
|
||||
cst_val *int_val(int i);
|
||||
cst_val *float_val(float f);
|
||||
cst_val *string_val(const char *s);
|
||||
cst_val *val_new_typed(int type, void *vv);
|
||||
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);
|
||||
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);
|
||||
|
||||
/* 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"
|
||||
extern const cst_val_def cst_val_defs[];
|
||||
|
||||
/* Generic pointer vals */
|
||||
typedef void cst_userdata;
|
||||
CST_VAL_USER_TYPE_DCLS(userdata,cst_userdata)
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,403 @@
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* Language Technologies Institute */
|
||||
/* Carnegie Mellon University */
|
||||
/* Copyright (c) 2001 */
|
||||
/* All Rights Reserved. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to use and distribute */
|
||||
/* this software and its documentation without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of this work, and to */
|
||||
/* permit persons to whom this work is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* 1. The code must retain the above copyright notice, this list of */
|
||||
/* conditions and the following disclaimer. */
|
||||
/* 2. Any modifications must be clearly marked as such. */
|
||||
/* 3. Original authors' names are not deleted. */
|
||||
/* 4. The authors' names are not used to endorse or promote products */
|
||||
/* derived from this software without specific prior written */
|
||||
/* permission. */
|
||||
/* */
|
||||
/* CARNEGIE MELLON UNIVERSITY AND THE CONTRIBUTORS TO THIS WORK */
|
||||
/* DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING */
|
||||
/* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT */
|
||||
/* SHALL CARNEGIE MELLON UNIVERSITY NOR THE CONTRIBUTORS BE LIABLE */
|
||||
/* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES */
|
||||
/* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN */
|
||||
/* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, */
|
||||
/* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF */
|
||||
/* THIS SOFTWARE. */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
/* Author: Alan W Black (awb@cs.cmu.edu) */
|
||||
/* Date: January 2001 */
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* Const Vals, and macros to define them */
|
||||
/* */
|
||||
/* Before you give up in disgust bear with me on this. Every single */
|
||||
/* line in this file has been *very* carefully decided on after much */
|
||||
/* thought, experimentation and reading more specs of the C language */
|
||||
/* than most people even thought existed. However inspite of that, the */
|
||||
/* result is still unsatisfying from an elegance point of view but the */
|
||||
/* given all the constraints this is probably the best compromise. */
|
||||
/* */
|
||||
/* This file offers macros for defining const cst_vals. I know many */
|
||||
/* are already laughing at me for wanting runtime types on objects and */
|
||||
/* will use this code as exemplars of why this should be done in C++, I */
|
||||
/* say good luck to them with their 4M footprint while I go for my */
|
||||
/* 50K footprint. But I *will* do cst_vals in 8 bytes and I *will* */
|
||||
/* have them defined const so they are in the text segment */
|
||||
/* */
|
||||
/* The problem here is that there is not yet a standard way to do */
|
||||
/* 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 */
|
||||
/* */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
|
||||
/* ----------------------------------------------------------------- */
|
||||
/* The English TTS System "Flite+hts_engine" */
|
||||
/* developed by HTS Working Group */
|
||||
/* http://hts-engine.sourceforge.net/ */
|
||||
/* ----------------------------------------------------------------- */
|
||||
/* */
|
||||
/* Copyright (c) 2005-2013 Nagoya Institute of Technology */
|
||||
/* Department of Computer Science */
|
||||
/* */
|
||||
/* 2005-2008 Tokyo Institute of Technology */
|
||||
/* Interdisciplinary Graduate School of */
|
||||
/* Science and Engineering */
|
||||
/* */
|
||||
/* All rights reserved. */
|
||||
/* */
|
||||
/* Redistribution and use in source and binary forms, with or */
|
||||
/* without modification, are permitted provided that the following */
|
||||
/* conditions are met: */
|
||||
/* */
|
||||
/* - Redistributions of source code must retain the above copyright */
|
||||
/* notice, this list of conditions and the following disclaimer. */
|
||||
/* - Redistributions in binary form must reproduce the above */
|
||||
/* copyright notice, this list of conditions and the following */
|
||||
/* disclaimer in the documentation and/or other materials provided */
|
||||
/* with the distribution. */
|
||||
/* - Neither the name of the HTS working group nor the names of its */
|
||||
/* contributors may be used to endorse or promote products derived */
|
||||
/* from this software without specific prior written permission. */
|
||||
/* */
|
||||
/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND */
|
||||
/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, */
|
||||
/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF */
|
||||
/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE */
|
||||
/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS */
|
||||
/* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, */
|
||||
/* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED */
|
||||
/* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, */
|
||||
/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON */
|
||||
/* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, */
|
||||
/* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY */
|
||||
/* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */
|
||||
/* POSSIBILITY OF SUCH DAMAGE. */
|
||||
/* ----------------------------------------------------------------- */
|
||||
|
||||
#ifndef _CST_VAL_CONSTS_H__
|
||||
#define _CST_VAL_CONSTS_H__
|
||||
|
||||
#include "cst_val_defs.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 }}}
|
||||
|
||||
extern const cst_val val_int_0;
|
||||
extern const cst_val val_int_1;
|
||||
extern const cst_val val_int_2;
|
||||
extern const cst_val val_int_3;
|
||||
extern const cst_val val_int_4;
|
||||
extern const cst_val val_int_5;
|
||||
extern const cst_val val_int_6;
|
||||
extern const cst_val val_int_7;
|
||||
extern const cst_val val_int_8;
|
||||
extern const cst_val val_int_9;
|
||||
extern const cst_val val_int_10;
|
||||
extern const cst_val val_int_11;
|
||||
extern const cst_val val_int_12;
|
||||
extern const cst_val val_int_13;
|
||||
extern const cst_val val_int_14;
|
||||
extern const cst_val val_int_15;
|
||||
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_string_0;
|
||||
extern const cst_val val_string_1;
|
||||
extern const cst_val val_string_2;
|
||||
extern const cst_val val_string_3;
|
||||
extern const cst_val val_string_4;
|
||||
extern const cst_val val_string_5;
|
||||
extern const cst_val val_string_6;
|
||||
extern const cst_val val_string_7;
|
||||
extern const cst_val val_string_8;
|
||||
extern const cst_val val_string_9;
|
||||
extern const cst_val val_string_10;
|
||||
extern const cst_val val_string_11;
|
||||
extern const cst_val val_string_12;
|
||||
extern const cst_val val_string_13;
|
||||
extern const cst_val val_string_14;
|
||||
extern const cst_val val_string_15;
|
||||
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;
|
||||
|
||||
#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 by 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 your are */
|
||||
/* unquestionably doing the wrong thing */
|
||||
typedef struct cst_val_atom_struct_float {
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
#if defined(SIZEOF_VOID_P) && SIZEOF_VOID_P == 8
|
||||
int ref_count;
|
||||
int type;
|
||||
#else
|
||||
short ref_count;
|
||||
short type; /* order is here important */
|
||||
#endif
|
||||
#else
|
||||
#if defined(SIZEOF_VOID_P) && SIZEOF_VOID_P == 8
|
||||
int type;
|
||||
int ref_count;
|
||||
#else
|
||||
short type; /* order is here important */
|
||||
short ref_count;
|
||||
#endif
|
||||
#endif
|
||||
float fval;
|
||||
} cst_val_float;
|
||||
|
||||
typedef struct cst_val_atom_struct_int {
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
#if defined(SIZEOF_VOID_P) && SIZEOF_VOID_P == 8
|
||||
int ref_count;
|
||||
int type;
|
||||
#else
|
||||
short ref_count;
|
||||
short type; /* order is here important (and unintuitive) */
|
||||
#endif
|
||||
#else
|
||||
#if defined(SIZEOF_VOID_P) && SIZEOF_VOID_P == 8
|
||||
int type;
|
||||
int ref_count;
|
||||
#else
|
||||
short type; /* order is here important */
|
||||
short ref_count;
|
||||
#endif
|
||||
#endif
|
||||
int ival;
|
||||
} cst_val_int;
|
||||
|
||||
typedef struct cst_val_atom_struct_void {
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
#if defined(SIZEOF_VOID_P) && SIZEOF_VOID_P == 8
|
||||
int ref_count;
|
||||
int type;
|
||||
#else
|
||||
short ref_count;
|
||||
short type; /* order is here important */
|
||||
#endif
|
||||
#else
|
||||
#if defined(SIZEOF_VOID_P) && SIZEOF_VOID_P == 8
|
||||
int type;
|
||||
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_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;
|
||||
|
||||
#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
|
||||
|
||||
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
|
||||
|
||||
const cst_val *val_string_n(int n);
|
||||
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,112 @@
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* Language Technologies Institute */
|
||||
/* Carnegie Mellon University */
|
||||
/* Copyright (c) 1999 */
|
||||
/* All Rights Reserved. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to use and distribute */
|
||||
/* this software and its documentation without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of this work, and to */
|
||||
/* permit persons to whom this work is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* 1. The code must retain the above copyright notice, this list of */
|
||||
/* conditions and the following disclaimer. */
|
||||
/* 2. Any modifications must be clearly marked as such. */
|
||||
/* 3. Original authors' names are not deleted. */
|
||||
/* 4. The authors' names are not used to endorse or promote products */
|
||||
/* derived from this software without specific prior written */
|
||||
/* permission. */
|
||||
/* */
|
||||
/* CARNEGIE MELLON UNIVERSITY AND THE CONTRIBUTORS TO THIS WORK */
|
||||
/* DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING */
|
||||
/* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT */
|
||||
/* SHALL CARNEGIE MELLON UNIVERSITY NOR THE CONTRIBUTORS BE LIABLE */
|
||||
/* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES */
|
||||
/* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN */
|
||||
/* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, */
|
||||
/* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF */
|
||||
/* THIS SOFTWARE. */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
/* Author: Alan W Black (awb@cs.cmu.edu) */
|
||||
/* Date: December 1999 */
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* Macros for user defined type objects */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
#ifndef _CST_VAL_DEFS_H__
|
||||
#define _CST_VAL_DEFS_H__
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
/* Macro for defining new user structs as vals */
|
||||
#define CST_VAL_USER_TYPE_DCLS(NAME,TYPE) \
|
||||
extern const int cst_val_type_##NAME; \
|
||||
TYPE *val_##NAME(const cst_val *v); \
|
||||
cst_val *NAME##_val(const TYPE *v);
|
||||
|
||||
#define CST_VAL_USER_FUNCPTR_DCLS(NAME,TYPE) \
|
||||
extern const int cst_val_type_##NAME; \
|
||||
TYPE val_##NAME(const cst_val *v); \
|
||||
cst_val *NAME##_val(const TYPE v);
|
||||
|
||||
#define CST_VAL_REGISTER_TYPE(NAME,TYPE) \
|
||||
TYPE *val_##NAME(const cst_val *v) \
|
||||
{ \
|
||||
return (TYPE *)val_generic(v,cst_val_type_##NAME,#NAME); \
|
||||
} \
|
||||
void val_delete_##NAME(void *v) \
|
||||
{ \
|
||||
delete_##NAME((TYPE *)v); \
|
||||
} \
|
||||
\
|
||||
cst_val *NAME##_val(const TYPE *v) \
|
||||
{ \
|
||||
return val_new_typed(cst_val_type_##NAME, \
|
||||
(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) \
|
||||
{ \
|
||||
return (TYPE *)val_generic(v,cst_val_type_##NAME,#NAME); \
|
||||
} \
|
||||
\
|
||||
cst_val *NAME##_val(const TYPE *v) \
|
||||
{ \
|
||||
return val_new_typed(cst_val_type_##NAME, \
|
||||
(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) \
|
||||
{ \
|
||||
return (TYPE)val_generic(v,cst_val_type_##NAME,#NAME); \
|
||||
} \
|
||||
\
|
||||
cst_val *NAME##_val(const TYPE v) \
|
||||
{ \
|
||||
return val_new_typed(cst_val_type_##NAME, \
|
||||
(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
|
||||
@@ -0,0 +1,113 @@
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* Language Technologies Institute */
|
||||
/* Carnegie Mellon University */
|
||||
/* Copyright (c) 2000 */
|
||||
/* All Rights Reserved. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to use and distribute */
|
||||
/* this software and its documentation without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of this work, and to */
|
||||
/* permit persons to whom this work is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* 1. The code must retain the above copyright notice, this list of */
|
||||
/* conditions and the following disclaimer. */
|
||||
/* 2. Any modifications must be clearly marked as such. */
|
||||
/* 3. Original authors' names are not deleted. */
|
||||
/* 4. The authors' names are not used to endorse or promote products */
|
||||
/* derived from this software without specific prior written */
|
||||
/* permission. */
|
||||
/* */
|
||||
/* CARNEGIE MELLON UNIVERSITY AND THE CONTRIBUTORS TO THIS WORK */
|
||||
/* DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING */
|
||||
/* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT */
|
||||
/* SHALL CARNEGIE MELLON UNIVERSITY NOR THE CONTRIBUTORS BE LIABLE */
|
||||
/* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES */
|
||||
/* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN */
|
||||
/* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, */
|
||||
/* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF */
|
||||
/* THIS SOFTWARE. */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
/* Author: Alan W Black (awb@cs.cmu.edu) */
|
||||
/* Date: August 2000 */
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* Viterbi support */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
#ifndef _CST_VITERBI_H__
|
||||
#define _CST_VITERBI_H__
|
||||
|
||||
#include "cst_file.h"
|
||||
#include "cst_math.h"
|
||||
#include "cst_utterance.h"
|
||||
|
||||
typedef struct cst_vit_cand_struct {
|
||||
int score;
|
||||
cst_val *val;
|
||||
int ival, pos;
|
||||
cst_item *item;
|
||||
struct cst_vit_cand_struct *next;
|
||||
} cst_vit_cand;
|
||||
cst_vit_cand *new_vit_cand();
|
||||
void vit_cand_set(cst_vit_cand *vc, cst_val *val);
|
||||
void vit_cand_set_int(cst_vit_cand *vc, int ival);
|
||||
void delete_vit_cand(cst_vit_cand *vc);
|
||||
|
||||
typedef struct cst_vit_path_struct {
|
||||
int score;
|
||||
int state;
|
||||
cst_vit_cand *cand;
|
||||
cst_features *f;
|
||||
struct cst_vit_path_struct *from;
|
||||
struct cst_vit_path_struct *next;
|
||||
} cst_vit_path;
|
||||
cst_vit_path *new_vit_path();
|
||||
void delete_vit_path(cst_vit_path *vp);
|
||||
|
||||
typedef struct cst_vit_point_struct {
|
||||
cst_item *item;
|
||||
int num_states;
|
||||
int num_paths;
|
||||
cst_vit_cand *cands;
|
||||
cst_vit_path *paths;
|
||||
cst_vit_path **state_paths;
|
||||
struct cst_vit_point_struct *next;
|
||||
} cst_vit_point;
|
||||
cst_vit_point *new_vit_point();
|
||||
void delete_vit_point(cst_vit_point *vp);
|
||||
|
||||
struct cst_viterbi_struct;
|
||||
|
||||
/* Functions for user call back, to find candiates at a point, and
|
||||
to join (and score) paths */
|
||||
typedef cst_vit_cand *(cst_vit_cand_f_t)(cst_item *s,
|
||||
struct cst_viterbi_struct *vd);
|
||||
typedef cst_vit_path *(cst_vit_path_f_t)(cst_vit_path *p,
|
||||
cst_vit_cand *c,
|
||||
struct cst_viterbi_struct *vd);
|
||||
|
||||
typedef struct cst_viterbi_struct {
|
||||
int num_states;
|
||||
cst_vit_cand_f_t *cand_func;
|
||||
cst_vit_path_f_t *path_func;
|
||||
int big_is_good;
|
||||
|
||||
cst_vit_point *timeline;
|
||||
cst_vit_point *last_point;
|
||||
cst_features *f;
|
||||
} cst_viterbi;
|
||||
|
||||
|
||||
cst_viterbi *new_viterbi(cst_vit_cand_f_t *cand_func,
|
||||
cst_vit_path_f_t *path_func);
|
||||
void delete_viterbi(cst_viterbi *vd);
|
||||
|
||||
void viterbi_initialise(cst_viterbi *vd,cst_relation *r);
|
||||
void viterbi_decode(cst_viterbi *vd);
|
||||
int viterbi_result(cst_viterbi *vd, const char *n);
|
||||
void viterbi_copy_feature(cst_viterbi *vd,const char *featname);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,69 @@
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* Language Technologies Institute */
|
||||
/* Carnegie Mellon University */
|
||||
/* Copyright (c) 1999 */
|
||||
/* All Rights Reserved. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to use and distribute */
|
||||
/* this software and its documentation without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of this work, and to */
|
||||
/* permit persons to whom this work is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* 1. The code must retain the above copyright notice, this list of */
|
||||
/* conditions and the following disclaimer. */
|
||||
/* 2. Any modifications must be clearly marked as such. */
|
||||
/* 3. Original authors' names are not deleted. */
|
||||
/* 4. The authors' names are not used to endorse or promote products */
|
||||
/* derived from this software without specific prior written */
|
||||
/* permission. */
|
||||
/* */
|
||||
/* CARNEGIE MELLON UNIVERSITY AND THE CONTRIBUTORS TO THIS WORK */
|
||||
/* DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING */
|
||||
/* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT */
|
||||
/* SHALL CARNEGIE MELLON UNIVERSITY NOR THE CONTRIBUTORS BE LIABLE */
|
||||
/* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES */
|
||||
/* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN */
|
||||
/* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, */
|
||||
/* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF */
|
||||
/* THIS SOFTWARE. */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
/* Author: Alan W Black (awb@cs.cmu.edu) */
|
||||
/* Date: December 2000 */
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* Voice functions */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
#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"
|
||||
|
||||
struct cst_voice_struct {
|
||||
const char *name;
|
||||
|
||||
cst_features *features;
|
||||
cst_features *ffunctions;
|
||||
|
||||
/* This hook is called (from utt_init()) after the input text (if
|
||||
any) has been set and voice features have been copied in, but
|
||||
before synthesis. */
|
||||
cst_utterance *(*utt_init)(cst_utterance *u,
|
||||
struct cst_voice_struct *v);
|
||||
};
|
||||
typedef struct cst_voice_struct cst_voice;
|
||||
|
||||
/* Constructor functions */
|
||||
cst_voice *new_voice();
|
||||
void delete_voice(cst_voice *u);
|
||||
|
||||
CST_VAL_USER_TYPE_DCLS(voice,cst_voice)
|
||||
|
||||
#endif
|
||||
+158
@@ -0,0 +1,158 @@
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* Language Technologies Institute */
|
||||
/* Carnegie Mellon University */
|
||||
/* Copyright (c) 1999 */
|
||||
/* All Rights Reserved. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to use and distribute */
|
||||
/* this software and its documentation without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of this work, and to */
|
||||
/* permit persons to whom this work is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* 1. The code must retain the above copyright notice, this list of */
|
||||
/* conditions and the following disclaimer. */
|
||||
/* 2. Any modifications must be clearly marked as such. */
|
||||
/* 3. Original authors' names are not deleted. */
|
||||
/* 4. The authors' names are not used to endorse or promote products */
|
||||
/* derived from this software without specific prior written */
|
||||
/* permission. */
|
||||
/* */
|
||||
/* CARNEGIE MELLON UNIVERSITY AND THE CONTRIBUTORS TO THIS WORK */
|
||||
/* DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING */
|
||||
/* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT */
|
||||
/* SHALL CARNEGIE MELLON UNIVERSITY NOR THE CONTRIBUTORS BE LIABLE */
|
||||
/* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES */
|
||||
/* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN */
|
||||
/* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, */
|
||||
/* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF */
|
||||
/* THIS SOFTWARE. */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
/* Author: Alan W Black (awb@cs.cmu.edu) */
|
||||
/* Date: August 2000 */
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* Waveforms */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
#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 "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;
|
||||
} 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_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
|
||||
|
||||
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);
|
||||
|
||||
CST_VAL_USER_TYPE_DCLS(wave,cst_wave)
|
||||
|
||||
#endif
|
||||
+170
@@ -0,0 +1,170 @@
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* Language Technologies Institute */
|
||||
/* Carnegie Mellon University */
|
||||
/* Copyright (c) 1999 */
|
||||
/* All Rights Reserved. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to use and distribute */
|
||||
/* this software and its documentation without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of this work, and to */
|
||||
/* permit persons to whom this work is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* 1. The code must retain the above copyright notice, this list of */
|
||||
/* conditions and the following disclaimer. */
|
||||
/* 2. Any modifications must be clearly marked as such. */
|
||||
/* 3. Original authors' names are not deleted. */
|
||||
/* 4. The authors' names are not used to endorse or promote products */
|
||||
/* derived from this software without specific prior written */
|
||||
/* permission. */
|
||||
/* */
|
||||
/* CARNEGIE MELLON UNIVERSITY AND THE CONTRIBUTORS TO THIS WORK */
|
||||
/* DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING */
|
||||
/* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT */
|
||||
/* SHALL CARNEGIE MELLON UNIVERSITY NOR THE CONTRIBUTORS BE LIABLE */
|
||||
/* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES */
|
||||
/* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN */
|
||||
/* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, */
|
||||
/* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF */
|
||||
/* THIS SOFTWARE. */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
/* Author: Alan W Black (awb@cs.cmu.edu) */
|
||||
/* Date: December 1999 */
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* Light weight run-time speech synthesis system, public API */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
|
||||
/* ----------------------------------------------------------------- */
|
||||
/* The English TTS System "Flite+hts_engine" */
|
||||
/* developed by HTS Working Group */
|
||||
/* http://hts-engine.sourceforge.net/ */
|
||||
/* ----------------------------------------------------------------- */
|
||||
/* */
|
||||
/* Copyright (c) 2005-2013 Nagoya Institute of Technology */
|
||||
/* Department of Computer Science */
|
||||
/* */
|
||||
/* 2005-2008 Tokyo Institute of Technology */
|
||||
/* Interdisciplinary Graduate School of */
|
||||
/* Science and Engineering */
|
||||
/* */
|
||||
/* All rights reserved. */
|
||||
/* */
|
||||
/* Redistribution and use in source and binary forms, with or */
|
||||
/* without modification, are permitted provided that the following */
|
||||
/* conditions are met: */
|
||||
/* */
|
||||
/* - Redistributions of source code must retain the above copyright */
|
||||
/* notice, this list of conditions and the following disclaimer. */
|
||||
/* - Redistributions in binary form must reproduce the above */
|
||||
/* copyright notice, this list of conditions and the following */
|
||||
/* disclaimer in the documentation and/or other materials provided */
|
||||
/* with the distribution. */
|
||||
/* - Neither the name of the HTS working group nor the names of its */
|
||||
/* contributors may be used to endorse or promote products derived */
|
||||
/* from this software without specific prior written permission. */
|
||||
/* */
|
||||
/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND */
|
||||
/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, */
|
||||
/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF */
|
||||
/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE */
|
||||
/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS */
|
||||
/* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, */
|
||||
/* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED */
|
||||
/* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, */
|
||||
/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON */
|
||||
/* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, */
|
||||
/* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY */
|
||||
/* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */
|
||||
/* POSSIBILITY OF SUCH DAMAGE. */
|
||||
/* ----------------------------------------------------------------- */
|
||||
|
||||
#ifndef _FLITE_H__
|
||||
#define _FLITE_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
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_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"
|
||||
#ifndef FLITE_PLUS_HTS_ENGINE
|
||||
#include "cst_units.h"
|
||||
#endif /* !FLITE_PLUS_HTS_ENGINE */
|
||||
#include "cst_tokenstream.h"
|
||||
|
||||
extern cst_val *flite_voice_list;
|
||||
|
||||
/* Public functions */
|
||||
int flite_init();
|
||||
|
||||
/* General top level functions */
|
||||
cst_voice *flite_voice_select(const char *name);
|
||||
float flite_file_to_speech(const char *filename,
|
||||
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_to_speech(const char *filename,
|
||||
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);
|
||||
|
||||
cst_utterance *flite_do_synth(cst_utterance *u,
|
||||
cst_voice *voice,
|
||||
cst_uttfunc synth);
|
||||
float flite_process_output(cst_utterance *u,
|
||||
const char *outtype,
|
||||
int append);
|
||||
|
||||
/* 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);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user