first commit

This commit is contained in:
Your Name
2022-10-20 20:29:11 +08:00
commit 4d531f8044
3238 changed files with 1387862 additions and 0 deletions
+256
View File
@@ -0,0 +1,256 @@
/* ----------------------------------------------------------------- */
/* 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. */
/* ----------------------------------------------------------------- */
Flite is free software.
We have kept the core code to BSD-like copyright, thus the system is
free to use in commercial products, with commercial extensions. GPL
code is only included as part of the build process and does not
taint any of the run-time code.
Note the PalmOS code uses BSD code that requires acknowledgements in
any distribution documentation.
As a collection it is distributed under the following license. Note
a few files in this distribution have a different but equally free
non-conflicting licence, see below.
Language Technologies Institute
Carnegie Mellon University
Copyright (c) 1999-2008
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.
All files within this distribution have the above license except
the following
src/cg/cst_mlpg.h
src/cg/cst_mlpg.c
src/cg/cst_mlsa.h
src/cg/cst_mlsa.c
src/cg/cst_vc.h
src/cg/cst_vc.c
/*********************************************************************/
/* */
/* Nagoya Institute of Technology, Aichi, Japan, */
/* Nara Institute of Science and Technology, Nara, Japan */
/* and */
/* Carnegie Mellon University, Pittsburgh, PA */
/* Copyright (c) 2003-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. */
/* */
/* NAGOYA INSTITUTE OF TECHNOLOGY, NARA INSTITUTE OF SCIENCE AND */
/* TECHNOLOGY, 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 NAGOYA INSTITUTE OF TECHNOLOGY, NARA */
/* INSTITUTE OF SCIENCE AND TECHNOLOGY, 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. */
/* */
/*********************************************************************/
These functions are derived from the versions in festvox/src/vc/ as
modified by Tomoki Toda which in turn contain code derived from
NITECH's HTS system. Their copyright has the same freedoms as
as Flite's but under NAIST, NITECH and/or CMU.
src/audio/au_wince.c
src/utils/cst_file_stdio.c
src/utils/cst_mmap_posix.c
src/utils/cst_mmap_win32.c
src/utils/cst_mmap_none.c
src/utils/cst_file_wince.c
sapi/
are copyright Cepstral, LLC rather than CMU but fall under the same
free licence as the above, except for the owner.
doc/alice
Is the first two chapters of Alice in Wonderland as distributed by the
Gutenburg project and is now in the public domain
src/regex/regexp.c
src/regex/regsub.c
* Copyright (c) 1986 by University of Toronto.
* Written by Henry Spencer. Not derived from licensed software.
*
* Permission is granted to anyone to use this software for any
* purpose on any computer system, and to redistribute it freely,
* subject to the following restrictions:
*
* 1. The author is not responsible for the consequences of use of
* this software, no matter how awful, even if they arise
* from defects in it.
*
* 2. The origin of this software must not be misrepresented, either
* by explicit claim or by omission.
*
* 3. Altered versions must be plainly marked as such, and must not
* be misrepresented as being the original software.
src/speech/rateconv.c
* Copyright (c) 1992, 1995 by Markus Mummert
*
* Redistribution and use of this software, modifcation and inclusion
* into other forms of software are permitted provided that the following
* conditions are met:
*
* 1. Redistributions of this software must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. If this software is redistributed in a modified condition
* it must reveal clearly that it has been modified.
lang/usenglish/us_durz_cart.c
lang/usenglish/us_durz_cart.h
lang/usenglish/us_int_accent_cart.c
lang/usenglish/us_int_accent_cart.h
lang/usenglish/us_int_tone_cart.c
lang/usenglish/us_int_tone_cart.h
lang/usenglish/us_phoneset.c
lang/usenglish/us_f0lr.c
These are directly (or indirectly) compiled/derived from files that are
part of the Festival Speech Synthesis System (1.4.1). Hence they have
a joint copyright CMU/Edinburgh but with the same free licence
configure
# Copyright (C) 1992, 93, 94, 95, 96 Free Software Foundation, Inc.
#
# This configure script is free software; the Free Software Foundation
# gives unlimited permission to copy, distribute and modify it.
configure.sub
config.guess
missing
install-sh
mkinstalldirs
Copyright FSF, and under the GPL, these files are only used for
convenient configuration and are not part of the generated binary,
and therefore do not impose any GPL restrctions on the rest of the
system. But as they are standard methods for configuration they
are included.
palm/include/peal.h
palm/include/pealstub.h
palm/arm_flite/pealstub.c
palm/m68k_flite/peal.c
/**********
* Copyright (c) 2004 Greg Parker. All rights reserved.
*
* 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.
*
* THIS SOFTWARE IS PROVIDED BY GREG PARKER ``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 AUTHOR 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.
**********/
The whole Sun Microsystems math library was ported to Palm
for this but its not actually needed, though the include file is
to allow bits of the system to compile that currently linked in
to the system, so we just have the include file here
palm/include/fdlibm.h
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
*
* Developed at SunSoft, a Sun Microsystems, Inc. business.
* Permission to use, copy, modify, and distribute this
* software is freely granted, provided that this notice
* is preserved.
* ====================================================
+82
View File
@@ -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
+49
View File
@@ -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
View File
@@ -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
+77
View File
@@ -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
+70
View File
@@ -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
+78
View File
@@ -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
+89
View File
@@ -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
+65
View File
@@ -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
View File
@@ -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
+50
View File
@@ -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
View File
@@ -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
+87
View File
@@ -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
+78
View File
@@ -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
+51
View File
@@ -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
+76
View File
@@ -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
View File
@@ -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
+72
View File
@@ -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
+51
View File
@@ -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
+49
View File
@@ -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
+58
View File
@@ -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
+72
View File
@@ -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
View File
@@ -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
+93
View File
@@ -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
+70
View File
@@ -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
+64
View File
@@ -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
+74
View File
@@ -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
View File
@@ -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
+403
View File
@@ -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
+112
View File
@@ -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
+113
View File
@@ -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
+69
View File
@@ -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
View File
@@ -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
View File
@@ -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
@@ -0,0 +1,173 @@
/*************************************************************************/
/* */
/* Language Technologies Institute */
/* Carnegie Mellon University */
/* Copyright (c) 1999-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: December 2000 */
/*************************************************************************/
/* */
/* A simple voice defintion */
/* */
/*************************************************************************/
/* ----------------------------------------------------------------- */
/* 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. */
/* ----------------------------------------------------------------- */
#include "flite.h"
#ifndef FLITE_PLUS_HTS_ENGINE
#include "cst_diphone.h"
#endif /* !FLITE_PLUS_HTS_ENGINE */
#include "usenglish.h"
#include "cmu_lex.h"
static cst_utterance *cmu_us_kal_postlex(cst_utterance *u);
#ifndef FLITE_PLUS_HTS_ENGINE
extern cst_diphone_db cmu_us_kal_db;
#endif /* !FLITE_PLUS_HTS_ENGINE */
cst_voice *cmu_us_kal_diphone = NULL;
cst_voice *register_cmu_us_kal(const char *voxdir)
{
cst_voice *v;
cst_lexicon *lex;
if (cmu_us_kal_diphone)
return cmu_us_kal_diphone; /* Already registered */
v = new_voice();
v->name = "kal";
/* Set up basic values for synthesizing with this voice */
usenglish_init(v);
#ifndef FLITE_PLUS_HTS_ENGINE
flite_feat_set_string(v->features,"name","cmu_us_kal_diphone");
#endif /* !FLITE_PLUS_HTS_ENGINE */
/* Lexicon */
lex = cmu_lex_init();
flite_feat_set(v->features,"lexicon",lexicon_val(lex));
#ifndef FLITE_PLUS_HTS_ENGINE
/* Intonation */
flite_feat_set_float(v->features,"int_f0_target_mean",95.0);
flite_feat_set_float(v->features,"int_f0_target_stddev",11.0);
flite_feat_set_float(v->features,"duration_stretch",1.1);
#endif /* !FLITE_PLUS_HTS_ENGINE */
/* Post lexical rules */
flite_feat_set(v->features,"postlex_func",uttfunc_val(&cmu_us_kal_postlex));
#ifndef FLITE_PLUS_HTS_ENGINE
/* Waveform synthesis: diphone_synth */
flite_feat_set(v->features,"wave_synth_func",uttfunc_val(&diphone_synth));
flite_feat_set(v->features,"diphone_db",diphone_db_val(&cmu_us_kal_db));
flite_feat_set_int(v->features,"sample_rate",cmu_us_kal_db.sts->sample_rate);
flite_feat_set_string(v->features,"resynth_type","fixed");
flite_feat_set_string(v->features,"join_type","modified_lpc");
#endif /* !FLITE_PLUS_HTS_ENGINE */
cmu_us_kal_diphone = v;
return cmu_us_kal_diphone;
}
void unregister_cmu_us_kal(cst_voice *v)
{
if (v != cmu_us_kal_diphone)
return;
delete_voice(v);
cmu_us_kal_diphone = NULL;
}
#ifndef FLITE_PLUS_HTS_ENGINE
static void fix_ah(cst_utterance *u)
{
/* This should really be done in the index itself */
const cst_item *s;
for (s=relation_head(utt_relation(u,"Segment")); s; s=item_next(s))
if (cst_streq(item_feat_string(s,"name"),"ah"))
item_set_string(s,"name","aa");
}
#endif /* !FLITE_PLUS_HTS_ENGINE */
static cst_utterance *cmu_us_kal_postlex(cst_utterance *u)
{
cmu_postlex(u);
#ifndef FLITE_PLUS_HTS_ENGINE
fix_ah(u);
#endif /* !FLITE_PLUS_HTS_ENGINE */
return u;
}
+374
View File
@@ -0,0 +1,374 @@
/*************************************************************************/
/* */
/* 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 */
/*************************************************************************/
/* */
/* CMU Lexicon definition */
/* */
/*************************************************************************/
#include "flite.h"
#include "cmu_lex.h"
extern const int cmu_lex_entry[];
extern const unsigned char cmu_lex_data[];
extern const int cmu_lex_num_entries;
extern const int cmu_lex_num_bytes;
extern const char * const cmu_lex_phone_table[54];
extern const char * const cmu_lex_phones_huff_table[];
extern const char * const cmu_lex_entries_huff_table[];
static int cmu_is_vowel(const char *p);
static int cmu_is_silence(const char *p);
static int cmu_has_vowel_in_list(const cst_val *v);
static int cmu_has_vowel_in_syl(const cst_item *i);
static int cmu_sonority(const char *p);
static const char * const addenda0[] = { "p,", NULL };
static const char * const addenda1[] = { "p.", NULL };
static const char * const addenda2[] = { "p(", NULL };
static const char * const addenda3[] = { "p)", NULL };
static const char * const addenda4[] = { "p[", NULL };
static const char * const addenda5[] = { "p]", NULL };
static const char * const addenda6[] = { "p{", NULL };
static const char * const addenda7[] = { "p}", NULL };
static const char * const addenda8[] = { "p:", NULL };
static const char * const addenda9[] = { "p;", NULL };
static const char * const addenda10[] = { "p?", NULL};
static const char * const addenda11[] = { "p!", NULL };
static const char * const addenda12[] = { "n@", "ae1", "t", NULL };
static const char * const addenda13[] = { "n#", "hh", "ae1","sh", NULL };
static const char * const addenda14[] = { "n$", "d", "aa1", "l", "er", NULL };
static const char * const addenda15[] = { "n%", "p", "er", "s", "eh1", "n", "t", NULL };
static const char * const addenda16[] = { "n^", "k", "eh1", "r", "eh1", "t", NULL };
static const char * const addenda17[] = { "n&","ae1","m","p","er","s","ae1","n","d", NULL };
static const char * const addenda18[] = { "n*","ae1","s","t","er","ih1","s","k",NULL };
static const char * const addenda19[] = { "n|","b","aa1","r",NULL };
static const char * const addenda20[] = { "n\\","b","ae1","k","s","l","ae1","sh",NULL };
static const char * const addenda21[] = { "n=","iy1","k","w","ax","l","z",NULL};
static const char * const addenda22[] = { "n+","p","l","ah1","s",NULL};
static const char * const addenda23[] = { "n~","t","ih1","l","d","ax",NULL};
static const char * const addenda24[] = { "p'",NULL};
static const char * const addenda25[] = { "p`",NULL};
static const char * const addenda26[] = { "p\"",NULL};
static const char * const addenda27[] = { "p-",NULL};
static const char * const addenda28[] = { "p<",NULL};
static const char * const addenda29[] = { "p>",NULL};
static const char * const addenda30[] = { "n_","ah1","n","d","er","s","k","ao1","r",NULL};
static const char * const addenda31[] = { "s's","z",NULL};
static const char * const addenda32[] = { "nim","ay1","m",NULL};
static const char * const addenda33[] = { "vdoesnt","d","ah1","z","n","t",NULL};
static const char * const addenda34[] = { "vyoull","y","uw1","l",NULL};
static const char * const addenda35[] = { "n/","s","l","ae1","sh",NULL};
static const char * const addenda36[] = { "nin","ih","n",NULL};
static const char * const addenda37[] = { "nto","t","ax",NULL};
static const char * const addenda38[] = { "n_a","ey",NULL};
static const char * const addenda39[] = { "vhavent","hh","ae1","v","ax","n","t",NULL};
static const char * const * const addenda[] = {
addenda0,
addenda1,
addenda2,
addenda3,
addenda4,
addenda5,
addenda6,
addenda7,
addenda8,
addenda9,
addenda10,
addenda11,
addenda12,
addenda13,
addenda14,
addenda15,
addenda16,
addenda17,
addenda18,
addenda19,
addenda20,
addenda21,
addenda22,
addenda23,
addenda24,
addenda25,
addenda26,
addenda27,
addenda28,
addenda29,
addenda30,
addenda31,
addenda32,
addenda33,
addenda34,
addenda35,
addenda36,
addenda37,
addenda38,
addenda39,
NULL };
static int cmu_is_silence(const char *p)
{
if (cst_streq(p,"pau"))
return TRUE;
else
return FALSE;
}
static int cmu_has_vowel_in_list(const cst_val *v)
{
const cst_val *t;
for (t=v; t; t=val_cdr(t))
if (cmu_is_vowel(val_string(val_car(t))))
return TRUE;
return FALSE;
}
static int cmu_has_vowel_in_syl(const cst_item *i)
{
const cst_item *n;
for (n=i; n; n=item_prev(n))
if (cmu_is_vowel(item_feat_string(n,"name")))
return TRUE;
return FALSE;
}
static int cmu_is_vowel(const char *p)
{
/* this happens to work for US English phoneset */
if (strchr("aeiou",p[0]) == NULL)
return FALSE;
else
return TRUE;
}
static int cmu_sonority(const char *p)
{
/* A bunch of hacks for US English phoneset */
if (cmu_is_vowel(p) || (cmu_is_silence(p)))
return 5;
else if (strchr("wylr",p[0]) != NULL)
return 4; /* glides/liquids */
else if (strchr("nm",p[0]) != NULL)
return 3; /* nasals */
else if (strchr("bdgjlmnnnrvwyz",p[0]) != NULL)
return 2; /* voiced obstruents */
else
return 1;
}
int cmu_syl_boundary(const cst_item *i,const cst_val *rest)
{
/* Returns TRUE if this should be a syllable boundary */
/* This is of course phone set dependent */
int p, n, nn;
if (rest == NULL)
return TRUE;
else if (cmu_is_silence(val_string(val_car(rest))))
return TRUE;
else if (!cmu_has_vowel_in_list(rest)) /* no more vowels so rest *all* coda */
return FALSE;
else if (!cmu_has_vowel_in_syl(i)) /* need a vowel */
return FALSE;
else if (cmu_is_vowel(val_string(val_car(rest))))
return TRUE;
else if (val_cdr(rest) == NULL)
return FALSE;
else
{ /* so there is following vowel, and multiple phones left */
p = cmu_sonority(item_feat_string(i,"name"));
n = cmu_sonority(val_string(val_car(rest)));
nn = cmu_sonority(val_string(val_car(val_cdr(rest))));
if ((p <= n) && (n <= nn))
return TRUE;
else
return FALSE;
}
}
static int cmulex_dist_to_vowel(const cst_val *rest)
{
if (rest == 0)
return 0; /* shouldn't get here */
else if (cmu_is_vowel(val_string(val_car(rest))))
return 0;
else
return 1+cmulex_dist_to_vowel(val_cdr(rest));
}
static const char * const cmulex_onset_trigrams[] = {
"str", "spy", "spr", "spl", "sky", "skw", "skr", "skl", NULL
};
static const char * const cmulex_onset_bigrams[] = {
"zw", "zl",
"vy", "vr", "vl",
"thw", "thr",
"ty", "tw",
"tr", /* "ts", */
"shw", "shr", "shn", "shm", "shl",
"sw", "sv", "st", "sr", "sp", "sn", "sm", "sl", "sk", "sf",
"py", "pw", "pr", "pl",
"ny",
"my", "mr",
"ly",
"ky", "kw", "kr", "kl",
"hhy", "hhw", "hhr", "hhl",
"gy", "gw", "gr", "gl",
"fy", "fr", "fl",
"dy", "dw", "dr",
"by", "bw", "br", "bl",
NULL
};
static int cmulex_onset_bigram(const cst_val *rest)
{
char x[10];
int i;
cst_sprintf(x,"%s%s",val_string(val_car(rest)),
val_string(val_car(val_cdr(rest))));
for (i=0; cmulex_onset_bigrams[i]; i++)
if (cst_streq(x,cmulex_onset_bigrams[i]))
return TRUE;
return FALSE;
}
static int cmulex_onset_trigram(const cst_val *rest)
{
char x[15];
int i;
cst_sprintf(x,"%s%s%s",val_string(val_car(rest)),
val_string(val_car(val_cdr(rest))),
val_string(val_car(val_cdr(val_cdr(rest)))));
for (i=0; cmulex_onset_trigrams[i]; i++)
if (cst_streq(x,cmulex_onset_trigrams[i]))
return TRUE;
return FALSE;
}
int cmu_syl_boundary_mo(const cst_item *i,const cst_val *rest)
{
/* syl boundary maximal onset */
int d2v;
if (rest == NULL)
return TRUE;
else if (cmu_is_silence(val_string(val_car(rest))))
return TRUE;
else if (!cmu_has_vowel_in_list(rest))
/* no more vowels so rest *all* coda */
return FALSE;
else if (!cmu_has_vowel_in_syl(i)) /* need a vowel */
/* no vowel yet in syl so keep copying */
return FALSE;
else if (cmu_is_vowel(val_string(val_car(rest))))
/* next is a vowel, syl has vowel, so this is a break */
return TRUE;
else if (cst_streq("ng",val_string(val_car(rest))))
/* next is "ng" which can't start a word internal syl */
return FALSE;
else
{
/* want to know if from rest to the next vowel is a valid onset */
d2v = cmulex_dist_to_vowel(rest);
if (d2v < 2)
return TRUE;
else if (d2v > 3)
return FALSE;
else if (d2v == 2)
return cmulex_onset_bigram(rest);
else /* if (d2v == 3) */
return cmulex_onset_trigram(rest);
return TRUE;
}
}
cst_lexicon cmu_lex;
cst_lts_rules cmu_lts_rules;
extern const char * const cmu_lts_phone_table[];
extern const char * const cmu_lts_letter_table[];
extern const cst_lts_addr cmu_lts_letter_index[];
extern const cst_lts_model cmu_lts_model[];
cst_lexicon *cmu_lex_init()
{
/* I'd like to do this as a const but it needs everything in this */
/* file and already the bits are too big for some compilers */
if (cmu_lts_rules.name)
return &cmu_lex; /* Already initialized */
cmu_lts_rules.name = "cmu";
cmu_lts_rules.letter_index = cmu_lts_letter_index;
#ifdef CST_NO_STATIC_LTS_MODEL
/* cmu_lts_rules.models will be set elsewhere */
#else
cmu_lts_rules.models = cmu_lts_model;
#endif
cmu_lts_rules.phone_table = cmu_lts_phone_table;
cmu_lts_rules.context_window_size = 4;
cmu_lts_rules.context_extra_feats = 1;
cmu_lts_rules.letter_table = 0 /* cmu_lts_letter_table */;
cmu_lex.name = "cmu";
cmu_lex.num_entries = cmu_lex_num_entries;
#ifdef CST_NO_STATIC_LEX
/* cmu_lex.data will be set elsewhere */
#else
cmu_lex.data = cmu_lex_data;
#endif
cmu_lex.num_bytes = cmu_lex_num_bytes;
cmu_lex.phone_table = (char **) cmu_lex_phone_table;
cmu_lex.syl_boundary = cmu_syl_boundary_mo;
cmu_lex.addenda = (char ***) addenda;
cmu_lex.lts_rule_set = (cst_lts_rules *) &cmu_lts_rules;
cmu_lex.phone_hufftable = cmu_lex_phones_huff_table;
cmu_lex.entry_hufftable = cmu_lex_entries_huff_table;
cmu_lex.postlex = cmu_postlex;
return &cmu_lex;
}
+55
View File
@@ -0,0 +1,55 @@
/*************************************************************************/
/* */
/* Language Technologies Institute */
/* Carnegie Mellon University */
/* Copyright (c) 2001-2008 */
/* 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 2008 */
/*************************************************************************/
/* CMU Lexicon public functions */
/*************************************************************************/
#ifndef _CMU_LEX_H_
#define _CMU_LEX_H_
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#include "cst_lexicon.h"
cst_lexicon *cmu_lex_init(void);
cst_utterance *cmu_postlex(cst_utterance *u);
#ifdef __cplusplus
} /* extern "C" */
#endif /* __cplusplus */
#endif
@@ -0,0 +1,10 @@
/*******************************************************/
/** generated lexicon data file from cmu */
/*******************************************************/
const unsigned char cmu_lex_data[] =
{
0,
#include "cmu_lex_data_raw.c"
};
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,88 @@
/*******************************************************/
/** generated lexicon entry file from cmu */
/*******************************************************/
#include "cst_string.h"
#include "cst_lexicon.h"
const int cmu_lex_num_bytes =
#include "cmu_lex_num_bytes.c"
;
const int cmu_lex_num_entries = 36963;
const char * const cmu_lex_phone_table[57] =
{
"_epsilon_",
"ax0",
"ey1",
"l",
"p",
"ih1",
"r",
"t",
"g",
"er0",
"b",
"aa1",
"n",
"k",
"th",
"eh0",
"s",
"m",
"ao1",
"eh1",
"d",
"aa0",
"ae1",
"ow1",
"ih0",
"iy0",
"ow0",
"ey0",
"uw1",
"v",
"iy1",
"z",
"uw0",
"ng",
"sh",
"ae0",
"ah1",
"ao0",
"f",
"hh",
"ay1",
"jh",
"aw1",
"aw0",
"ch",
"zh",
"y",
"uh1",
"dh",
"w",
"er1",
"oy1",
"ay0",
"oy0",
"uh0",
"ah0",
NULL
};
const char * const cmu_lex_phones_huff_table[257] =
{
NULL, /* reserved */
#include "cmu_lex_phones_huff_table.c"
NULL
};
const char * const cmu_lex_entries_huff_table[257] =
{
NULL, /* reserved */
#include "cmu_lex_entries_huff_table.c"
NULL
};
@@ -0,0 +1,254 @@
"q" , /* 0.000147 */
"ment" , /* 0.000733 */
"ors" , /* 0.000733 */
"0del" , /* 0.000739 */
"gr" , /* 0.000739 */
"iss" , /* 0.000739 */
"ano" , /* 0.000750 */
"enb" , /* 0.000750 */
"ette" , /* 0.000750 */
"ult" , /* 0.000750 */
"0im" , /* 0.000762 */
"ug" , /* 0.000762 */
"0ab" , /* 0.000768 */
"0th" , /* 0.000774 */
"orn" , /* 0.000774 */
"ost" , /* 0.000780 */
"pl" , /* 0.000780 */
"0ac" , /* 0.000785 */
"eb" , /* 0.000791 */
"ern" , /* 0.000791 */
"ord" , /* 0.000791 */
"let" , /* 0.000803 */
"owski" , /* 0.000815 */
"pr" , /* 0.000821 */
"ind" , /* 0.000826 */
"ann" , /* 0.000832 */
"iel" , /* 0.000832 */
"ina" , /* 0.000838 */
"0el" , /* 0.000850 */
"ted" , /* 0.000850 */
"ish" , /* 0.000856 */
"0fr" , /* 0.000862 */
"ok" , /* 0.000867 */
"ally" , /* 0.000873 */
"oll" , /* 0.000873 */
"ons" , /* 0.000879 */
"ge" , /* 0.000885 */
"ial" , /* 0.000885 */
"af" , /* 0.000891 */
"ath" , /* 0.000897 */
"ick" , /* 0.000920 */
"0dis" , /* 0.000926 */
"0pro" , /* 0.000938 */
"ont" , /* 0.000938 */
"0car" , /* 0.000950 */
"ins" , /* 0.000950 */
"able" , /* 0.000955 */
"0sp" , /* 0.000996 */
"ph" , /* 0.001002 */
"ino" , /* 0.001008 */
"ast" , /* 0.001043 */
"enc" , /* 0.001067 */
"ore" , /* 0.001067 */
"0y" , /* 0.001078 */
"her" , /* 0.001084 */
"our" , /* 0.001084 */
"0gr" , /* 0.001090 */
"ki" , /* 0.001090 */
"one" , /* 0.001090 */
"ler" , /* 0.001102 */
"ev" , /* 0.001114 */
"0br" , /* 0.001120 */
"0ad" , /* 0.001131 */
"az" , /* 0.001131 */
"ett" , /* 0.001172 */
"0am" , /* 0.001178 */
"0ex" , /* 0.001196 */
"ik" , /* 0.001207 */
"err" , /* 0.001225 */
"ew" , /* 0.001225 */
"co" , /* 0.001243 */
"if" , /* 0.001248 */
"eg" , /* 0.001254 */
"man" , /* 0.001272 */
"aw" , /* 0.001284 */
"0sh" , /* 0.001295 */
"ek" , /* 0.001295 */
"up" , /* 0.001295 */
"0com" , /* 0.001301 */
"0pr" , /* 0.001307 */
"ne" , /* 0.001313 */
"ans" , /* 0.001319 */
"gh" , /* 0.001348 */
"anc" , /* 0.001354 */
"ated" , /* 0.001360 */
"ous" , /* 0.001372 */
"ud" , /* 0.001372 */
"0tr" , /* 0.001377 */
"ob" , /* 0.001389 */
"ort" , /* 0.001389 */
"ski" , /* 0.001389 */
"0mar" , /* 0.001407 */
"st" , /* 0.001413 */
"ach" , /* 0.001418 */
"ies" , /* 0.001430 */
"he" , /* 0.001436 */
"ass" , /* 0.001489 */
"ah" , /* 0.001495 */
"uc" , /* 0.001495 */
"0ar" , /* 0.001501 */
"ub" , /* 0.001506 */
"end" , /* 0.001524 */
"ert" , /* 0.001559 */
"0z" , /* 0.001571 */
"ich" , /* 0.001577 */
"ens" , /* 0.001583 */
"ly" , /* 0.001583 */
"ang" , /* 0.001629 */
"ier" , /* 0.001629 */
"op" , /* 0.001635 */
"0st" , /* 0.001641 */
"0le" , /* 0.001670 */
"ity" , /* 0.001670 */
"arr" , /* 0.001682 */
"ip" , /* 0.001735 */
"ate" , /* 0.001770 */
"ou" , /* 0.001782 */
"iz" , /* 0.001788 */
"ie" , /* 0.001817 */
"ib" , /* 0.001823 */
"0mc" , /* 0.001835 */
"ak" , /* 0.001852 */
"ov" , /* 0.001870 */
"ey" , /* 0.001876 */
"0sch" , /* 0.001893 */
"art" , /* 0.001893 */
"ay" , /* 0.001969 */
"ter" , /* 0.002005 */
"io" , /* 0.002040 */
"0de" , /* 0.002134 */
"ff" , /* 0.002186 */
"oc" , /* 0.002192 */
"0e" , /* 0.002198 */
"ion" , /* 0.002216 */
"od" , /* 0.002227 */
"0con" , /* 0.002268 */
"0al" , /* 0.002286 */
"ard" , /* 0.002298 */
"ine" , /* 0.002327 */
"um" , /* 0.002339 */
"est" , /* 0.002374 */
"0un" , /* 0.002391 */
"ian" , /* 0.002415 */
"ill" , /* 0.002450 */
"all" , /* 0.002462 */
"og" , /* 0.002468 */
"ess" , /* 0.002479 */
"av" , /* 0.002520 */
"ap" , /* 0.002538 */
"ow" , /* 0.002556 */
"te" , /* 0.002591 */
"0j" , /* 0.002614 */
"0ch" , /* 0.002685 */
"tr" , /* 0.002708 */
"j" , /* 0.002731 */
"au" , /* 0.002767 */
"0o" , /* 0.002796 */
"ant" , /* 0.002813 */
"ation" , /* 0.002854 */
"ia" , /* 0.002866 */
"ers" , /* 0.002907 */
"qu" , /* 0.002931 */
"iv" , /* 0.002989 */
"ab" , /* 0.002995 */
"0re" , /* 0.003030 */
"and" , /* 0.003171 */
"ist" , /* 0.003212 */
"x" , /* 0.003212 */
"im" , /* 0.003253 */
"un" , /* 0.003318 */
"ir" , /* 0.003505 */
"ul" , /* 0.003570 */
"ot" , /* 0.003646 */
"ut" , /* 0.003792 */
"ig" , /* 0.003804 */
"0in" , /* 0.003822 */
"ell" , /* 0.003851 */
"id" , /* 0.003956 */
"0a" , /* 0.004033 */
"om" , /* 0.004203 */
"ent" , /* 0.004261 */
"ec" , /* 0.004308 */
"ad" , /* 0.004384 */
"0w" , /* 0.004460 */
"em" , /* 0.004496 */
"ag" , /* 0.004572 */
"0n" , /* 0.004589 */
"w" , /* 0.004672 */
"0v" , /* 0.004841 */
"re" , /* 0.004853 */
"ro" , /* 0.005029 */
"ac" , /* 0.005252 */
"ch" , /* 0.005357 */
"il" , /* 0.005398 */
"us" , /* 0.005451 */
"0t" , /* 0.005697 */
"0f" , /* 0.005814 */
"am" , /* 0.005855 */
"le" , /* 0.005855 */
"et" , /* 0.006119 */
"0k" , /* 0.006207 */
"f" , /* 0.006248 */
"ur" , /* 0.006283 */
"os" , /* 0.006700 */
"z" , /* 0.006764 */
"as" , /* 0.006916 */
"is" , /* 0.007250 */
"0l" , /* 0.007315 */
"0g" , /* 0.007678 */
"ol" , /* 0.007708 */
"ing" , /* 0.007725 */
"0h" , /* 0.007889 */
"v" , /* 0.008270 */
"0r" , /* 0.008329 */
"it" , /* 0.008511 */
"at" , /* 0.008657 */
"g" , /* 0.008681 */
"0d" , /* 0.008827 */
"el" , /* 0.008827 */
"b" , /* 0.009015 */
"or" , /* 0.009073 */
"m" , /* 0.009173 */
"k" , /* 0.009226 */
"d" , /* 0.009449 */
"ic" , /* 0.009484 */
"u" , /* 0.009654 */
"ed" , /* 0.009771 */
"an" , /* 0.010498 */
"p" , /* 0.010591 */
"l" , /* 0.010890 */
"n" , /* 0.010896 */
"0p" , /* 0.011230 */
"c" , /* 0.011295 */
"en" , /* 0.011365 */
"0c" , /* 0.011670 */
"in" , /* 0.011693 */
"r" , /* 0.011793 */
"t" , /* 0.012086 */
"al" , /* 0.012139 */
"on" , /* 0.012350 */
"ar" , /* 0.012473 */
"0s" , /* 0.012549 */
"0b" , /* 0.012825 */
"es" , /* 0.013206 */
"h" , /* 0.013616 */
"0m" , /* 0.014132 */
"0" , /* 0.014489 */
"y" , /* 0.014900 */
"i" , /* 0.016986 */
"s" , /* 0.017185 */
"o" , /* 0.018803 */
"er" , /* 0.019331 */
"a" , /* 0.021816 */
"e" , /* 0.027378 */
@@ -0,0 +1 @@
410522
@@ -0,0 +1,254 @@
"\067" , /* 0.000024 */
"\065" , /* 0.000380 */
"\021\013\006" , /* 0.000771 */
"\002\007\001\024" , /* 0.000777 */
"\013\007" , /* 0.000783 */
"\021\026\014" , /* 0.000783 */
"\001\004" , /* 0.000789 */
"\046\031" , /* 0.000789 */
"\003\036" , /* 0.000801 */
"\010\011" , /* 0.000801 */
"\013\006\024" , /* 0.000801 */
"\015\001\003" , /* 0.000801 */
"\026\024" , /* 0.000813 */
"\036\014\001" , /* 0.000813 */
"\004\001\003" , /* 0.000819 */
"\001\012\001\003" , /* 0.000825 */
"\005\021" , /* 0.000825 */
"\022\006\001" , /* 0.000831 */
"\050\006" , /* 0.000831 */
"\012\026" , /* 0.000837 */
"\030\007\031" , /* 0.000837 */
"\044\003" , /* 0.000843 */
"\017\020" , /* 0.000849 */
"\032\014" , /* 0.000849 */
"\013\020" , /* 0.000855 */
"\004\026" , /* 0.000874 */
"\036\037" , /* 0.000874 */
"\050\024" , /* 0.000874 */
"\001\014\024" , /* 0.000916 */
"\005\010" , /* 0.000916 */
"\012\003" , /* 0.000928 */
"\046\003" , /* 0.000928 */
"\001\003\031" , /* 0.000934 */
"\001\014\037" , /* 0.000934 */
"\013\014\032" , /* 0.000934 */
"\020\011" , /* 0.000934 */
"\066" , /* 0.000934 */
"\005\003\001" , /* 0.000940 */
"\012\062" , /* 0.000940 */
"\030\051" , /* 0.000940 */
"\013\010" , /* 0.000946 */
"\050\007" , /* 0.000952 */
"\012\031" , /* 0.000958 */
"\005\037" , /* 0.000964 */
"\022\014" , /* 0.000964 */
"\023\014\007" , /* 0.000964 */
"\015\001\021" , /* 0.000970 */
"\032\003" , /* 0.000976 */
"\036\003" , /* 0.000982 */
"\036\014\032" , /* 0.000982 */
"\005\020\007" , /* 0.000994 */
"\020\001\003" , /* 0.000994 */
"\023\024" , /* 0.000994 */
"\043\015" , /* 0.000994 */
"\060" , /* 0.000994 */
"\025\021" , /* 0.001000 */
"\051\031" , /* 0.001012 */
"\054\031" , /* 0.001018 */
"\015\011" , /* 0.001024 */
"\007\001\024" , /* 0.001030 */
"\023\003\001" , /* 0.001036 */
"\023\021" , /* 0.001036 */
"\053" , /* 0.001042 */
"\013\003\001" , /* 0.001054 */
"\037\031" , /* 0.001078 */
"\022\006\031" , /* 0.001084 */
"\023\020\007" , /* 0.001084 */
"\001\020\007" , /* 0.001090 */
"\015\027" , /* 0.001109 */
"\026\014\024" , /* 0.001109 */
"\023\020" , /* 0.001115 */
"\003\026" , /* 0.001127 */
"\001\014\020" , /* 0.001133 */
"\024\036" , /* 0.001133 */
"\006\027" , /* 0.001151 */
"\057\006" , /* 0.001157 */
"\036\014\031" , /* 0.001163 */
"\022\046" , /* 0.001193 */
"\021\011" , /* 0.001199 */
"\005\007" , /* 0.001223 */
"\027\014\031" , /* 0.001223 */
"\005\020" , /* 0.001247 */
"\006\023" , /* 0.001259 */
"\035\031" , /* 0.001277 */
"\002\003" , /* 0.001289 */
"\046\011" , /* 0.001289 */
"\050\037" , /* 0.001289 */
"\024\032" , /* 0.001295 */
"\017\015" , /* 0.001313 */
"\007\001\014" , /* 0.001319 */
"\041\015" , /* 0.001319 */
"\020\036" , /* 0.001325 */
"\063" , /* 0.001325 */
"\030\010" , /* 0.001331 */
"\012\001\003" , /* 0.001362 */
"\021\026" , /* 0.001374 */
"\024\006" , /* 0.001380 */
"\055" , /* 0.001392 */
"\004\011" , /* 0.001398 */
"\030\020\007" , /* 0.001416 */
"\030\021" , /* 0.001422 */
"\013\021" , /* 0.001458 */
"\017\003" , /* 0.001464 */
"\046\006" , /* 0.001488 */
"\004\003" , /* 0.001494 */
"\056\040" , /* 0.001494 */
"\015\001" , /* 0.001506 */
"\023\006\031" , /* 0.001512 */
"\015\061" , /* 0.001536 */
"\015\026" , /* 0.001542 */
"\020\001" , /* 0.001548 */
"\024\023" , /* 0.001572 */
"\007\032" , /* 0.001590 */
"\015\003" , /* 0.001603 */
"\015\013\014" , /* 0.001603 */
"\043\014" , /* 0.001603 */
"\011\037" , /* 0.001627 */
"\041\010" , /* 0.001663 */
"\001\014\007" , /* 0.001681 */
"\025\003" , /* 0.001681 */
"\020\007\006" , /* 0.001711 */
"\005\015" , /* 0.001741 */
"\023\006\001" , /* 0.001765 */
"\045" , /* 0.001771 */
"\030\035" , /* 0.001783 */
"\017\014" , /* 0.001789 */
"\021\004" , /* 0.001789 */
"\022\003" , /* 0.001795 */
"\002\014" , /* 0.001801 */
"\021\001\015" , /* 0.001819 */
"\027\014" , /* 0.001819 */
"\021\001" , /* 0.001874 */
"\035\011" , /* 0.001886 */
"\015\032" , /* 0.001898 */
"\042\001\014" , /* 0.001952 */
"\024\001" , /* 0.001970 */
"\006\036" , /* 0.002018 */
"\001\012" , /* 0.002060 */
"\005\006" , /* 0.002060 */
"\044\014" , /* 0.002072 */
"\013\015" , /* 0.002121 */
"\020\001\014" , /* 0.002139 */
"\024\011" , /* 0.002175 */
"\057" , /* 0.002181 */
"\015\001\014" , /* 0.002193 */
"\013\003" , /* 0.002229 */
"\026\021" , /* 0.002241 */
"\050\014" , /* 0.002253 */
"\030\007" , /* 0.002283 */
"\002\007" , /* 0.002289 */
"\030\037" , /* 0.002295 */
"\027\003" , /* 0.002313 */
"\023\007" , /* 0.002325 */
"\024\031" , /* 0.002332 */
"\012\011" , /* 0.002416 */
"\015\006" , /* 0.002434 */
"\020\031" , /* 0.002458 */
"\024\030" , /* 0.002470 */
"\041" , /* 0.002470 */
"\020\004" , /* 0.002494 */
"\043" , /* 0.002506 */
"\036\014" , /* 0.002603 */
"\001\024" , /* 0.002609 */
"\005\003" , /* 0.002663 */
"\012\006" , /* 0.002669 */
"\045\006" , /* 0.002693 */
"\010\006" , /* 0.002729 */
"\015\013" , /* 0.002735 */
"\007\001" , /* 0.002741 */
"\002\042\001\014" , /* 0.002850 */
"\025\014" , /* 0.002862 */
"\026\003" , /* 0.002886 */
"\001\037" , /* 0.002910 */
"\030\024" , /* 0.003054 */
"\026\015" , /* 0.003109 */
"\030\003" , /* 0.003175 */
"\064" , /* 0.003175 */
"\007\031" , /* 0.003217 */
"\007\011" , /* 0.003271 */
"\001\015" , /* 0.003368 */
"\021\001\014" , /* 0.003434 */
"\020\015\031" , /* 0.003458 */
"\033" , /* 0.003579 */
"\004\006" , /* 0.003705 */
"\056\034" , /* 0.003723 */
"\023\015" , /* 0.003946 */
"\007\006" , /* 0.004018 */
"\022" , /* 0.004157 */
"\052" , /* 0.004163 */
"\017" , /* 0.004193 */
"\030\020" , /* 0.004290 */
"\020\015" , /* 0.004368 */
"\023\003" , /* 0.004368 */
"\040" , /* 0.004434 */
"\023\006" , /* 0.004446 */
"\025\006" , /* 0.004488 */
"\007\020" , /* 0.004573 */
"\001\021" , /* 0.004735 */
"\003\001" , /* 0.004814 */
"\016" , /* 0.005109 */
"\013\014" , /* 0.005332 */
"\001\007" , /* 0.005621 */
"\006\031" , /* 0.005675 */
"\013\006" , /* 0.005711 */
"\023\014" , /* 0.005729 */
"\044" , /* 0.005850 */
"\026\014" , /* 0.005970 */
"\005\014" , /* 0.006055 */
"\056" , /* 0.006151 */
"\001\020" , /* 0.006169 */
"\022\006" , /* 0.006266 */
"\062" , /* 0.006404 */
"\003\031" , /* 0.006513 */
"\006\001" , /* 0.006567 */
"\030\041" , /* 0.006711 */
"\030" , /* 0.006910 */
"\025" , /* 0.006958 */
"\050" , /* 0.008127 */
"\030\015" , /* 0.008145 */
"\054" , /* 0.008212 */
"\020\007" , /* 0.008778 */
"\023" , /* 0.008832 */
"\030\014" , /* 0.008922 */
"\042" , /* 0.009826 */
"\051" , /* 0.009941 */
"\034" , /* 0.010182 */
"\026" , /* 0.010242 */
"\005" , /* 0.010645 */
"\061" , /* 0.011073 */
"\031" , /* 0.011314 */
"\013" , /* 0.011567 */
"\036" , /* 0.011652 */
"\027" , /* 0.011941 */
"\002" , /* 0.011947 */
"\001\003" , /* 0.013007 */
"\006" , /* 0.013110 */
"\001\014" , /* 0.013429 */
"\032" , /* 0.013664 */
"\047" , /* 0.013796 */
"\001" , /* 0.013839 */
"\011" , /* 0.014351 */
"\010" , /* 0.015345 */
"\046" , /* 0.015857 */
"\035" , /* 0.016556 */
"\014" , /* 0.016718 */
"\004" , /* 0.018056 */
"\003" , /* 0.018104 */
"\015" , /* 0.019514 */
"\012" , /* 0.021170 */
"\037" , /* 0.022357 */
"\021" , /* 0.025177 */
"\007" , /* 0.026273 */
"\024" , /* 0.026581 */
"\020" , /* 0.029376 */
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,154 @@
/*******************************************************/
/** Autogenerated lts rules (regex) for cmu */
/** from wfst/ */
/*******************************************************/
#include "cst_string.h"
#include "cst_lts.h"
#include "cst_lexicon.h"
const char * const cmu_lts_phone_table[76] =
{
"epsilon",
"eh1",
"aa1",
"ey1",
"aw1",
"ax0",
"ao1",
"ay0",
"aa0",
"ey0",
"ae1",
"ih1",
"aw0",
"ow0",
"ao0",
"ow1",
"eh0",
"ih0",
"w-ey1",
"w-ax0",
"y-ax0",
"ae0",
"ay1",
"ah0",
"ah1",
"b",
"ch",
"k",
"s",
"t-s",
"sh",
"d",
"t",
"jh",
"iy1",
"iy0",
"uw1",
"y-uw1",
"oy1",
"y-uw0",
"uw0",
"oy0",
"f",
"g",
"zh",
"hh",
"y",
"l",
"ax0-l",
"m",
"ax0-m",
"m-ae1",
"m-ax0",
"ng",
"n",
"n-y",
"uh1",
"uh0",
"w",
"w-ah1",
"er1",
"p",
"r",
"er0",
"z",
"th",
"dh",
"y-er0",
"y-uh1",
"y-er1",
"v",
"k-s",
"g-zh",
"k-sh",
"g-z",
NULL
};
const char * const cmu_lts_letter_table[30] =
{
"nothing",
"#",
"0",
"a",
"b",
"c",
"d",
"e",
"f",
"g",
"h",
"i",
"j",
"k",
"l",
"m",
"n",
"o",
"p",
"q",
"r",
"s",
"t",
"u",
"v",
"w",
"x",
"y",
"z",
NULL
};
const cst_lts_addr cmu_lts_letter_index[27] =
{
0, /* a */
5371, /* b */
5414, /* c */
6048, /* d */
6256, /* e */
10649, /* f */
10666, /* g */
11293, /* h */
11522, /* i */
15403, /* j */
15514, /* k */
15533, /* l */
15900, /* m */
15942, /* n */
16176, /* o */
19793, /* p */
19830, /* q */
19831, /* r */
21775, /* s */
22667, /* t */
22957, /* u */
24709, /* v */
24719, /* w */
24877, /* x */
24923, /* y */
25377, /* z */
0
};
@@ -0,0 +1,110 @@
/*************************************************************************/
/* */
/* Language Technologies Institute */
/* Carnegie Mellon University */
/* Copyright (c) 2001-2008 */
/* 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 2008 */
/*************************************************************************/
/* Moved the CMU lexicon specific postlexical rules into cmulex itself */
/*************************************************************************/
#include "flite.h"
static void apostrophe_s(cst_utterance *u)
{
cst_item *s;
cst_item *schwa;
cst_phoneset *ps=0;
const char *pname, *word;
ps = val_phoneset(feat_val(u->features,"phoneset"));
for (s=item_next(relation_head(utt_relation(u,"Segment")));
s; s=item_next(s))
{
word = val_string(ffeature(s, "R:SylStructure.parent.parent.name"));
if (cst_streq("'s", word))
{
pname = item_feat_string(item_prev(s),"name");
if ((strchr("fa",*phone_feature_string(ps,pname,"ctype")) != NULL)
&& (strchr("dbg",
*phone_feature_string(ps,pname,"cplace")) == NULL))
/* needs a schwa */
{
schwa = item_prepend(s,NULL);
item_set_string(schwa,"name","ax");
item_prepend(item_as(s,"SylStructure"),schwa);
}
else if (cst_streq("-",phone_feature_string(ps,pname,"cvox")))
item_set_string(s,"name","s");
}
else if (cst_streq("'ve", word)
|| cst_streq("'ll", word)
|| cst_streq("'d", word))
{
if (cst_streq("-",ffeature_string(s,"p.ph_vc")))
{
schwa = item_prepend(s,NULL);
item_set_string(schwa,"name","ax");
item_prepend(item_as(s,"SylStructure"),schwa);
}
}
}
}
static void the_iy_ax(cst_utterance *u)
{
const cst_item *i;
const char *word;
for (i = relation_head(utt_relation(u, "Segment")); i; i = item_next(i))
{
if (cst_streq("ax", item_name(i)))
{
word = ffeature_string(i,"R:SylStructure.parent.parent.name");
if (cst_streq("the", word)
&& cst_streq("+", ffeature_string(i,"n.ph_vc")))
item_set_string(i, "name", "iy");
}
}
}
cst_utterance *cmu_postlex(cst_utterance *u)
{
/* Post lexical rules */
apostrophe_s(u);
the_iy_ax(u);
return u;
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,410 @@
/*************************************************************************/
/* */
/* 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 */
/*************************************************************************/
/* */
/* English text expanders */
/* */
/* numbers, digits, ids (years), money */
/* */
/*************************************************************************/
#include <ctype.h>
#include "us_text.h"
static const char * const digit2num[] = {
"zero",
"one",
"two",
"three",
"four",
"five",
"six",
"seven",
"eight",
"nine" };
static const char * const digit2teen[] = {
"ten", /* shouldn't get called */
"eleven",
"twelve",
"thirteen",
"fourteen",
"fifteen",
"sixteen",
"seventeen",
"eighteen",
"nineteen" };
static const char * const digit2enty[] = {
"zero", /* shouldn't get called */
"ten",
"twenty",
"thirty",
"forty",
"fifty",
"sixty",
"seventy",
"eighty",
"ninety" };
static const char * const ord2num[] = {
"zeroth",
"first",
"second",
"third",
"fourth",
"fifth",
"sixth",
"seventh",
"eighth",
"ninth" };
static const char * const ord2teen[] = {
"tenth", /* shouldn't get called */
"eleventh",
"twelfth",
"thirteenth",
"fourteenth",
"fifteenth",
"sixteenth",
"seventeenth",
"eighteenth",
"nineteenth" };
static const char * const ord2enty[] = {
"zeroth", /* shouldn't get called */
"tenth",
"twentieth",
"thirtieth",
"fortieth",
"fiftieth",
"sixtieth",
"seventieth",
"eightieth",
"ninetieth" };
cst_val *en_exp_number(const char *numstring)
{
/* Expand given token to list of words pronouncing it as a number */
int num_digits = cst_strlen(numstring);
char part[4];
cst_val *p;
int i;
if (num_digits == 0)
return NULL;
else if (num_digits == 1)
return en_exp_digits(numstring);
else if (num_digits == 2)
{
if (numstring[0] == '0')
{
if (numstring[1] == '0')
return 0;
else
return cons_val(string_val(digit2num[numstring[1]-'0']),0);
}
else if (numstring[1] == '0')
return cons_val(string_val(digit2enty[numstring[0]-'0']),0);
else if (numstring[0] == '1')
return cons_val(string_val(digit2teen[numstring[1]-'0']),0);
else
return cons_val(string_val(digit2enty[numstring[0]-'0']),
en_exp_digits(numstring+1));
}
else if (num_digits == 3)
{
if (numstring[0] == '0')
return en_exp_number(numstring+1);
else
return cons_val(string_val(digit2num[numstring[0]-'0']),
cons_val(string_val("hundred"),
en_exp_number(numstring+1)));
}
else if (num_digits < 7)
{
for (i=0; i < num_digits-3; i++)
part[i] = numstring[i];
part[i]='\0';
p = en_exp_number(part);
if (p == 0) /* no thousands */
return en_exp_number(numstring+i);
else
return val_append(p,cons_val(string_val("thousand"),
en_exp_number(numstring+i)));
}
else if (num_digits < 10)
{
for (i=0; i < num_digits-6; i++)
part[i] = numstring[i];
part[i]='\0';
p = en_exp_number(part);
if (p == 0) /* no millions */
return en_exp_number(numstring+i);
else
return val_append(p,cons_val(string_val("million"),
en_exp_number(numstring+i)));
}
else if (num_digits < 13)
{ /* If there are pedantic brits out there, tough!, 10^9 is a billion */
for (i=0; i < num_digits-9; i++)
part[i] = numstring[i];
part[i]='\0';
p = en_exp_number(part);
if (p == 0) /* no billions */
return en_exp_number(numstring+i);
else
return val_append(p,cons_val(string_val("billion"),
en_exp_number(numstring+i)));
}
else /* Way too many digits here, to be a number */
{
return en_exp_digits(numstring);
}
}
cst_val *en_exp_ordinal(const char *rawnumstring)
{
/* return ordinal for digit string */
cst_val *card, *o;
const cst_val *t;
const char *l;
const char *ord;
char *numstring;
int i,j;
numstring = cst_strdup(rawnumstring);
for (j=i=0; i < cst_strlen(rawnumstring); i++)
if (rawnumstring[i] != ',')
{
numstring[j] = rawnumstring[i];
j++;
}
numstring[j] = '\0';
card = val_reverse(en_exp_number(numstring));
cst_free(numstring);
l = val_string(val_car(card));
ord = 0;
for (i=0; i<10; i++)
if (cst_streq(l,digit2num[i]))
ord = ord2num[i];
if (!ord)
for (i=0; i<10; i++)
if (cst_streq(l,digit2teen[i]))
ord = ord2teen[i];
if (!ord)
for (i=0; i<10; i++)
if (cst_streq(l,digit2enty[i]))
ord = ord2enty[i];
if (cst_streq(l,"hundred"))
ord = "hundredth";
if (cst_streq(l,"thousand"))
ord = "thousandth";
if (cst_streq(l,"billion"))
ord = "billtionth";
if (!ord) /* dunno, so don't convert anything */
return card;
o = cons_val(string_val(ord),0);
for (t=val_cdr(card); t; t=val_cdr(t))
o = cons_val(val_car(t),o);
delete_val(card);
return o;
}
cst_val *en_exp_id(const char *numstring)
{
/* Expand numstring as pairs as in years or ids */
char aaa[3];
if ((cst_strlen(numstring) == 4) &&
(numstring[2] == '0') &&
(numstring[3] == '0'))
{
if (numstring[1] == '0')
return en_exp_number(numstring); /* 2000, 3000 */
else
{
aaa[0] = numstring[0];
aaa[1] = numstring[1];
aaa[2] = '\0';
return val_append(en_exp_number(aaa),
cons_val(string_val("hundred"),0));
}
}
else if ((cst_strlen(numstring) == 3) &&
(numstring[0] != '0') &&
(numstring[1] == '0') &&
(numstring[2] == '0'))
{
return cons_val(string_val(digit2num[numstring[0]-'0']),
cons_val(string_val("hundred"),0));
}
else if ((cst_strlen(numstring) == 2) && (numstring[0] == '0')
&& (numstring[1] == '0'))
return cons_val(string_val("zero"),
cons_val(string_val("zero"),NULL));
else if ((cst_strlen(numstring) == 2) && (numstring[0] == '0'))
return cons_val(string_val("oh"),
en_exp_digits(&numstring[1]));
else if (((cst_strlen(numstring) == 4) &&
((numstring[1] == '0'))) ||
(cst_strlen(numstring) < 3))
return en_exp_number(numstring);
else if (cst_strlen(numstring)%2 == 1)
{
return cons_val(string_val(digit2num[numstring[0]-'0']),
en_exp_id(&numstring[1]));
}
else
{
aaa[0] = numstring[0];
aaa[1] = numstring[1];
aaa[2] = '\0';
return val_append(en_exp_number(aaa),en_exp_id(&numstring[2]));
}
}
cst_val *en_exp_real(const char *numstring)
{
char *aaa, *p;
cst_val *r;
if (numstring && (numstring[0] == '-'))
r = cons_val(string_val("minus"),
en_exp_real(&numstring[1]));
else if (numstring && (numstring[0] == '+'))
r = cons_val(string_val("plus"),
en_exp_real(&numstring[1]));
else if (((p=strchr(numstring,'e')) != 0) ||
((p=strchr(numstring,'E')) != 0))
{
aaa = cst_strdup(numstring);
aaa[cst_strlen(numstring)-cst_strlen(p)] = '\0';
r = val_append(en_exp_real(aaa),
cons_val(string_val("e"),
en_exp_real(p+1)));
cst_free(aaa);
}
else if ((p=strchr(numstring,'.')) != 0)
{
aaa = cst_strdup(numstring);
aaa[cst_strlen(numstring)-cst_strlen(p)] = '\0';
r = val_append(en_exp_number(aaa),
cons_val(string_val("point"),
en_exp_digits(p+1)));
cst_free(aaa);
}
else
r = en_exp_number(numstring); /* I don't think you can get here */
return r;
}
cst_val *en_exp_digits(const char *numstring)
{
/* Expand given token to list of words pronouncing it as digits */
cst_val *d = 0;
const char *p;
for (p=numstring; *p; p++)
{
if ((*p >= '0') && (*p <= '9'))
d = cons_val(string_val(digit2num[*p-'0']),d);
else
d = cons_val(string_val("umpty"),d);
}
return val_reverse(d);
}
cst_val *en_exp_letters(const char *lets)
{
/* returns these as list of single char symbols */
char *aaa;
cst_val *r;
int i;
aaa = cst_alloc(char,2);
aaa[1] = '\0';
for (r=0,i=0; lets[i] != '\0'; i++)
{
aaa[0] = lets[i];
if (isupper((int)aaa[0]))
aaa[0] = tolower((int)aaa[0]);
if (strchr("0123456789",aaa[0]))
r = cons_val(string_val(digit2num[aaa[0]-'0']),r);
else if (cst_streq(aaa,"a"))
r = cons_val(string_val("_a"),r);
else
r = cons_val(string_val(aaa),r);
}
cst_free(aaa);
return val_reverse(r);
}
int en_exp_roman(const char *roman)
{
int val;
const char *p;
val = 0;
for (p=roman; *p != 0; p++)
{
if (*p == 'X')
val += 10;
else if (*p == 'V')
val += 5;
else if (*p == 'I')
{
if (p[1] == 'V')
{
val += 4;
p++;
}
else if (p[1] == 'X')
{
val += 9;
p++;
}
else
val += 1;
}
}
return val;
}
@@ -0,0 +1,519 @@
/*************************************************************************/
/* */
/* 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 */
/*************************************************************************/
/* Feature functions used by various cart trees etc */
/* These have been create as needed, and as some of the trees are */
/* from University of Edinburgh's Festival system their names and */
/* semantics follow them */
/*************************************************************************/
/* ----------------------------------------------------------------- */
/* 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. */
/* ----------------------------------------------------------------- */
#include "cst_hrg.h"
#include "cst_phoneset.h"
#include "cst_regex.h"
#include "cst_ffeatures.h"
#include "us_ffeatures.h"
static const cst_val *gpos(const cst_item *word);
DEF_STATIC_CONST_VAL_STRING(val_string_numeric,"numeric");
DEF_STATIC_CONST_VAL_STRING(val_string_number,"number");
DEF_STATIC_CONST_VAL_STRING(val_string_month,"month");
DEF_STATIC_CONST_VAL_STRING(val_string_day,"day");
DEF_STATIC_CONST_VAL_STRING(val_string_other,"_other_");
DEF_STATIC_CONST_VAL_STRING(val_string_a,"a");
DEF_STATIC_CONST_VAL_STRING(val_string_flight,"flight");
DEF_STATIC_CONST_VAL_STRING(val_string_to,"to");
DEF_STATIC_CONST_VAL_STRING(val_string_content,"content");
static const cst_val *gpos(const cst_item *word)
{
/* Guess at part of speech (function/content) */
const char *w;
int s,t;
w = item_feat_string(word,"name");
for (s=0; us_gpos[s]; s++)
{
for (t=1; us_gpos[s][t]; t++)
if (cst_streq(w,val_string(us_gpos[s][t])))
return us_gpos[s][0];
}
return (cst_val *)&val_string_content;
}
static const cst_val *num_digits(const cst_item *token)
{
const char *name = item_feat_string(token,"name");
return val_int_n(cst_strlen(name));
}
static const cst_val *month_range(const cst_item *token)
{
int v = item_feat_int(token,"name");
if ((v > 0) && ( v < 32))
return VAL_STRING_1;
else
return VAL_STRING_0;
}
static const cst_val* token_pos_guess(const cst_item* token)
{
const char* name = item_feat_string(token, "name");
char* dc = cst_downcase(name);
const cst_val* r;
if (cst_regex_match(cst_rx_digits, dc))
r = (cst_val*)&val_string_numeric;
else if ((cst_regex_match(cst_rx_double, dc)) ||
(cst_regex_match(cst_rx_double, dc)))
r = (cst_val*)&val_string_number;
else if (cst_streq(dc, "jan") ||
cst_streq(dc, "january") ||
cst_streq(dc, "feb") ||
cst_streq(dc, "february") ||
cst_streq(dc, "mar") ||
cst_streq(dc, "march") ||
cst_streq(dc, "apr") ||
cst_streq(dc, "april") ||
cst_streq(dc, "may") ||
cst_streq(dc, "jun") ||
cst_streq(dc, "june") ||
cst_streq(dc, "jul") ||
cst_streq(dc, "july") ||
cst_streq(dc, "aug") ||
cst_streq(dc, "august") ||
cst_streq(dc, "sep") ||
cst_streq(dc, "sept") ||
cst_streq(dc, "september") ||
cst_streq(dc, "oct") ||
cst_streq(dc, "october") ||
cst_streq(dc, "nov") ||
cst_streq(dc, "november") ||
cst_streq(dc, "dec") ||
cst_streq(dc, "december"))
r = (cst_val*)&val_string_month;
else if (cst_streq(dc, "sun") ||
cst_streq(dc, "sunday") ||
cst_streq(dc, "mon") ||
cst_streq(dc, "monday") ||
cst_streq(dc, "tue") ||
cst_streq(dc, "tues") ||
cst_streq(dc, "tuesday") ||
cst_streq(dc, "wed") ||
cst_streq(dc, "wednesday") ||
cst_streq(dc, "thu") ||
cst_streq(dc, "thurs") ||
cst_streq(dc, "thursday") ||
cst_streq(dc, "fri") ||
cst_streq(dc, "friday") ||
cst_streq(dc, "sat") ||
cst_streq(dc, "saturday"))
r = (cst_val*)&val_string_day;
/* ignoring the "token_most_common" condition, does get used */
else if (cst_streq(dc, "a"))
r = (cst_val*)&val_string_a;
else if (cst_streq(dc, "flight"))
r = (cst_val*)&val_string_flight;
else if (cst_streq(dc, "to"))
r = (cst_val*)&val_string_to;
else
r = (cst_val*)&val_string_other;
cst_free(dc);
return r;
}
#ifdef FLITE_PLUS_HTS_ENGINE
const cst_val *accented(const cst_item *p); /* defined in cst_ffeatures.c */
int item_after_length(const cst_item *n){
int i = 0;
if(n == NULL) return 0;
for(;n;n=n->n,i++);
return i;
}
const cst_item *item_first(const cst_item *n){
if(n == 0) return 0;
for(;n->p != 0;n=n->p);
return n;
}
/* 11 12 13 53 54 */
static const cst_val *syl_numphones(const cst_item *syl){
return val_string_n(item_after_length(item_daughter(item_as(syl,"SylStructure"))));
}
/* 14 */
static const cst_val *pos_in_word(const cst_item *syl){
const cst_item *ss,*p;
int c = 0;
ss = item_as(syl,"SylStructure");
for(p = item_daughter(item_parent(ss));p;p = item_next(p),c++){
if(p == ss) return val_string_n(c);
}
return val_string_n(c);
}
/* 21 by Toda-san */
static const cst_val *lisp_distance_to_p_stress(const cst_item *syl){
const cst_item *s, *fs;
int c;
s=item_as(syl,"Syllable");
fs = path_to_item(syl,"R:SylStructure.parent.R:Phrase.parent.daughter.R:SylStructure.daughter");
if (item_equal(s,fs)) return val_string_n(0);
s=item_prev(s);
for (c=1; s && (!item_equal(s,fs)) && (c < CST_CONST_INT_MAX);
s=item_prev(s),c++)
if (strcmp("1", ffeature_string(s,"stress")) == 0) return val_string_n(c);
if (strcmp("1", ffeature_string(s,"stress")) == 0) return val_string_n(c);
else return val_string_n(0);
}
/* 22 by Toda-san */
static const cst_val *lisp_distance_to_n_stress(const cst_item *syl){
const cst_item *s, *fs;
int c;
s=item_as(syl,"Syllable");
fs = path_to_item(syl,"R:SylStructure.parent.R:Phrase.parent.daughtern.R:SylStructure.daughtern");
if (item_equal(s,fs)) return val_string_n(0);
s=item_next(s);
for (c=1; s && (!item_equal(s,fs)) && (c < CST_CONST_INT_MAX);
s=item_next(s),c++)
if (strcmp("1", ffeature_string(s,"stress")) == 0) return val_string_n(c);
if (strcmp("1", ffeature_string(s,"stress")) == 0) return val_string_n(c);
else return val_string_n(0);
}
/* 23 by Toda-san */
static const cst_val *lisp_distance_to_p_accent(const cst_item *syl){
const cst_item *s, *fs;
int c;
s=item_as(syl,"Syllable");
fs = path_to_item(syl,"R:SylStructure.parent.R:Phrase.parent.daughter.R:SylStructure.daughter");
if (item_equal(s,fs)) return val_string_n(0);
s=item_prev(s);
for (c=1; s && (!item_equal(s,fs)) && (c < CST_CONST_INT_MAX);
s=item_prev(s),c++)
if (val_int(accented(s))) return val_string_n(c);
if (val_int(accented(s))) return val_string_n(c);
else return val_string_n(0);
}
/* 24 by Toda-san */
static const cst_val *lisp_distance_to_n_accent(const cst_item *syl){
const cst_item *s, *fs;
int c;
s=item_as(syl,"Syllable");
fs = path_to_item(syl,"R:SylStructure.parent.R:Phrase.parent.daughtern.R:SylStructure.daughtern");
if (item_equal(s,fs)) return val_string_n(0);
s=item_next(s);
for (c=1; s && (!item_equal(s,fs)) && (c < CST_CONST_INT_MAX);
s=item_next(s),c++)
if (val_int(accented(s))) return val_string_n(c);
if (val_int(accented(s))) return val_string_n(c);
else return val_string_n(0);
}
/* 25 */
static char syl_vowel_str[16];
static cst_val syl_vowel_val;
static const cst_val *syl_vowel(const cst_item *syl){
/* the vowel in the syllable */
const cst_item *ss,*p;
int size;
CST_VAL_TYPE(&syl_vowel_val) = CST_VAL_TYPE_STRING;
ss = item_as(syl,"SylStructure");
for(p = item_daughter(ss),size = 0;p;p = item_next(p),size++){
if(strchr("aeiou",item_name(p)[0]) != NULL){
strcpy(syl_vowel_str,item_name(p));
CST_VAL_STRING_LVAL(&syl_vowel_val) = syl_vowel_str;
return &syl_vowel_val;
}
}
/* no vowel */
strcpy(syl_vowel_str,"novowel");
CST_VAL_STRING_LVAL(&syl_vowel_val) = syl_vowel_str;
return &syl_vowel_val;
}
/* 32 */
static const cst_val *pos_in_phrase(const cst_item *syl){
const cst_item *ss,*p;
int c = 0;
ss = item_as(syl,"Phrase");
for (p = item_first(ss);p;p=item_next(p),c++)
if(p == ss) return val_string_n(c);
return val_string_n(c);
}
/* 33 */
static const cst_val *words_out(const cst_item *syl){
const cst_item *ss,*p;
int c = 0;
ss = item_as(syl,"Phrase");
for(p = ss;p;p=item_next(p),c++);
return val_string_n(c);
}
/* 34 by Toda-san */
static const cst_val *content_words_in(const cst_item *word){
const cst_item *ss,*p,*fs;
int c;
ss = word;
fs = path_to_item(word,"R:Phrase.parent.daughter");
for (c=0, p=ss; p && (!item_equal(p,fs)) && (c < CST_CONST_INT_MAX);
p=item_prev(p))
if (cst_streq("content", ffeature_string(p,"gpos"))) c++;
return val_string_n(c); /* its used randomly as int and float */
}
/* 35 by Toda-san */
static const cst_val *content_words_out(const cst_item *word){
const cst_item *ss,*p,*fs;
int c;
ss = word;
fs = path_to_item(word,"R:Phrase.parent.daughtern");
for (c=0, p=ss; p && (!item_equal(p,fs)) && (c < CST_CONST_INT_MAX);
p=item_next(p))
if (cst_streq("content", ffeature_string(p,"gpos"))) c++;
return val_string_n(c); /* its used randomly as int and float */
}
/* 36 */
static const cst_val *lisp_distance_to_p_content(const cst_item *syl){
const cst_item *p;
int c = 0;
for(p=item_prev(item_as(syl,"Phrase"));p;p=item_prev(p)){
c++;
if(gpos(p)==(cst_val*)&val_string_content)
break;
}
return val_string_n(c);
}
/* 37 */
static const cst_val *lisp_distance_to_n_content(const cst_item *syl){
const cst_item *p;
int c = 0;
for(p=item_next(item_as(syl,"Phrase"));p;p=item_next(p)){
c++;
if (gpos(p)==(cst_val*)&val_string_content)
break;
}
return val_string_n(c);
}
/* 38 39 40 59 60 by Toda-san */
static const cst_val *lisp_num_syls_in_phrase(const cst_item *phrase){
const cst_item *sw,*fw;
int c;
sw = path_to_item(phrase,"daughter");
fw = path_to_item(phrase,"daughtern");
for (c=0; sw && (!item_equal(sw,fw)) && (c < CST_CONST_INT_MAX);
sw=item_next(sw)) c += ffeature_int(sw, "word_numsyls");
c += ffeature_int(sw, "word_numsyls");
return val_string_n(c);
}
/* 41 42 43 61 62 by Toda-san */
static const cst_val *lisp_num_words_in_phrase(const cst_item *phrase){
const cst_item *sw,*fw;
int c;
sw = path_to_item(phrase,"daughter");
fw = path_to_item(phrase,"daughtern");
for (c=1; sw && (!item_equal(sw,fw)) && (c < CST_CONST_INT_MAX);
sw=item_next(sw)) c++;
return val_string_n(c);
}
/* 46 by Toda-san */
static const cst_val *lisp_total_syls(const cst_item *phrase){
const cst_item *sp, *fp;
int c;
sp = phrase;
while (item_prev(sp) != NULL) sp = item_prev(sp);
fp = phrase;
while (item_next(fp) != NULL) fp = item_next(fp);
for (c = 0; sp && (!item_equal(sp, fp)) && (c < CST_CONST_INT_MAX);
sp = item_next(sp)) c += ffeature_int(sp, "lisp_num_syls_in_phrase");
c += ffeature_int(sp, "lisp_num_syls_in_phrase");
return val_string_n(c);
}
/* 47 by Toda-san */
static const cst_val *lisp_total_words(const cst_item *phrase){
const cst_item *sp, *fp;
int c;
sp = phrase;
while (item_prev(sp) != NULL) sp = item_prev(sp);
fp = phrase;
while (item_next(fp) != NULL) fp = item_next(fp);
for (c = 0; sp && (!item_equal(sp, fp)) && (c < CST_CONST_INT_MAX);
sp = item_next(sp)) c += ffeature_int(sp, "lisp_num_words_in_phrase");
c += ffeature_int(sp, "lisp_num_words_in_phrase");
return val_string_n(c);
}
/* 48 by Toda-san */
static const cst_val *lisp_total_phrases(const cst_item *phrase){
const cst_item *sp, *fp;
int c;
sp = phrase;
while (item_prev(sp) != NULL) sp = item_prev(sp);
fp = phrase;
while (item_next(fp) != NULL) fp = item_next(fp);
for (c = 1; sp && (!item_equal(sp, fp)) && (c < CST_CONST_INT_MAX);
sp = item_next(sp)) c++;
return val_string_n(c);
}
#endif /* FLITE_PLUS_HTS_ENGINE */
void us_ff_register(cst_features *ffunctions)
{
/* The language independent ones */
basic_ff_register(ffunctions);
ff_register(ffunctions, "gpos",gpos);
ff_register(ffunctions, "num_digits",num_digits);
ff_register(ffunctions, "month_range",month_range);
ff_register(ffunctions, "token_pos_guess",token_pos_guess);
#ifdef FLITE_PLUS_HTS_ENGINE
ff_register(ffunctions, "syl_numphones",syl_numphones); /* 11 12 13 53 54 */
ff_register(ffunctions, "pos_in_word",pos_in_word); /* 14 */
ff_register(ffunctions, "lisp_distance_to_p_stress",lisp_distance_to_p_stress); /* 21 */
ff_register(ffunctions, "lisp_distance_to_n_stress",lisp_distance_to_n_stress); /* 22 */
ff_register(ffunctions, "lisp_distance_to_p_accent",lisp_distance_to_p_accent); /* 23 */
ff_register(ffunctions, "lisp_distance_to_n_accent",lisp_distance_to_n_accent); /* 24 */
ff_register(ffunctions, "syl_vowel",syl_vowel); /* 25 */
ff_register(ffunctions, "pos_in_phrase",pos_in_phrase); /* 32 */
ff_register(ffunctions, "words_out",words_out); /* 33 */
ff_register(ffunctions, "content_words_in",content_words_in); /* 34 */
ff_register(ffunctions, "content_words_out",content_words_out); /* 35 */
ff_register(ffunctions, "lisp_distance_to_p_content",lisp_distance_to_p_content); /* 36 */
ff_register(ffunctions, "lisp_distance_to_n_content",lisp_distance_to_n_content); /* 37 */
ff_register(ffunctions, "lisp_num_syls_in_phrase",lisp_num_syls_in_phrase); /* 38 39 40 59 60 */
ff_register(ffunctions, "lisp_num_words_in_phrase",lisp_num_words_in_phrase); /* 41 42 43 61 62 */
ff_register(ffunctions, "lisp_total_syls",lisp_total_syls); /* 46 */
ff_register(ffunctions, "lisp_total_words",lisp_total_words); /* 47 */
ff_register(ffunctions, "lisp_total_phrases",lisp_total_phrases); /* 48 */
#endif /* FLITE_PLUS_HTS_ENGINE */
}
@@ -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: January 2001 */
/*************************************************************************/
/* Feature functions used by various cart trees etc */
/* These have been create as needed, and as some of the trees are */
/* from University of Edinburgh's Festival system their names and */
/* semantics follow them */
/*************************************************************************/
#ifndef _US_FFEATURES_H
#define _US_FFEATURES_H
void us_ff_register(cst_features *ffunctions);
extern const cst_val * const * const us_gpos[];
#endif /* _US_FFEATURES_H */
+290
View File
@@ -0,0 +1,290 @@
/*************************************************************************/
/* */
/* 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 */
/*************************************************************************/
/* Poor mans part of speech tagger */
/*************************************************************************/
#include "cst_val.h"
DEF_STATIC_CONST_VAL_STRING(gpos_in,"in");
DEF_STATIC_CONST_VAL_STRING(gpos_of,"of");
DEF_STATIC_CONST_VAL_STRING(gpos_for,"for");
DEF_STATIC_CONST_VAL_STRING(gpos_on,"on");
DEF_STATIC_CONST_VAL_STRING(gpos_that,"that");
DEF_STATIC_CONST_VAL_STRING(gpos_with,"with");
DEF_STATIC_CONST_VAL_STRING(gpos_by,"by");
DEF_STATIC_CONST_VAL_STRING(gpos_at,"at");
DEF_STATIC_CONST_VAL_STRING(gpos_from,"from");
DEF_STATIC_CONST_VAL_STRING(gpos_as,"as");
DEF_STATIC_CONST_VAL_STRING(gpos_if,"if");
DEF_STATIC_CONST_VAL_STRING(gpos_against,"against");
DEF_STATIC_CONST_VAL_STRING(gpos_about,"about");
DEF_STATIC_CONST_VAL_STRING(gpos_before,"before");
DEF_STATIC_CONST_VAL_STRING(gpos_because,"because");
DEF_STATIC_CONST_VAL_STRING(gpos_under,"under");
DEF_STATIC_CONST_VAL_STRING(gpos_after,"after");
DEF_STATIC_CONST_VAL_STRING(gpos_over,"over");
DEF_STATIC_CONST_VAL_STRING(gpos_into,"into");
DEF_STATIC_CONST_VAL_STRING(gpos_while,"while");
DEF_STATIC_CONST_VAL_STRING(gpos_without,"without");
DEF_STATIC_CONST_VAL_STRING(gpos_through,"through");
DEF_STATIC_CONST_VAL_STRING(gpos_new,"new"); /* ??? */
DEF_STATIC_CONST_VAL_STRING(gpos_between,"between");
DEF_STATIC_CONST_VAL_STRING(gpos_among,"among");
DEF_STATIC_CONST_VAL_STRING(gpos_until,"until");
DEF_STATIC_CONST_VAL_STRING(gpos_per,"per");
DEF_STATIC_CONST_VAL_STRING(gpos_up,"up");
DEF_STATIC_CONST_VAL_STRING(gpos_down,"down");
static const cst_val * const gpos_in_list[] = {
(cst_val *)&gpos_in,
(cst_val *)&gpos_of,
(cst_val *)&gpos_for,
(cst_val *)&gpos_in,
(cst_val *)&gpos_on,
(cst_val *)&gpos_that,
(cst_val *)&gpos_with,
(cst_val *)&gpos_by,
(cst_val *)&gpos_at,
(cst_val *)&gpos_from,
(cst_val *)&gpos_as,
(cst_val *)&gpos_if,
(cst_val *)&gpos_that,
(cst_val *)&gpos_against,
(cst_val *)&gpos_about,
(cst_val *)&gpos_before,
(cst_val *)&gpos_because,
(cst_val *)&gpos_under,
(cst_val *)&gpos_after,
(cst_val *)&gpos_over,
(cst_val *)&gpos_into,
(cst_val *)&gpos_while,
(cst_val *)&gpos_without,
(cst_val *)&gpos_through,
(cst_val *)&gpos_new,
(cst_val *)&gpos_between,
(cst_val *)&gpos_among,
(cst_val *)&gpos_until,
(cst_val *)&gpos_per,
(cst_val *)&gpos_up,
(cst_val *)&gpos_down,
0 };
DEF_STATIC_CONST_VAL_STRING(gpos_to,"to");
static const cst_val * const gpos_to_list[] = {
(cst_val *)&gpos_to,
(cst_val *)&gpos_to,
0 };
DEF_STATIC_CONST_VAL_STRING(gpos_det,"det");
DEF_STATIC_CONST_VAL_STRING(gpos_the,"the");
DEF_STATIC_CONST_VAL_STRING(gpos_a,"a");
DEF_STATIC_CONST_VAL_STRING(gpos_an,"an");
DEF_STATIC_CONST_VAL_STRING(gpos_some,"some");
DEF_STATIC_CONST_VAL_STRING(gpos_this,"this");
DEF_STATIC_CONST_VAL_STRING(gpos_each,"each");
DEF_STATIC_CONST_VAL_STRING(gpos_another,"another");
DEF_STATIC_CONST_VAL_STRING(gpos_those,"those");
DEF_STATIC_CONST_VAL_STRING(gpos_every,"every");
DEF_STATIC_CONST_VAL_STRING(gpos_all,"all");
DEF_STATIC_CONST_VAL_STRING(gpos_any,"any");
DEF_STATIC_CONST_VAL_STRING(gpos_these,"these");
DEF_STATIC_CONST_VAL_STRING(gpos_both,"both");
DEF_STATIC_CONST_VAL_STRING(gpos_neither,"neither");
DEF_STATIC_CONST_VAL_STRING(gpos_no,"no");
DEF_STATIC_CONST_VAL_STRING(gpos_many,"many");
static const cst_val * const gpos_det_list[] = {
(cst_val *)&gpos_det,
(cst_val *)&gpos_the,
(cst_val *)&gpos_a,
(cst_val *)&gpos_an,
(cst_val *)&gpos_no,
(cst_val *)&gpos_some,
(cst_val *)&gpos_this,
(cst_val *)&gpos_each,
(cst_val *)&gpos_another,
(cst_val *)&gpos_those,
(cst_val *)&gpos_every,
(cst_val *)&gpos_all,
(cst_val *)&gpos_any,
(cst_val *)&gpos_these,
(cst_val *)&gpos_both,
(cst_val *)&gpos_neither,
(cst_val *)&gpos_no,
(cst_val *)&gpos_many,
0 };
DEF_STATIC_CONST_VAL_STRING(gpos_md,"md");
DEF_STATIC_CONST_VAL_STRING(gpos_will,"will");
DEF_STATIC_CONST_VAL_STRING(gpos_may,"may");
DEF_STATIC_CONST_VAL_STRING(gpos_would,"would");
DEF_STATIC_CONST_VAL_STRING(gpos_can,"can");
DEF_STATIC_CONST_VAL_STRING(gpos_could,"could");
DEF_STATIC_CONST_VAL_STRING(gpos_should,"should");
DEF_STATIC_CONST_VAL_STRING(gpos_must,"must");
DEF_STATIC_CONST_VAL_STRING(gpos_ought,"ought");
DEF_STATIC_CONST_VAL_STRING(gpos_might,"might");
static const cst_val * const gpos_md_list[] = {
(cst_val *)&gpos_md,
(cst_val *)&gpos_will,
(cst_val *)&gpos_may,
(cst_val *)&gpos_would,
(cst_val *)&gpos_can,
(cst_val *)&gpos_could,
(cst_val *)&gpos_should,
(cst_val *)&gpos_must,
(cst_val *)&gpos_ought,
(cst_val *)&gpos_might,
0 };
DEF_STATIC_CONST_VAL_STRING(gpos_cc,"cc");
DEF_STATIC_CONST_VAL_STRING(gpos_and,"and");
DEF_STATIC_CONST_VAL_STRING(gpos_but,"but");
DEF_STATIC_CONST_VAL_STRING(gpos_or,"or");
DEF_STATIC_CONST_VAL_STRING(gpos_plus,"plus");
DEF_STATIC_CONST_VAL_STRING(gpos_yet,"yet");
DEF_STATIC_CONST_VAL_STRING(gpos_nor,"nor");
static const cst_val * const gpos_cc_list[] = {
(cst_val *)&gpos_cc,
(cst_val *)&gpos_and,
(cst_val *)&gpos_but,
(cst_val *)&gpos_or,
(cst_val *)&gpos_plus,
(cst_val *)&gpos_yet,
(cst_val *)&gpos_nor,
0 };
DEF_STATIC_CONST_VAL_STRING(gpos_wp,"wp");
DEF_STATIC_CONST_VAL_STRING(gpos_who,"who");
DEF_STATIC_CONST_VAL_STRING(gpos_what,"what");
DEF_STATIC_CONST_VAL_STRING(gpos_where,"where");
DEF_STATIC_CONST_VAL_STRING(gpos_how,"how");
DEF_STATIC_CONST_VAL_STRING(gpos_when,"when");
static const cst_val * const gpos_wp_list[] = {
(cst_val *)&gpos_wp,
(cst_val *)&gpos_who,
(cst_val *)&gpos_what,
(cst_val *)&gpos_where,
(cst_val *)&gpos_how,
(cst_val *)&gpos_when,
0 };
DEF_STATIC_CONST_VAL_STRING(gpos_pps,"pps");
DEF_STATIC_CONST_VAL_STRING(gpos_her,"her");
DEF_STATIC_CONST_VAL_STRING(gpos_his,"his");
DEF_STATIC_CONST_VAL_STRING(gpos_their,"their");
DEF_STATIC_CONST_VAL_STRING(gpos_its,"its");
DEF_STATIC_CONST_VAL_STRING(gpos_our,"our");
DEF_STATIC_CONST_VAL_STRING(gpos_mine,"mine");
static const cst_val * const gpos_pps_list[] = {
(cst_val *)&gpos_pps,
(cst_val *)&gpos_her,
(cst_val *)&gpos_his,
(cst_val *)&gpos_their,
(cst_val *)&gpos_its,
(cst_val *)&gpos_our,
(cst_val *)&gpos_mine,
0 };
DEF_STATIC_CONST_VAL_STRING(gpos_aux,"aux");
DEF_STATIC_CONST_VAL_STRING(gpos_is,"is");
DEF_STATIC_CONST_VAL_STRING(gpos_am,"am");
DEF_STATIC_CONST_VAL_STRING(gpos_are,"are");
DEF_STATIC_CONST_VAL_STRING(gpos_was,"was");
DEF_STATIC_CONST_VAL_STRING(gpos_were,"were");
DEF_STATIC_CONST_VAL_STRING(gpos_has,"has");
DEF_STATIC_CONST_VAL_STRING(gpos_have,"have");
DEF_STATIC_CONST_VAL_STRING(gpos_had,"had");
DEF_STATIC_CONST_VAL_STRING(gpos_be,"be");
static const cst_val * const gpos_aux_list[] = {
(cst_val *)&gpos_aux,
(cst_val *)&gpos_is,
(cst_val *)&gpos_am,
(cst_val *)&gpos_are,
(cst_val *)&gpos_was,
(cst_val *)&gpos_were,
(cst_val *)&gpos_has,
(cst_val *)&gpos_have,
(cst_val *)&gpos_had,
(cst_val *)&gpos_be,
0 };
DEF_STATIC_CONST_VAL_STRING(gpos_punc,"punc");
DEF_STATIC_CONST_VAL_STRING(gpos_dot,".");
DEF_STATIC_CONST_VAL_STRING(gpos_comma,",");
DEF_STATIC_CONST_VAL_STRING(gpos_colon,":");
DEF_STATIC_CONST_VAL_STRING(gpos_semicolon,";");
DEF_STATIC_CONST_VAL_STRING(gpos_dquote,"\"");
DEF_STATIC_CONST_VAL_STRING(gpos_squote,"'");
DEF_STATIC_CONST_VAL_STRING(gpos_leftparen,"(");
DEF_STATIC_CONST_VAL_STRING(gpos_qmark,"?");
DEF_STATIC_CONST_VAL_STRING(gpos_rightparen,")");
DEF_STATIC_CONST_VAL_STRING(gpos_emark,"!");
static const cst_val * const gpos_punc_list[] = {
(cst_val *)&gpos_punc,
(cst_val *)&gpos_dot,
(cst_val *)&gpos_comma,
(cst_val *)&gpos_colon,
(cst_val *)&gpos_semicolon,
(cst_val *)&gpos_dquote,
(cst_val *)&gpos_squote,
(cst_val *)&gpos_leftparen,
(cst_val *)&gpos_qmark,
(cst_val *)&gpos_rightparen,
(cst_val *)&gpos_emark,
0 };
const cst_val * const * const us_gpos[] = {
gpos_in_list,
gpos_to_list,
gpos_det_list,
gpos_md_list,
gpos_cc_list,
gpos_wp_list,
gpos_pps_list,
gpos_aux_list,
gpos_punc_list,
0 };
@@ -0,0 +1,234 @@
/*************************************************************************/
/* */
/* Carnegie Mellon University and */
/* Centre for Speech Technology Research */
/* University of Edinburgh, UK */
/* Copyright (c) 1998-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. */
/* */
/* THE UNIVERSITY OF EDINBURGH, 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 THE UNIVERSITY OF EDINBURGH, 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 */
/*************************************************************************/
/* */
/* Derived directly from the accent model cart tree in University of */
/* Edinburgh's Festival Speech Synthesis Systems */
/* file: festival/lib/tobi.scm:f2b_int_accent_cart_tree */
/* which was in turn was trained from Boston University FM Radio Data */
/* Corpus */
/* */
/*************************************************************************/
/*******************************************************/
/** Autogenerated cart trees for us_int_accent */
/*******************************************************/
#include "cst_string.h"
#include "cst_cart.h"
#include "cst_regex.h"
#include "us_int_accent_cart.h"
extern const cst_cart us_int_accent_cart;
static const cst_cart_node us_int_accent_cart_nodes[] = {
{ 0, CST_CART_OP_IS, CTNODE_NO_0000, (cst_val *)&val_0000},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0001 },
{ 1, CST_CART_OP_IS, CTNODE_NO_0002, (cst_val *)&val_0000},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0002 },
{ 2, CST_CART_OP_IS, CTNODE_NO_0004, (cst_val *)&val_0000},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0002 },
{ 3, CST_CART_OP_IS, CTNODE_NO_0006, (cst_val *)&val_0003},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0002 },
{ 4, CST_CART_OP_IS, CTNODE_NO_0008, (cst_val *)&val_0004},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0002 },
{ 4, CST_CART_OP_IS, CTNODE_NO_0010, (cst_val *)&val_0005},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0002 },
{ 5, CST_CART_OP_IS, CTNODE_NO_0012, (cst_val *)&val_0003},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0002 },
{ 4, CST_CART_OP_IS, CTNODE_NO_0014, (cst_val *)&val_0006},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0002 },
{ 4, CST_CART_OP_IS, CTNODE_NO_0016, (cst_val *)&val_0007},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0002 },
{ 4, CST_CART_OP_IS, CTNODE_NO_0018, (cst_val *)&val_0008},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0002 },
{ 4, CST_CART_OP_IS, CTNODE_NO_0020, (cst_val *)&val_0009},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0002 },
{ 6, CST_CART_OP_IS, CTNODE_NO_0022, (cst_val *)&val_0010},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0002 },
{ 7, CST_CART_OP_IS, CTNODE_NO_0024, (cst_val *)&val_0010},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0001 },
{ 4, CST_CART_OP_IS, CTNODE_NO_0026, (cst_val *)&val_0011},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0002 },
{ 8, CST_CART_OP_IS, CTNODE_NO_0028, (cst_val *)&val_0012},
{ 9, CST_CART_OP_IS, CTNODE_NO_0029, (cst_val *)&val_0000},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0002 },
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0001 },
{ 10, CST_CART_OP_IS, CTNODE_NO_0032, (cst_val *)&val_0013},
{ 11, CST_CART_OP_IS, CTNODE_NO_0033, (cst_val *)&val_0006},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0001 },
{ 12, CST_CART_OP_IS, CTNODE_NO_0035, (cst_val *)&val_0010},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0001 },
{ 13, CST_CART_OP_IS, CTNODE_NO_0037, (cst_val *)&val_0006},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0001 },
{ 9, CST_CART_OP_IS, CTNODE_NO_0039, (cst_val *)&val_0010},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0001 },
{ 14, CST_CART_OP_IS, CTNODE_NO_0041, (cst_val *)&val_0010},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0001 },
{ 8, CST_CART_OP_IS, CTNODE_NO_0043, (cst_val *)&val_0010},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0002 },
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0001 },
{ 3, CST_CART_OP_IS, CTNODE_NO_0046, (cst_val *)&val_0010},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0001 },
{ 5, CST_CART_OP_IS, CTNODE_NO_0048, (cst_val *)&val_0013},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0002 },
{ 10, CST_CART_OP_IS, CTNODE_NO_0050, (cst_val *)&val_0012},
{ 7, CST_CART_OP_IS, CTNODE_NO_0051, (cst_val *)&val_0014},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0002 },
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0001 },
{ 15, CST_CART_OP_IS, CTNODE_NO_0054, (cst_val *)&val_0015},
{ 14, CST_CART_OP_IS, CTNODE_NO_0055, (cst_val *)&val_0010},
{ 7, CST_CART_OP_IS, CTNODE_NO_0056, (cst_val *)&val_0006},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0001 },
{ 12, CST_CART_OP_IS, CTNODE_NO_0058, (cst_val *)&val_0015},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0001 },
{ 7, CST_CART_OP_IS, CTNODE_NO_0060, (cst_val *)&val_0014},
{ 12, CST_CART_OP_IS, CTNODE_NO_0061, (cst_val *)&val_0013},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0002 },
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0001 },
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0001 },
{ 16, CST_CART_OP_IS, CTNODE_NO_0065, (cst_val *)&val_0010},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0002 },
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0001 },
{ 13, CST_CART_OP_IS, CTNODE_NO_0068, (cst_val *)&val_0010},
{ 9, CST_CART_OP_IS, CTNODE_NO_0069, (cst_val *)&val_0010},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0016 },
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0002 },
{ 9, CST_CART_OP_IS, CTNODE_NO_0072, (cst_val *)&val_0000},
{ 3, CST_CART_OP_IS, CTNODE_NO_0073, (cst_val *)&val_0012},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0002 },
{ 8, CST_CART_OP_IS, CTNODE_NO_0075, (cst_val *)&val_0010},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0002 },
{ 14, CST_CART_OP_IS, CTNODE_NO_0077, (cst_val *)&val_0010},
{ 10, CST_CART_OP_IS, CTNODE_NO_0078, (cst_val *)&val_0010},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0002 },
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0001 },
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0002 },
{ 12, CST_CART_OP_IS, CTNODE_NO_0082, (cst_val *)&val_0013},
{ 17, CST_CART_OP_IS, CTNODE_NO_0083, (cst_val *)&val_0010},
{ 10, CST_CART_OP_IS, CTNODE_NO_0084, (cst_val *)&val_0010},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0002 },
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0016 },
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0001 },
{ 12, CST_CART_OP_IS, CTNODE_NO_0088, (cst_val *)&val_0017},
{ 7, CST_CART_OP_IS, CTNODE_NO_0089, (cst_val *)&val_0014},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0002 },
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0001 },
{ 11, CST_CART_OP_IS, CTNODE_NO_0092, (cst_val *)&val_0006},
{ 15, CST_CART_OP_IS, CTNODE_NO_0093, (cst_val *)&val_0013},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0001 },
{ 15, CST_CART_OP_IS, CTNODE_NO_0095, (cst_val *)&val_0012},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0001 },
{ 10, CST_CART_OP_IS, CTNODE_NO_0097, (cst_val *)&val_0010},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0002 },
{ 7, CST_CART_OP_IS, CTNODE_NO_0099, (cst_val *)&val_0014},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0001 },
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0018 },
{ 5, CST_CART_OP_IS, CTNODE_NO_0102, (cst_val *)&val_0015},
{ 8, CST_CART_OP_IS, CTNODE_NO_0103, (cst_val *)&val_0010},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0002 },
{ 10, CST_CART_OP_IS, CTNODE_NO_0105, (cst_val *)&val_0010},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0002 },
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0016 },
{ 11, CST_CART_OP_IS, CTNODE_NO_0108, (cst_val *)&val_0004},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0001 },
{ 9, CST_CART_OP_IS, CTNODE_NO_0110, (cst_val *)&val_0012},
{ 10, CST_CART_OP_IS, CTNODE_NO_0111, (cst_val *)&val_0010},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0002 },
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0001 },
{ 15, CST_CART_OP_IS, CTNODE_NO_0114, (cst_val *)&val_0019},
{ 14, CST_CART_OP_IS, CTNODE_NO_0115, (cst_val *)&val_0010},
{ 13, CST_CART_OP_IS, CTNODE_NO_0116, (cst_val *)&val_0014},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0018 },
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0002 },
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0002 },
{ 13, CST_CART_OP_IS, CTNODE_NO_0120, (cst_val *)&val_0005},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0002 },
{ 17, CST_CART_OP_IS, CTNODE_NO_0122, (cst_val *)&val_0012},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0001 },
{ 3, CST_CART_OP_IS, CTNODE_NO_0124, (cst_val *)&val_0013},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0002 },
{ 8, CST_CART_OP_IS, CTNODE_NO_0126, (cst_val *)&val_0010},
{ 16, CST_CART_OP_IS, CTNODE_NO_0127, (cst_val *)&val_0000},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0002 },
{ 3, CST_CART_OP_IS, CTNODE_NO_0129, (cst_val *)&val_0012},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0002 },
{ 10, CST_CART_OP_IS, CTNODE_NO_0131, (cst_val *)&val_0010},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0002 },
{ 3, CST_CART_OP_IS, CTNODE_NO_0133, (cst_val *)&val_0000},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0001 },
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0002 },
{ 7, CST_CART_OP_IS, CTNODE_NO_0136, (cst_val *)&val_0006},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0016 },
{ 15, CST_CART_OP_IS, CTNODE_NO_0138, (cst_val *)&val_0020},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0018 },
{ 12, CST_CART_OP_IS, CTNODE_NO_0140, (cst_val *)&val_0015},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0001 },
{ 15, CST_CART_OP_IS, CTNODE_NO_0142, (cst_val *)&val_0013},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0018 },
{ 14, CST_CART_OP_IS, CTNODE_NO_0144, (cst_val *)&val_0010},
{ 15, CST_CART_OP_IS, CTNODE_NO_0145, (cst_val *)&val_0012},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0001 },
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0002 },
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0002 },
{ 255, CST_CART_OP_NONE, 0, 0}};
static const char * const us_int_accent_feat_table[] = {
"R:SylStructure.parent.R:Token.parent.EMPH",
"n.R:SylStructure.parent.R:Token.parent.EMPH",
"p.R:SylStructure.parent.R:Token.parent.EMPH",
"ssyl_in",
"R:SylStructure.parent.gpos",
"ssyl_out",
"stress",
"R:SylStructure.parent.R:Word.p.gpos",
"p.syl_break",
"syl_break",
"p.p.syl_break",
"R:SylStructure.parent.R:Word.p.p.gpos",
"syl_out",
"R:SylStructure.parent.R:Word.n.gpos",
"n.stress",
"syl_in",
"n.syl_break",
"n.n.syl_break",
NULL };
const cst_cart us_int_accent_cart = {
us_int_accent_cart_nodes,
us_int_accent_feat_table
};
@@ -0,0 +1,144 @@
/*************************************************************************/
/* */
/* Carnegie Mellon University and */
/* Centre for Speech Technology Research */
/* University of Edinburgh, UK */
/* Copyright (c) 1998-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. */
/* */
/* THE UNIVERSITY OF EDINBURGH, 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 THE UNIVERSITY OF EDINBURGH, 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 */
/*************************************************************************/
/* */
/* Derived directly from the accent model cart tree in University of */
/* Edinburgh's Festival Speech Synthesis Systems */
/* file: festival/lib/tobi.scm:f2b_int_accent_cart_tree */
/* which was in turn was trained from Boston University FM Radio Data */
/* Corpus */
/* */
/*************************************************************************/
/*******************************************************/
/** Autogenerated cart tree for us_int_accent */
/** from . */
/*******************************************************/
DEF_STATIC_CONST_VAL_STRING(val_0000,"1");
DEF_STATIC_CONST_VAL_STRING(val_0001,"H*");
#define CTNODE_NO_0000 2
DEF_STATIC_CONST_VAL_STRING(val_0002,"NONE");
#define CTNODE_NO_0002 4
#define CTNODE_NO_0004 6
DEF_STATIC_CONST_VAL_STRING(val_0003,"10");
#define CTNODE_NO_0006 8
DEF_STATIC_CONST_VAL_STRING(val_0004,"to");
#define CTNODE_NO_0008 10
DEF_STATIC_CONST_VAL_STRING(val_0005,"cc");
#define CTNODE_NO_0010 12
#define CTNODE_NO_0012 14
DEF_STATIC_CONST_VAL_STRING(val_0006,"in");
#define CTNODE_NO_0014 16
DEF_STATIC_CONST_VAL_STRING(val_0007,"wp");
#define CTNODE_NO_0016 18
DEF_STATIC_CONST_VAL_STRING(val_0008,"aux");
#define CTNODE_NO_0018 20
DEF_STATIC_CONST_VAL_STRING(val_0009,"det");
#define CTNODE_NO_0020 22
DEF_STATIC_CONST_VAL_STRING(val_0010,"0");
#define CTNODE_NO_0022 24
#define CTNODE_NO_0024 26
DEF_STATIC_CONST_VAL_STRING(val_0011,"md");
#define CTNODE_NO_0026 28
DEF_STATIC_CONST_VAL_STRING(val_0012,"3");
#define CTNODE_NO_0029 31
#define CTNODE_NO_0028 32
DEF_STATIC_CONST_VAL_STRING(val_0013,"4");
#define CTNODE_NO_0033 35
#define CTNODE_NO_0035 37
#define CTNODE_NO_0037 39
#define CTNODE_NO_0039 41
#define CTNODE_NO_0041 43
#define CTNODE_NO_0043 45
#define CTNODE_NO_0032 46
#define CTNODE_NO_0046 48
#define CTNODE_NO_0048 50
DEF_STATIC_CONST_VAL_STRING(val_0014,"content");
#define CTNODE_NO_0051 53
#define CTNODE_NO_0050 54
DEF_STATIC_CONST_VAL_STRING(val_0015,"2");
#define CTNODE_NO_0056 58
#define CTNODE_NO_0058 60
#define CTNODE_NO_0061 63
#define CTNODE_NO_0060 64
#define CTNODE_NO_0055 65
#define CTNODE_NO_0065 67
#define CTNODE_NO_0054 68
DEF_STATIC_CONST_VAL_STRING(val_0016,"L+H*");
#define CTNODE_NO_0069 71
#define CTNODE_NO_0068 72
#define CTNODE_NO_0073 75
#define CTNODE_NO_0075 77
#define CTNODE_NO_0078 80
#define CTNODE_NO_0077 81
#define CTNODE_NO_0072 82
#define CTNODE_NO_0084 86
#define CTNODE_NO_0083 87
#define CTNODE_NO_0082 88
DEF_STATIC_CONST_VAL_STRING(val_0017,"5");
#define CTNODE_NO_0089 91
#define CTNODE_NO_0088 92
#define CTNODE_NO_0093 95
#define CTNODE_NO_0095 97
#define CTNODE_NO_0097 99
#define CTNODE_NO_0099 101
DEF_STATIC_CONST_VAL_STRING(val_0018,"!H*");
#define CTNODE_NO_0092 102
#define CTNODE_NO_0103 105
#define CTNODE_NO_0105 107
#define CTNODE_NO_0102 108
#define CTNODE_NO_0108 110
#define CTNODE_NO_0111 113
#define CTNODE_NO_0110 114
DEF_STATIC_CONST_VAL_STRING(val_0019,"7");
#define CTNODE_NO_0116 118
#define CTNODE_NO_0115 119
#define CTNODE_NO_0114 120
#define CTNODE_NO_0120 122
#define CTNODE_NO_0122 124
#define CTNODE_NO_0124 126
#define CTNODE_NO_0127 129
#define CTNODE_NO_0129 131
#define CTNODE_NO_0131 133
#define CTNODE_NO_0133 135
#define CTNODE_NO_0126 136
#define CTNODE_NO_0136 138
DEF_STATIC_CONST_VAL_STRING(val_0020,"6");
#define CTNODE_NO_0138 140
#define CTNODE_NO_0140 142
#define CTNODE_NO_0142 144
#define CTNODE_NO_0145 147
#define CTNODE_NO_0144 148
@@ -0,0 +1,177 @@
/*************************************************************************/
/* */
/* Carnegie Mellon University and */
/* Centre for Speech Technology Research */
/* University of Edinburgh, UK */
/* Copyright (c) 1998-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. */
/* */
/* THE UNIVERSITY OF EDINBURGH, 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 THE UNIVERSITY OF EDINBURGH, 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 */
/*************************************************************************/
/* */
/* Derived directly from the tone model cart tree in University of */
/* Edinburgh's Festival Speech Synthesis Systems */
/* file: festival/lib/tobi.scm:f2b_int_tone_cart_tree */
/* which was in turn was trained from Boston University FM Radio Data */
/* Corpus */
/* */
/*************************************************************************/
/*******************************************************/
/** Autogenerated cart trees for us_int_tone */
/*******************************************************/
#include "cst_string.h"
#include "cst_cart.h"
#include "cst_regex.h"
#include "us_int_tone_cart.h"
extern const cst_cart us_int_tone_cart;
static const cst_cart_node us_int_tone_cart_nodes[] = {
{ 0, CST_CART_OP_IS, CTNODE_NO_0000, (cst_val *)&val_0000},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0001 },
{ 1, CST_CART_OP_IS, CTNODE_NO_0002, (cst_val *)&val_0002},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0003 },
{ 2, CST_CART_OP_IS, CTNODE_NO_0004, (cst_val *)&val_0004},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0003 },
{ 1, CST_CART_OP_IS, CTNODE_NO_0006, (cst_val *)&val_0005},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0003 },
{ 3, CST_CART_OP_IS, CTNODE_NO_0008, (cst_val *)&val_0006},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0003 },
{ 1, CST_CART_OP_IS, CTNODE_NO_0010, (cst_val *)&val_0007},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0003 },
{ 4, CST_CART_OP_IS, CTNODE_NO_0012, (cst_val *)&val_0008},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0003 },
{ 4, CST_CART_OP_IS, CTNODE_NO_0014, (cst_val *)&val_0006},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0003 },
{ 1, CST_CART_OP_IS, CTNODE_NO_0016, (cst_val *)&val_0009},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0003 },
{ 5, CST_CART_OP_IS, CTNODE_NO_0018, (cst_val *)&val_0006},
{ 6, CST_CART_OP_IS, CTNODE_NO_0019, (cst_val *)&val_0010},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0011 },
{ 7, CST_CART_OP_IS, CTNODE_NO_0021, (cst_val *)&val_0012},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0011 },
{ 6, CST_CART_OP_IS, CTNODE_NO_0023, (cst_val *)&val_0007},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0011 },
{ 2, CST_CART_OP_IS, CTNODE_NO_0025, (cst_val *)&val_0006},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0011 },
{ 8, CST_CART_OP_IS, CTNODE_NO_0027, (cst_val *)&val_0013},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0011 },
{ 6, CST_CART_OP_IS, CTNODE_NO_0029, (cst_val *)&val_0012},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0014 },
{ 8, CST_CART_OP_IS, CTNODE_NO_0031, (cst_val *)&val_0015},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0011 },
{ 9, CST_CART_OP_IS, CTNODE_NO_0033, (cst_val *)&val_0016},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0011 },
{ 7, CST_CART_OP_IS, CTNODE_NO_0035, (cst_val *)&val_0007},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0011 },
{ 9, CST_CART_OP_IS, CTNODE_NO_0037, (cst_val *)&val_0010},
{ 6, CST_CART_OP_IS, CTNODE_NO_0038, (cst_val *)&val_0009},
{ 4, CST_CART_OP_IS, CTNODE_NO_0039, (cst_val *)&val_0010},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0011 },
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0014 },
{ 10, CST_CART_OP_IS, CTNODE_NO_0042, (cst_val *)&val_0010},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0011 },
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0014 },
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0011 },
{ 1, CST_CART_OP_IS, CTNODE_NO_0046, (cst_val *)&val_0017},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0003 },
{ 8, CST_CART_OP_IS, CTNODE_NO_0048, (cst_val *)&val_0010},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0003 },
{ 1, CST_CART_OP_IS, CTNODE_NO_0050, (cst_val *)&val_0018},
{ 11, CST_CART_OP_IS, CTNODE_NO_0051, (cst_val *)&val_0010},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0003 },
{ 12, CST_CART_OP_IS, CTNODE_NO_0053, (cst_val *)&val_0006},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0003 },
{ 8, CST_CART_OP_IS, CTNODE_NO_0055, (cst_val *)&val_0000},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0003 },
{ 13, CST_CART_OP_IS, CTNODE_NO_0057, (cst_val *)&val_0006},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0003 },
{ 11, CST_CART_OP_IS, CTNODE_NO_0059, (cst_val *)&val_0009},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0003 },
{ 7, CST_CART_OP_IS, CTNODE_NO_0061, (cst_val *)&val_0002},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0003 },
{ 13, CST_CART_OP_IS, CTNODE_NO_0063, (cst_val *)&val_0008},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0003 },
{ 11, CST_CART_OP_IS, CTNODE_NO_0065, (cst_val *)&val_0002},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0003 },
{ 2, CST_CART_OP_IS, CTNODE_NO_0067, (cst_val *)&val_0010},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0003 },
{ 11, CST_CART_OP_IS, CTNODE_NO_0069, (cst_val *)&val_0019},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0003 },
{ 14, CST_CART_OP_IS, CTNODE_NO_0071, (cst_val *)&val_0019},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0003 },
{ 7, CST_CART_OP_IS, CTNODE_NO_0073, (cst_val *)&val_0009},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0003 },
{ 14, CST_CART_OP_IS, CTNODE_NO_0075, (cst_val *)&val_0009},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0003 },
{ 8, CST_CART_OP_IS, CTNODE_NO_0077, (cst_val *)&val_0016},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0003 },
{ 11, CST_CART_OP_IS, CTNODE_NO_0079, (cst_val *)&val_0012},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0003 },
{ 9, CST_CART_OP_IS, CTNODE_NO_0081, (cst_val *)&val_0000},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0003 },
{ 14, CST_CART_OP_IS, CTNODE_NO_0083, (cst_val *)&val_0007},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0003 },
{ 2, CST_CART_OP_IS, CTNODE_NO_0085, (cst_val *)&val_0006},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0003 },
{ 4, CST_CART_OP_IS, CTNODE_NO_0087, (cst_val *)&val_0010},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0003 },
{ 6, CST_CART_OP_IS, CTNODE_NO_0089, (cst_val *)&val_0018},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0003 },
{ 5, CST_CART_OP_IS, CTNODE_NO_0091, (cst_val *)&val_0008},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0020 },
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0003 },
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0003 },
{ 255, CST_CART_OP_NONE, 0, 0}};
static const char * const us_int_tone_feat_table[] = {
"lisp_syl_yn_question",
"R:SylStructure.parent.gpos",
"ssyl_in",
"p.old_syl_break",
"n.old_syl_break",
"old_syl_break",
"R:SylStructure.parent.R:Word.n.gpos",
"R:SylStructure.parent.R:Word.p.gpos",
"syl_in",
"sub_phrases",
"n.stress",
"R:SylStructure.parent.R:Word.n.n.gpos",
"p.p.old_syl_break",
"n.n.old_syl_break",
"R:SylStructure.parent.R:Word.p.p.gpos",
NULL };
const cst_cart us_int_tone_cart = {
us_int_tone_cart_nodes,
us_int_tone_feat_table
};
@@ -0,0 +1,117 @@
/*************************************************************************/
/* */
/* Carnegie Mellon University and */
/* Centre for Speech Technology Research */
/* University of Edinburgh, UK */
/* Copyright (c) 1998-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. */
/* */
/* THE UNIVERSITY OF EDINBURGH, 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 THE UNIVERSITY OF EDINBURGH, 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 */
/*************************************************************************/
/* */
/* Derived directly from the tone model cart tree in University of */
/* Edinburgh's Festival Speech Synthesis Systems */
/* file: festival/lib/tobi.scm:f2b_int_tone_cart_tree */
/* which was in turn was trained from Boston University FM Radio Data */
/* Corpus */
/* */
/*************************************************************************/
/*******************************************************/
/** Autogenerated cart tree for us_int_tone */
/** from . */
/*******************************************************/
DEF_STATIC_CONST_VAL_STRING(val_0000,"1");
DEF_STATIC_CONST_VAL_STRING(val_0001,"H-H%");
#define CTNODE_NO_0000 2
DEF_STATIC_CONST_VAL_STRING(val_0002,"cc");
DEF_STATIC_CONST_VAL_STRING(val_0003,"NONE");
#define CTNODE_NO_0002 4
DEF_STATIC_CONST_VAL_STRING(val_0004,"10");
#define CTNODE_NO_0004 6
DEF_STATIC_CONST_VAL_STRING(val_0005,"md");
#define CTNODE_NO_0006 8
DEF_STATIC_CONST_VAL_STRING(val_0006,"4");
#define CTNODE_NO_0008 10
DEF_STATIC_CONST_VAL_STRING(val_0007,"det");
#define CTNODE_NO_0010 12
DEF_STATIC_CONST_VAL_STRING(val_0008,"3");
#define CTNODE_NO_0012 14
#define CTNODE_NO_0014 16
DEF_STATIC_CONST_VAL_STRING(val_0009,"in");
#define CTNODE_NO_0016 18
DEF_STATIC_CONST_VAL_STRING(val_0010,"0");
DEF_STATIC_CONST_VAL_STRING(val_0011,"L-L%");
#define CTNODE_NO_0019 21
DEF_STATIC_CONST_VAL_STRING(val_0012,"aux");
#define CTNODE_NO_0021 23
#define CTNODE_NO_0023 25
#define CTNODE_NO_0025 27
DEF_STATIC_CONST_VAL_STRING(val_0013,"6");
#define CTNODE_NO_0027 29
DEF_STATIC_CONST_VAL_STRING(val_0014,"L-H%");
#define CTNODE_NO_0029 31
DEF_STATIC_CONST_VAL_STRING(val_0015,"5");
#define CTNODE_NO_0031 33
DEF_STATIC_CONST_VAL_STRING(val_0016,"2");
#define CTNODE_NO_0033 35
#define CTNODE_NO_0035 37
#define CTNODE_NO_0039 41
#define CTNODE_NO_0038 42
#define CTNODE_NO_0042 44
#define CTNODE_NO_0037 45
#define CTNODE_NO_0018 46
DEF_STATIC_CONST_VAL_STRING(val_0017,"pps");
#define CTNODE_NO_0046 48
#define CTNODE_NO_0048 50
DEF_STATIC_CONST_VAL_STRING(val_0018,"content");
#define CTNODE_NO_0051 53
#define CTNODE_NO_0053 55
#define CTNODE_NO_0055 57
#define CTNODE_NO_0057 59
#define CTNODE_NO_0059 61
#define CTNODE_NO_0061 63
#define CTNODE_NO_0063 65
#define CTNODE_NO_0065 67
#define CTNODE_NO_0067 69
DEF_STATIC_CONST_VAL_STRING(val_0019,"to");
#define CTNODE_NO_0069 71
#define CTNODE_NO_0071 73
#define CTNODE_NO_0073 75
#define CTNODE_NO_0075 77
#define CTNODE_NO_0077 79
#define CTNODE_NO_0079 81
#define CTNODE_NO_0081 83
#define CTNODE_NO_0083 85
#define CTNODE_NO_0085 87
#define CTNODE_NO_0087 89
#define CTNODE_NO_0089 91
DEF_STATIC_CONST_VAL_STRING(val_0020,"H-");
#define CTNODE_NO_0091 93
#define CTNODE_NO_0050 94
@@ -0,0 +1,127 @@
/*******************************************************/
/** Autogenerated cart trees for us_nums */
/*******************************************************/
#include "cst_string.h"
#include "cst_cart.h"
#include "cst_regex.h"
#include "us_nums_cart.h"
extern const cst_cart us_nums_cart;
static const cst_cart_node us_nums_cart_nodes[] = {
{ 0, CST_CART_OP_LESS, CTNODE_us_nums_NO_0000, (cst_val *)&val_0000},
{ 1, CST_CART_OP_IS, CTNODE_us_nums_NO_0001, (cst_val *)&val_0001},
{ 2, CST_CART_OP_IS, CTNODE_us_nums_NO_0002, (cst_val *)&val_0002},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0003 },
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0004 },
{ 3, CST_CART_OP_IS, CTNODE_us_nums_NO_0005, (cst_val *)&val_0001},
{ 2, CST_CART_OP_IS, CTNODE_us_nums_NO_0006, (cst_val *)&val_0002},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0005 },
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0004 },
{ 3, CST_CART_OP_IS, CTNODE_us_nums_NO_0009, (cst_val *)&val_0006},
{ 0, CST_CART_OP_LESS, CTNODE_us_nums_NO_0010, (cst_val *)&val_0007},
{ 1, CST_CART_OP_IS, CTNODE_us_nums_NO_0011, (cst_val *)&val_0006},
{ 4, CST_CART_OP_IS, CTNODE_us_nums_NO_0012, (cst_val *)&val_0008},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0009 },
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0005 },
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0005 },
{ 5, CST_CART_OP_IS, CTNODE_us_nums_NO_0016, (cst_val *)&val_0008},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0005 },
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0009 },
{ 0, CST_CART_OP_LESS, CTNODE_us_nums_NO_0019, (cst_val *)&val_0007},
{ 5, CST_CART_OP_IS, CTNODE_us_nums_NO_0020, (cst_val *)&val_0006},
{ 3, CST_CART_OP_IS, CTNODE_us_nums_NO_0021, (cst_val *)&val_0008},
{ 2, CST_CART_OP_IS, CTNODE_us_nums_NO_0022, (cst_val *)&val_0002},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0009 },
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0005 },
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0005 },
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0005 },
{ 6, CST_CART_OP_LESS, CTNODE_us_nums_NO_0027, (cst_val *)&val_0010},
{ 1, CST_CART_OP_IS, CTNODE_us_nums_NO_0028, (cst_val *)&val_0011},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0009 },
{ 3, CST_CART_OP_IS, CTNODE_us_nums_NO_0030, (cst_val *)&val_0008},
{ 1, CST_CART_OP_IS, CTNODE_us_nums_NO_0031, (cst_val *)&val_0008},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0009 },
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0005 },
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0005 },
{ 1, CST_CART_OP_IS, CTNODE_us_nums_NO_0035, (cst_val *)&val_0012},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0009 },
{ 3, CST_CART_OP_IS, CTNODE_us_nums_NO_0037, (cst_val *)&val_0008},
{ 5, CST_CART_OP_IS, CTNODE_us_nums_NO_0038, (cst_val *)&val_0008},
{ 6, CST_CART_OP_LESS, CTNODE_us_nums_NO_0039, (cst_val *)&val_0013},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0009 },
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0005 },
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0005 },
{ 6, CST_CART_OP_LESS, CTNODE_us_nums_NO_0043, (cst_val *)&val_0014},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0005 },
{ 6, CST_CART_OP_LESS, CTNODE_us_nums_NO_0045, (cst_val *)&val_0015},
{ 6, CST_CART_OP_LESS, CTNODE_us_nums_NO_0046, (cst_val *)&val_0016},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0009 },
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0005 },
{ 6, CST_CART_OP_LESS, CTNODE_us_nums_NO_0049, (cst_val *)&val_0017},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0005 },
{ 6, CST_CART_OP_LESS, CTNODE_us_nums_NO_0051, (cst_val *)&val_0018},
{ 1, CST_CART_OP_IS, CTNODE_us_nums_NO_0052, (cst_val *)&val_0019},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0009 },
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0005 },
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0005 },
{ 1, CST_CART_OP_IS, CTNODE_us_nums_NO_0056, (cst_val *)&val_0006},
{ 4, CST_CART_OP_IS, CTNODE_us_nums_NO_0057, (cst_val *)&val_0001},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0003 },
{ 5, CST_CART_OP_IS, CTNODE_us_nums_NO_0059, (cst_val *)&val_0006},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0005 },
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0009 },
{ 5, CST_CART_OP_IS, CTNODE_us_nums_NO_0062, (cst_val *)&val_0006},
{ 3, CST_CART_OP_IS, CTNODE_us_nums_NO_0063, (cst_val *)&val_0001},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0005 },
{ 3, CST_CART_OP_IS, CTNODE_us_nums_NO_0065, (cst_val *)&val_0006},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0009 },
{ 1, CST_CART_OP_IS, CTNODE_us_nums_NO_0067, (cst_val *)&val_0019},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0005 },
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0003 },
{ 1, CST_CART_OP_IS, CTNODE_us_nums_NO_0070, (cst_val *)&val_0019},
{ 0, CST_CART_OP_LESS, CTNODE_us_nums_NO_0071, (cst_val *)&val_0020},
{ 6, CST_CART_OP_LESS, CTNODE_us_nums_NO_0072, (cst_val *)&val_0021},
{ 6, CST_CART_OP_LESS, CTNODE_us_nums_NO_0073, (cst_val *)&val_0022},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0005 },
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0003 },
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0005 },
{ 4, CST_CART_OP_IS, CTNODE_us_nums_NO_0077, (cst_val *)&val_0019},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0009 },
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0005 },
{ 3, CST_CART_OP_IS, CTNODE_us_nums_NO_0080, (cst_val *)&val_0023},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0003 },
{ 1, CST_CART_OP_IS, CTNODE_us_nums_NO_0082, (cst_val *)&val_0008},
{ 4, CST_CART_OP_IS, CTNODE_us_nums_NO_0083, (cst_val *)&val_0008},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0005 },
{ 0, CST_CART_OP_LESS, CTNODE_us_nums_NO_0085, (cst_val *)&val_0024},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0003 },
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0009 },
{ 0, CST_CART_OP_LESS, CTNODE_us_nums_NO_0088, (cst_val *)&val_0025},
{ 6, CST_CART_OP_LESS, CTNODE_us_nums_NO_0089, (cst_val *)&val_0026},
{ 6, CST_CART_OP_LESS, CTNODE_us_nums_NO_0090, (cst_val *)&val_0027},
{ 6, CST_CART_OP_LESS, CTNODE_us_nums_NO_0091, (cst_val *)&val_0028},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0005 },
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0003 },
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0003 },
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0005 },
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0005 },
{ 255, CST_CART_OP_NONE, 0, 0}};
static const char * const us_nums_feat_table[] = {
"num_digits",
"p.token_pos_guess",
"month_range",
"n.token_pos_guess",
"p.p.token_pos_guess",
"n.n.token_pos_guess",
"name",
NULL };
const cst_cart us_nums_cart = {
us_nums_cart_nodes,
us_nums_feat_table
};
@@ -0,0 +1,82 @@
/*******************************************************/
/** Autogenerated cart tree for us_nums */
/** from . */
/*******************************************************/
DEF_STATIC_CONST_VAL_FLOAT(val_0000,3.800000);
DEF_STATIC_CONST_VAL_STRING(val_0001,"month");
DEF_STATIC_CONST_VAL_STRING(val_0002,"0");
DEF_STATIC_CONST_VAL_STRING(val_0003,"year");
#define CTNODE_us_nums_NO_0002 4
DEF_STATIC_CONST_VAL_STRING(val_0004,"ordinal");
#define CTNODE_us_nums_NO_0001 5
DEF_STATIC_CONST_VAL_STRING(val_0005,"cardinal");
#define CTNODE_us_nums_NO_0006 8
#define CTNODE_us_nums_NO_0005 9
DEF_STATIC_CONST_VAL_STRING(val_0006,"numeric");
DEF_STATIC_CONST_VAL_FLOAT(val_0007,2.000000);
DEF_STATIC_CONST_VAL_STRING(val_0008,"sym");
DEF_STATIC_CONST_VAL_STRING(val_0009,"digits");
#define CTNODE_us_nums_NO_0012 14
#define CTNODE_us_nums_NO_0011 15
#define CTNODE_us_nums_NO_0010 16
#define CTNODE_us_nums_NO_0016 18
#define CTNODE_us_nums_NO_0009 19
#define CTNODE_us_nums_NO_0022 24
#define CTNODE_us_nums_NO_0021 25
#define CTNODE_us_nums_NO_0020 26
#define CTNODE_us_nums_NO_0019 27
DEF_STATIC_CONST_VAL_FLOAT(val_0010,302.299988);
DEF_STATIC_CONST_VAL_STRING(val_0011,"flight");
#define CTNODE_us_nums_NO_0028 30
#define CTNODE_us_nums_NO_0031 33
#define CTNODE_us_nums_NO_0030 34
#define CTNODE_us_nums_NO_0027 35
DEF_STATIC_CONST_VAL_STRING(val_0012,"a");
#define CTNODE_us_nums_NO_0035 37
DEF_STATIC_CONST_VAL_FLOAT(val_0013,669.200012);
#define CTNODE_us_nums_NO_0039 41
#define CTNODE_us_nums_NO_0038 42
#define CTNODE_us_nums_NO_0037 43
DEF_STATIC_CONST_VAL_FLOAT(val_0014,373.200012);
#define CTNODE_us_nums_NO_0043 45
DEF_STATIC_CONST_VAL_FLOAT(val_0015,436.200012);
DEF_STATIC_CONST_VAL_FLOAT(val_0016,392.600006);
#define CTNODE_us_nums_NO_0046 48
#define CTNODE_us_nums_NO_0045 49
DEF_STATIC_CONST_VAL_FLOAT(val_0017,716.500000);
#define CTNODE_us_nums_NO_0049 51
DEF_STATIC_CONST_VAL_FLOAT(val_0018,773.599976);
DEF_STATIC_CONST_VAL_STRING(val_0019,"_other_");
#define CTNODE_us_nums_NO_0052 54
#define CTNODE_us_nums_NO_0051 55
#define CTNODE_us_nums_NO_0000 56
#define CTNODE_us_nums_NO_0057 59
#define CTNODE_us_nums_NO_0059 61
#define CTNODE_us_nums_NO_0056 62
#define CTNODE_us_nums_NO_0063 65
#define CTNODE_us_nums_NO_0065 67
#define CTNODE_us_nums_NO_0067 69
#define CTNODE_us_nums_NO_0062 70
DEF_STATIC_CONST_VAL_FLOAT(val_0020,4.400000);
DEF_STATIC_CONST_VAL_FLOAT(val_0021,2959.600098);
DEF_STATIC_CONST_VAL_FLOAT(val_0022,1773.400024);
#define CTNODE_us_nums_NO_0073 75
#define CTNODE_us_nums_NO_0072 76
#define CTNODE_us_nums_NO_0071 77
#define CTNODE_us_nums_NO_0077 79
#define CTNODE_us_nums_NO_0070 80
DEF_STATIC_CONST_VAL_STRING(val_0023,"to");
#define CTNODE_us_nums_NO_0080 82
#define CTNODE_us_nums_NO_0083 85
DEF_STATIC_CONST_VAL_FLOAT(val_0024,4.600000);
#define CTNODE_us_nums_NO_0085 87
#define CTNODE_us_nums_NO_0082 88
DEF_STATIC_CONST_VAL_FLOAT(val_0025,4.800000);
DEF_STATIC_CONST_VAL_FLOAT(val_0026,2880.000000);
DEF_STATIC_CONST_VAL_FLOAT(val_0027,1633.199951);
DEF_STATIC_CONST_VAL_FLOAT(val_0028,1306.400024);
#define CTNODE_us_nums_NO_0091 93
#define CTNODE_us_nums_NO_0090 94
#define CTNODE_us_nums_NO_0089 95
#define CTNODE_us_nums_NO_0088 96
@@ -0,0 +1,257 @@
/*************************************************************************/
/* */
/* Carnegie Mellon University and */
/* Centre for Speech Technology Research */
/* University of Edinburgh, UK */
/* Copyright (c) 1998-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. */
/* */
/* THE UNIVERSITY OF EDINBURGH, 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 THE UNIVERSITY OF EDINBURGH, 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. */
/* */
/*******************************************************/
/** Autogenerated phoneset trees for us */
/*******************************************************/
#include "cst_string.h"
#include "cst_phoneset.h"
extern const cst_phoneset us_phoneset;
static const char * const us_featnames[] = {
"vc",
"vlng",
"vheight",
"vfront",
"vrnd",
"ctype",
"cplace",
"cvox",
NULL };
static const char * const us_phonenames[] = {
"aa",
"ae",
"ah",
"ao",
"aw",
"ax",
"axr",
"ay",
"b",
"ch",
"d",
"dh",
"dx",
"eh",
"el",
"em",
"en",
"er",
"ey",
"f",
"g",
"hh",
"hv",
"ih",
"iy",
"jh",
"k",
"l",
"m",
"n",
"nx",
"ng",
"ow",
"oy",
"p",
"r",
"s",
"sh",
"t",
"th",
"uh",
"uw",
"v",
"w",
"y",
"z",
"zh",
"pau",
"h#",
"brth",
NULL };
static const int us_fv_000[] = { 0, 1, 2, 2, 3, 4, 4, 4, -1 };
static const int us_fv_001[] = { 0, 5, 2, 6, 3, 4, 4, 4, -1 };
static const int us_fv_002[] = { 0, 5, 7, 7, 3, 4, 4, 4, -1 };
static const int us_fv_003[] = { 0, 1, 2, 2, 0, 4, 4, 4, -1 };
static const int us_fv_004[] = { 0, 8, 2, 7, 3, 4, 4, 4, -1 };
static const int us_fv_005[] = { 0, 9, 7, 7, 3, 4, 4, 4, -1 };
static const int us_fv_006[] = { 0, 9, 7, 7, 3, 10, 9, 0, -1 };
static const int us_fv_007[] = { 0, 8, 2, 7, 3, 4, 4, 4, -1 };
static const int us_fv_008[] = { 3, 4, 4, 4, 4, 5, 1, 0, -1 };
static const int us_fv_009[] = { 3, 4, 4, 4, 4, 9, 11, 3, -1 };
static const int us_fv_010[] = { 3, 4, 4, 4, 4, 5, 9, 0, -1 };
static const int us_fv_011[] = { 3, 4, 4, 4, 4, 12, 8, 0, -1 };
static const int us_fv_012[] = { 3, 9, 4, 4, 4, 5, 9, 0, -1 };
static const int us_fv_013[] = { 0, 5, 7, 6, 3, 4, 4, 4, -1 };
static const int us_fv_014[] = { 0, 5, 4, 4, 4, 1, 9, 0, -1 };
static const int us_fv_015[] = { 0, 5, 4, 4, 4, 13, 1, 0, -1 };
static const int us_fv_016[] = { 0, 5, 4, 4, 4, 13, 9, 0, -1 };
static const int us_fv_017[] = { 0, 9, 7, 7, 3, 10, 4, 4, -1 };
static const int us_fv_018[] = { 0, 8, 7, 6, 3, 4, 4, 4, -1 };
static const int us_fv_019[] = { 3, 4, 4, 4, 4, 12, 14, 3, -1 };
static const int us_fv_020[] = { 3, 4, 4, 4, 4, 5, 15, 0, -1 };
static const int us_fv_021[] = { 3, 4, 4, 4, 4, 12, 16, 3, -1 };
static const int us_fv_022[] = { 3, 4, 4, 4, 4, 12, 16, 0, -1 };
static const int us_fv_023[] = { 0, 5, 6, 6, 3, 4, 4, 4, -1 };
static const int us_fv_024[] = { 0, 1, 6, 6, 3, 4, 4, 4, -1 };
static const int us_fv_025[] = { 3, 4, 4, 4, 4, 9, 11, 0, -1 };
static const int us_fv_026[] = { 3, 4, 4, 4, 4, 5, 15, 3, -1 };
static const int us_fv_027[] = { 3, 4, 4, 4, 4, 1, 9, 0, -1 };
static const int us_fv_028[] = { 3, 4, 4, 4, 4, 13, 1, 0, -1 };
static const int us_fv_029[] = { 3, 4, 4, 4, 4, 13, 9, 0, -1 };
static const int us_fv_030[] = { 3, 4, 4, 4, 4, 13, 8, 0, -1 };
static const int us_fv_031[] = { 3, 4, 4, 4, 4, 13, 15, 0, -1 };
static const int us_fv_032[] = { 0, 8, 7, 2, 0, 4, 4, 4, -1 };
static const int us_fv_033[] = { 0, 8, 7, 2, 0, 4, 4, 4, -1 };
static const int us_fv_034[] = { 3, 4, 4, 4, 4, 5, 1, 3, -1 };
static const int us_fv_035[] = { 3, 4, 4, 4, 4, 10, 9, 0, -1 };
static const int us_fv_036[] = { 3, 4, 4, 4, 4, 12, 9, 3, -1 };
static const int us_fv_037[] = { 3, 4, 4, 4, 4, 12, 11, 3, -1 };
static const int us_fv_038[] = { 3, 4, 4, 4, 4, 5, 9, 3, -1 };
static const int us_fv_039[] = { 3, 4, 4, 4, 4, 12, 8, 3, -1 };
static const int us_fv_040[] = { 0, 5, 6, 2, 0, 4, 4, 4, -1 };
static const int us_fv_041[] = { 0, 1, 6, 2, 0, 4, 4, 4, -1 };
static const int us_fv_042[] = { 3, 4, 4, 4, 4, 12, 14, 0, -1 };
static const int us_fv_043[] = { 3, 4, 4, 4, 4, 10, 1, 0, -1 };
static const int us_fv_044[] = { 3, 4, 4, 4, 4, 10, 11, 0, -1 };
static const int us_fv_045[] = { 3, 4, 4, 4, 4, 12, 9, 0, -1 };
static const int us_fv_046[] = { 3, 4, 4, 4, 4, 12, 11, 0, -1 };
static const int us_fv_047[] = { 3, 4, 4, 4, 4, 4, 4, 3, -1 };
static const int us_fv_048[] = { 3, 4, 4, 4, 4, 4, 4, 3, -1 };
static const int us_fv_049[] = { 3, 4, 4, 4, 4, 4, 4, 3, -1 };
static const int us_fv_050[] = { 0 };
static const int * const us_fvtable[] = {
us_fv_000,
us_fv_001,
us_fv_002,
us_fv_003,
us_fv_004,
us_fv_005,
us_fv_006,
us_fv_007,
us_fv_008,
us_fv_009,
us_fv_010,
us_fv_011,
us_fv_012,
us_fv_013,
us_fv_014,
us_fv_015,
us_fv_016,
us_fv_017,
us_fv_018,
us_fv_019,
us_fv_020,
us_fv_021,
us_fv_022,
us_fv_023,
us_fv_024,
us_fv_025,
us_fv_026,
us_fv_027,
us_fv_028,
us_fv_029,
us_fv_030,
us_fv_031,
us_fv_032,
us_fv_033,
us_fv_034,
us_fv_035,
us_fv_036,
us_fv_037,
us_fv_038,
us_fv_039,
us_fv_040,
us_fv_041,
us_fv_042,
us_fv_043,
us_fv_044,
us_fv_045,
us_fv_046,
us_fv_047,
us_fv_048,
us_fv_049,
us_fv_050 };
DEF_STATIC_CONST_VAL_STRING(featval_0,"+");
DEF_STATIC_CONST_VAL_STRING(featval_1,"l");
DEF_STATIC_CONST_VAL_STRING(featval_2,"3");
DEF_STATIC_CONST_VAL_STRING(featval_3,"-");
DEF_STATIC_CONST_VAL_STRING(featval_4,"0");
DEF_STATIC_CONST_VAL_STRING(featval_5,"s");
DEF_STATIC_CONST_VAL_STRING(featval_6,"1");
DEF_STATIC_CONST_VAL_STRING(featval_7,"2");
DEF_STATIC_CONST_VAL_STRING(featval_8,"d");
DEF_STATIC_CONST_VAL_STRING(featval_9,"a");
DEF_STATIC_CONST_VAL_STRING(featval_10,"r");
DEF_STATIC_CONST_VAL_STRING(featval_11,"p");
DEF_STATIC_CONST_VAL_STRING(featval_12,"f");
DEF_STATIC_CONST_VAL_STRING(featval_13,"n");
DEF_STATIC_CONST_VAL_STRING(featval_14,"b");
DEF_STATIC_CONST_VAL_STRING(featval_15,"v");
DEF_STATIC_CONST_VAL_STRING(featval_16,"g");
static const cst_val * const us_featvals[] = {
(cst_val *)&featval_0,
(cst_val *)&featval_1,
(cst_val *)&featval_2,
(cst_val *)&featval_3,
(cst_val *)&featval_4,
(cst_val *)&featval_5,
(cst_val *)&featval_6,
(cst_val *)&featval_7,
(cst_val *)&featval_8,
(cst_val *)&featval_9,
(cst_val *)&featval_10,
(cst_val *)&featval_11,
(cst_val *)&featval_12,
(cst_val *)&featval_13,
(cst_val *)&featval_14,
(cst_val *)&featval_15,
(cst_val *)&featval_16,
NULL };
const cst_phoneset us_phoneset = {
"us",
us_featnames,
us_featvals,
us_phonenames,
"pau",
50,
us_fvtable
};
@@ -0,0 +1,44 @@
/*******************************************************/
/** Autogenerated cart trees for us_phrasing */
/*******************************************************/
#include "cst_string.h"
#include "cst_cart.h"
#include "cst_regex.h"
#include "us_phrasing_cart.h"
extern const cst_cart us_phrasing_cart;
static const cst_cart_node us_phrasing_cart_nodes[] = {
{ 0, CST_CART_OP_IS, CTNODE_us_phrasing_NO_0000, (cst_val *)&val_0000},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0001 },
{ 1, CST_CART_OP_IS, CTNODE_us_phrasing_NO_0002, (cst_val *)&val_0002},
{ 2, CST_CART_OP_IS, CTNODE_us_phrasing_NO_0003, (cst_val *)&val_0003},
{ 3, CST_CART_OP_IS, CTNODE_us_phrasing_NO_0004, (cst_val *)&val_0004},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0001 },
{ 4, CST_CART_OP_IS, CTNODE_us_phrasing_NO_0006, (cst_val *)&val_0004},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0001 },
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0005 },
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0001 },
{ 5, CST_CART_OP_IS, CTNODE_us_phrasing_NO_0010, (cst_val *)&val_0002},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0001 },
{ 4, CST_CART_OP_IS, CTNODE_us_phrasing_NO_0012, (cst_val *)&val_0004},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0001 },
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0005 },
{ 255, CST_CART_OP_NONE, 0, 0}};
static const char * const us_phrasing_feat_table[] = {
"R:Token.parent.n.name",
"R:Token.n.name",
"R:Token.parent.punc",
"R:Token.parent.break",
"break",
"n.name",
NULL };
const cst_cart us_phrasing_cart = {
us_phrasing_cart_nodes,
us_phrasing_feat_table
};
@@ -0,0 +1,18 @@
/*******************************************************/
/** Autogenerated cart tree for us_phrasing */
/** from . */
/*******************************************************/
DEF_STATIC_CONST_VAL_STRING(val_0000,"--");
DEF_STATIC_CONST_VAL_STRING(val_0001,"BB");
#define CTNODE_us_phrasing_NO_0000 2
DEF_STATIC_CONST_VAL_STRING(val_0002,"0");
DEF_STATIC_CONST_VAL_STRING(val_0003,"");
DEF_STATIC_CONST_VAL_STRING(val_0004,"1");
#define CTNODE_us_phrasing_NO_0004 6
#define CTNODE_us_phrasing_NO_0006 8
DEF_STATIC_CONST_VAL_STRING(val_0005,"NB");
#define CTNODE_us_phrasing_NO_0003 9
#define CTNODE_us_phrasing_NO_0002 10
#define CTNODE_us_phrasing_NO_0010 12
#define CTNODE_us_phrasing_NO_0012 14
@@ -0,0 +1,397 @@
/*******************************************************/
/** Autogenerated cart trees for us_pos */
/*******************************************************/
#include "cst_string.h"
#include "cst_cart.h"
#include "cst_regex.h"
#include "us_pos_cart.h"
static const cst_cart_node us_pos_cart_nodes[] = {
{ 0, CST_CART_OP_IS, CTNODE_us_pos_NO_0000, (cst_val *)&val_0000},
{ 1, CST_CART_OP_IS, CTNODE_us_pos_NO_0001, (cst_val *)&val_0001},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0002 },
{ 2, CST_CART_OP_IS, CTNODE_us_pos_NO_0003, (cst_val *)&val_0003},
{ 1, CST_CART_OP_IS, CTNODE_us_pos_NO_0004, (cst_val *)&val_0004},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0002 },
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0005 },
{ 1, CST_CART_OP_IS, CTNODE_us_pos_NO_0007, (cst_val *)&val_0006},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0005 },
{ 3, CST_CART_OP_IS, CTNODE_us_pos_NO_0009, (cst_val *)&val_0007},
{ 4, CST_CART_OP_IS, CTNODE_us_pos_NO_0010, (cst_val *)&val_0007},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0002 },
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0005 },
{ 4, CST_CART_OP_IS, CTNODE_us_pos_NO_0013, (cst_val *)&val_0008},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0005 },
{ 3, CST_CART_OP_IS, CTNODE_us_pos_NO_0015, (cst_val *)&val_0000},
{ 4, CST_CART_OP_IS, CTNODE_us_pos_NO_0016, (cst_val *)&val_0007},
{ 1, CST_CART_OP_IS, CTNODE_us_pos_NO_0017, (cst_val *)&val_0009},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0010 },
{ 1, CST_CART_OP_IS, CTNODE_us_pos_NO_0019, (cst_val *)&val_0011},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0010 },
{ 1, CST_CART_OP_IS, CTNODE_us_pos_NO_0021, (cst_val *)&val_0012},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0010 },
{ 1, CST_CART_OP_IS, CTNODE_us_pos_NO_0023, (cst_val *)&val_0013},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0010 },
{ 1, CST_CART_OP_IS, CTNODE_us_pos_NO_0025, (cst_val *)&val_0014},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0010 },
{ 1, CST_CART_OP_IS, CTNODE_us_pos_NO_0027, (cst_val *)&val_0015},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0010 },
{ 1, CST_CART_OP_IS, CTNODE_us_pos_NO_0029, (cst_val *)&val_0016},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0010 },
{ 1, CST_CART_OP_IS, CTNODE_us_pos_NO_0031, (cst_val *)&val_0017},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0010 },
{ 1, CST_CART_OP_IS, CTNODE_us_pos_NO_0033, (cst_val *)&val_0018},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0010 },
{ 1, CST_CART_OP_IS, CTNODE_us_pos_NO_0035, (cst_val *)&val_0019},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0010 },
{ 2, CST_CART_OP_IS, CTNODE_us_pos_NO_0037, (cst_val *)&val_0020},
{ 5, CST_CART_OP_IS, CTNODE_us_pos_NO_0038, (cst_val *)&val_0021},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0010 },
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0002 },
{ 1, CST_CART_OP_IS, CTNODE_us_pos_NO_0041, (cst_val *)&val_0022},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0010 },
{ 5, CST_CART_OP_IS, CTNODE_us_pos_NO_0043, (cst_val *)&val_0021},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0010 },
{ 1, CST_CART_OP_IS, CTNODE_us_pos_NO_0045, (cst_val *)&val_0023},
{ 6, CST_CART_OP_IS, CTNODE_us_pos_NO_0046, (cst_val *)&val_0000},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0010 },
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0002 },
{ 2, CST_CART_OP_IS, CTNODE_us_pos_NO_0049, (cst_val *)&val_0024},
{ 7, CST_CART_OP_IS, CTNODE_us_pos_NO_0050, (cst_val *)&val_0000},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0002 },
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0010 },
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0002 },
{ 1, CST_CART_OP_IS, CTNODE_us_pos_NO_0054, (cst_val *)&val_0004},
{ 7, CST_CART_OP_IS, CTNODE_us_pos_NO_0055, (cst_val *)&val_0025},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0002 },
{ 4, CST_CART_OP_IS, CTNODE_us_pos_NO_0057, (cst_val *)&val_0026},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0002 },
{ 8, CST_CART_OP_IS, CTNODE_us_pos_NO_0059, (cst_val *)&val_0027},
{ 9, CST_CART_OP_IS, CTNODE_us_pos_NO_0060, (cst_val *)&val_0028},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0002 },
{ 5, CST_CART_OP_IS, CTNODE_us_pos_NO_0062, (cst_val *)&val_0029},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0005 },
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0002 },
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0002 },
{ 1, CST_CART_OP_IS, CTNODE_us_pos_NO_0066, (cst_val *)&val_0013},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0010 },
{ 1, CST_CART_OP_IS, CTNODE_us_pos_NO_0068, (cst_val *)&val_0009},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0010 },
{ 1, CST_CART_OP_IS, CTNODE_us_pos_NO_0070, (cst_val *)&val_0030},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0005 },
{ 1, CST_CART_OP_IS, CTNODE_us_pos_NO_0072, (cst_val *)&val_0011},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0010 },
{ 1, CST_CART_OP_IS, CTNODE_us_pos_NO_0074, (cst_val *)&val_0017},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0010 },
{ 1, CST_CART_OP_IS, CTNODE_us_pos_NO_0076, (cst_val *)&val_0016},
{ 4, CST_CART_OP_IS, CTNODE_us_pos_NO_0077, (cst_val *)&val_0026},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0010 },
{ 9, CST_CART_OP_IS, CTNODE_us_pos_NO_0079, (cst_val *)&val_0004},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0010 },
{ 7, CST_CART_OP_IS, CTNODE_us_pos_NO_0081, (cst_val *)&val_0000},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0010 },
{ 6, CST_CART_OP_IS, CTNODE_us_pos_NO_0083, (cst_val *)&val_0000},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0005 },
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0010 },
{ 1, CST_CART_OP_IS, CTNODE_us_pos_NO_0086, (cst_val *)&val_0031},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0010 },
{ 1, CST_CART_OP_IS, CTNODE_us_pos_NO_0088, (cst_val *)&val_0014},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0010 },
{ 1, CST_CART_OP_IS, CTNODE_us_pos_NO_0090, (cst_val *)&val_0032},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0005 },
{ 1, CST_CART_OP_IS, CTNODE_us_pos_NO_0092, (cst_val *)&val_0033},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0005 },
{ 1, CST_CART_OP_IS, CTNODE_us_pos_NO_0094, (cst_val *)&val_0034},
{ 4, CST_CART_OP_IS, CTNODE_us_pos_NO_0095, (cst_val *)&val_0026},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0002 },
{ 9, CST_CART_OP_IS, CTNODE_us_pos_NO_0097, (cst_val *)&val_0035},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0005 },
{ 6, CST_CART_OP_IS, CTNODE_us_pos_NO_0099, (cst_val *)&val_0026},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0002 },
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0005 },
{ 1, CST_CART_OP_IS, CTNODE_us_pos_NO_0102, (cst_val *)&val_0036},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0005 },
{ 1, CST_CART_OP_IS, CTNODE_us_pos_NO_0104, (cst_val *)&val_0037},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0005 },
{ 1, CST_CART_OP_IS, CTNODE_us_pos_NO_0106, (cst_val *)&val_0038},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0005 },
{ 1, CST_CART_OP_IS, CTNODE_us_pos_NO_0108, (cst_val *)&val_0012},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0010 },
{ 1, CST_CART_OP_IS, CTNODE_us_pos_NO_0110, (cst_val *)&val_0018},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0010 },
{ 1, CST_CART_OP_IS, CTNODE_us_pos_NO_0112, (cst_val *)&val_0015},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0010 },
{ 1, CST_CART_OP_IS, CTNODE_us_pos_NO_0114, (cst_val *)&val_0039},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0010 },
{ 1, CST_CART_OP_IS, CTNODE_us_pos_NO_0116, (cst_val *)&val_0040},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0010 },
{ 1, CST_CART_OP_IS, CTNODE_us_pos_NO_0118, (cst_val *)&val_0041},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0005 },
{ 1, CST_CART_OP_IS, CTNODE_us_pos_NO_0120, (cst_val *)&val_0022},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0010 },
{ 1, CST_CART_OP_IS, CTNODE_us_pos_NO_0122, (cst_val *)&val_0019},
{ 4, CST_CART_OP_IS, CTNODE_us_pos_NO_0123, (cst_val *)&val_0026},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0010 },
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0002 },
{ 1, CST_CART_OP_IS, CTNODE_us_pos_NO_0126, (cst_val *)&val_0042},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0005 },
{ 1, CST_CART_OP_IS, CTNODE_us_pos_NO_0128, (cst_val *)&val_0043},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0005 },
{ 1, CST_CART_OP_IS, CTNODE_us_pos_NO_0130, (cst_val *)&val_0044},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0010 },
{ 1, CST_CART_OP_IS, CTNODE_us_pos_NO_0132, (cst_val *)&val_0045},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0005 },
{ 1, CST_CART_OP_IS, CTNODE_us_pos_NO_0134, (cst_val *)&val_0046},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0005 },
{ 1, CST_CART_OP_IS, CTNODE_us_pos_NO_0136, (cst_val *)&val_0047},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0005 },
{ 1, CST_CART_OP_IS, CTNODE_us_pos_NO_0138, (cst_val *)&val_0048},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0002 },
{ 1, CST_CART_OP_IS, CTNODE_us_pos_NO_0140, (cst_val *)&val_0049},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0005 },
{ 1, CST_CART_OP_IS, CTNODE_us_pos_NO_0142, (cst_val *)&val_0023},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0002 },
{ 1, CST_CART_OP_IS, CTNODE_us_pos_NO_0144, (cst_val *)&val_0050},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0002 },
{ 1, CST_CART_OP_IS, CTNODE_us_pos_NO_0146, (cst_val *)&val_0051},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0010 },
{ 1, CST_CART_OP_IS, CTNODE_us_pos_NO_0148, (cst_val *)&val_0052},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0005 },
{ 1, CST_CART_OP_IS, CTNODE_us_pos_NO_0150, (cst_val *)&val_0053},
{ 4, CST_CART_OP_IS, CTNODE_us_pos_NO_0151, (cst_val *)&val_0000},
{ 6, CST_CART_OP_IS, CTNODE_us_pos_NO_0152, (cst_val *)&val_0000},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0005 },
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0002 },
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0005 },
{ 2, CST_CART_OP_IS, CTNODE_us_pos_NO_0156, (cst_val *)&val_0054},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0005 },
{ 2, CST_CART_OP_IS, CTNODE_us_pos_NO_0158, (cst_val *)&val_0055},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0005 },
{ 1, CST_CART_OP_IS, CTNODE_us_pos_NO_0160, (cst_val *)&val_0056},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0005 },
{ 1, CST_CART_OP_IS, CTNODE_us_pos_NO_0162, (cst_val *)&val_0000},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0010 },
{ 1, CST_CART_OP_IS, CTNODE_us_pos_NO_0164, (cst_val *)&val_0057},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0005 },
{ 9, CST_CART_OP_IS, CTNODE_us_pos_NO_0166, (cst_val *)&val_0035},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0005 },
{ 2, CST_CART_OP_IS, CTNODE_us_pos_NO_0168, (cst_val *)&val_0058},
{ 8, CST_CART_OP_IS, CTNODE_us_pos_NO_0169, (cst_val *)&val_0004},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0005 },
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0002 },
{ 4, CST_CART_OP_IS, CTNODE_us_pos_NO_0172, (cst_val *)&val_0026},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0002 },
{ 1, CST_CART_OP_IS, CTNODE_us_pos_NO_0174, (cst_val *)&val_0059},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0002 },
{ 1, CST_CART_OP_IS, CTNODE_us_pos_NO_0176, (cst_val *)&val_0060},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0002 },
{ 1, CST_CART_OP_IS, CTNODE_us_pos_NO_0178, (cst_val *)&val_0061},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0002 },
{ 1, CST_CART_OP_IS, CTNODE_us_pos_NO_0180, (cst_val *)&val_0062},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0002 },
{ 1, CST_CART_OP_IS, CTNODE_us_pos_NO_0182, (cst_val *)&val_0063},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0002 },
{ 1, CST_CART_OP_IS, CTNODE_us_pos_NO_0184, (cst_val *)&val_0064},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0002 },
{ 1, CST_CART_OP_IS, CTNODE_us_pos_NO_0186, (cst_val *)&val_0065},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0002 },
{ 4, CST_CART_OP_IS, CTNODE_us_pos_NO_0188, (cst_val *)&val_0000},
{ 1, CST_CART_OP_IS, CTNODE_us_pos_NO_0189, (cst_val *)&val_0066},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0002 },
{ 1, CST_CART_OP_IS, CTNODE_us_pos_NO_0191, (cst_val *)&val_0067},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0002 },
{ 1, CST_CART_OP_IS, CTNODE_us_pos_NO_0193, (cst_val *)&val_0068},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0002 },
{ 6, CST_CART_OP_IS, CTNODE_us_pos_NO_0195, (cst_val *)&val_0007},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0002 },
{ 1, CST_CART_OP_IS, CTNODE_us_pos_NO_0197, (cst_val *)&val_0069},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0002 },
{ 1, CST_CART_OP_IS, CTNODE_us_pos_NO_0199, (cst_val *)&val_0070},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0002 },
{ 1, CST_CART_OP_IS, CTNODE_us_pos_NO_0201, (cst_val *)&val_0071},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0002 },
{ 6, CST_CART_OP_IS, CTNODE_us_pos_NO_0203, (cst_val *)&val_0026},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0002 },
{ 1, CST_CART_OP_IS, CTNODE_us_pos_NO_0205, (cst_val *)&val_0072},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0002 },
{ 1, CST_CART_OP_IS, CTNODE_us_pos_NO_0207, (cst_val *)&val_0073},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0005 },
{ 6, CST_CART_OP_IS, CTNODE_us_pos_NO_0209, (cst_val *)&val_0000},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0002 },
{ 8, CST_CART_OP_IS, CTNODE_us_pos_NO_0211, (cst_val *)&val_0074},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0002 },
{ 6, CST_CART_OP_IS, CTNODE_us_pos_NO_0213, (cst_val *)&val_0075},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0002 },
{ 8, CST_CART_OP_IS, CTNODE_us_pos_NO_0215, (cst_val *)&val_0003},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0002 },
{ 2, CST_CART_OP_IS, CTNODE_us_pos_NO_0217, (cst_val *)&val_0004},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0002 },
{ 7, CST_CART_OP_IS, CTNODE_us_pos_NO_0219, (cst_val *)&val_0000},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0005 },
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0002 },
{ 1, CST_CART_OP_IS, CTNODE_us_pos_NO_0222, (cst_val *)&val_0076},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0005 },
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0002 },
{ 1, CST_CART_OP_IS, CTNODE_us_pos_NO_0225, (cst_val *)&val_0013},
{ 4, CST_CART_OP_IS, CTNODE_us_pos_NO_0226, (cst_val *)&val_0007},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0002 },
{ 2, CST_CART_OP_IS, CTNODE_us_pos_NO_0228, (cst_val *)&val_0077},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0078 },
{ 4, CST_CART_OP_IS, CTNODE_us_pos_NO_0230, (cst_val *)&val_0079},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0010 },
{ 6, CST_CART_OP_IS, CTNODE_us_pos_NO_0232, (cst_val *)&val_0079},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0005 },
{ 4, CST_CART_OP_IS, CTNODE_us_pos_NO_0234, (cst_val *)&val_0026},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0002 },
{ 2, CST_CART_OP_IS, CTNODE_us_pos_NO_0236, (cst_val *)&val_0080},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0078 },
{ 3, CST_CART_OP_IS, CTNODE_us_pos_NO_0238, (cst_val *)&val_0026},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0078 },
{ 5, CST_CART_OP_IS, CTNODE_us_pos_NO_0240, (cst_val *)&val_0004},
{ 2, CST_CART_OP_IS, CTNODE_us_pos_NO_0241, (cst_val *)&val_0004},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0078 },
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0010 },
{ 5, CST_CART_OP_IS, CTNODE_us_pos_NO_0244, (cst_val *)&val_0020},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0078 },
{ 8, CST_CART_OP_IS, CTNODE_us_pos_NO_0246, (cst_val *)&val_0004},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0078 },
{ 2, CST_CART_OP_IS, CTNODE_us_pos_NO_0248, (cst_val *)&val_0004},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0002 },
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0078 },
{ 4, CST_CART_OP_IS, CTNODE_us_pos_NO_0251, (cst_val *)&val_0079},
{ 1, CST_CART_OP_IS, CTNODE_us_pos_NO_0252, (cst_val *)&val_0036},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0005 },
{ 1, CST_CART_OP_IS, CTNODE_us_pos_NO_0254, (cst_val *)&val_0033},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0005 },
{ 1, CST_CART_OP_IS, CTNODE_us_pos_NO_0256, (cst_val *)&val_0081},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0005 },
{ 1, CST_CART_OP_IS, CTNODE_us_pos_NO_0258, (cst_val *)&val_0032},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0005 },
{ 9, CST_CART_OP_IS, CTNODE_us_pos_NO_0260, (cst_val *)&val_0003},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0010 },
{ 1, CST_CART_OP_IS, CTNODE_us_pos_NO_0262, (cst_val *)&val_0014},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0010 },
{ 1, CST_CART_OP_IS, CTNODE_us_pos_NO_0264, (cst_val *)&val_0015},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0010 },
{ 1, CST_CART_OP_IS, CTNODE_us_pos_NO_0266, (cst_val *)&val_0012},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0010 },
{ 9, CST_CART_OP_IS, CTNODE_us_pos_NO_0268, (cst_val *)&val_0004},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0010 },
{ 7, CST_CART_OP_IS, CTNODE_us_pos_NO_0270, (cst_val *)&val_0000},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0005 },
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0010 },
{ 1, CST_CART_OP_IS, CTNODE_us_pos_NO_0273, (cst_val *)&val_0016},
{ 7, CST_CART_OP_IS, CTNODE_us_pos_NO_0274, (cst_val *)&val_0025},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0002 },
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0005 },
{ 1, CST_CART_OP_IS, CTNODE_us_pos_NO_0277, (cst_val *)&val_0036},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0005 },
{ 1, CST_CART_OP_IS, CTNODE_us_pos_NO_0279, (cst_val *)&val_0041},
{ 4, CST_CART_OP_IS, CTNODE_us_pos_NO_0280, (cst_val *)&val_0007},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0010 },
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0005 },
{ 1, CST_CART_OP_IS, CTNODE_us_pos_NO_0283, (cst_val *)&val_0011},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0078 },
{ 3, CST_CART_OP_IS, CTNODE_us_pos_NO_0285, (cst_val *)&val_0075},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0005 },
{ 1, CST_CART_OP_IS, CTNODE_us_pos_NO_0287, (cst_val *)&val_0033},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0005 },
{ 1, CST_CART_OP_IS, CTNODE_us_pos_NO_0289, (cst_val *)&val_0082},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0005 },
{ 9, CST_CART_OP_IS, CTNODE_us_pos_NO_0291, (cst_val *)&val_0021},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0002 },
{ 2, CST_CART_OP_IS, CTNODE_us_pos_NO_0293, (cst_val *)&val_0055},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0005 },
{ 1, CST_CART_OP_IS, CTNODE_us_pos_NO_0295, (cst_val *)&val_0017},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0010 },
{ 1, CST_CART_OP_IS, CTNODE_us_pos_NO_0297, (cst_val *)&val_0015},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0010 },
{ 1, CST_CART_OP_IS, CTNODE_us_pos_NO_0299, (cst_val *)&val_0012},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0010 },
{ 1, CST_CART_OP_IS, CTNODE_us_pos_NO_0301, (cst_val *)&val_0014},
{ 4, CST_CART_OP_IS, CTNODE_us_pos_NO_0302, (cst_val *)&val_0007},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0002 },
{ 2, CST_CART_OP_IS, CTNODE_us_pos_NO_0304, (cst_val *)&val_0083},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0002 },
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0010 },
{ 9, CST_CART_OP_IS, CTNODE_us_pos_NO_0307, (cst_val *)&val_0003},
{ 1, CST_CART_OP_IS, CTNODE_us_pos_NO_0308, (cst_val *)&val_0084},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0005 },
{ 1, CST_CART_OP_IS, CTNODE_us_pos_NO_0310, (cst_val *)&val_0085},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0010 },
{ 1, CST_CART_OP_IS, CTNODE_us_pos_NO_0312, (cst_val *)&val_0051},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0010 },
{ 1, CST_CART_OP_IS, CTNODE_us_pos_NO_0314, (cst_val *)&val_0018},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0005 },
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0002 },
{ 1, CST_CART_OP_IS, CTNODE_us_pos_NO_0317, (cst_val *)&val_0009},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0010 },
{ 1, CST_CART_OP_IS, CTNODE_us_pos_NO_0319, (cst_val *)&val_0032},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0005 },
{ 1, CST_CART_OP_IS, CTNODE_us_pos_NO_0321, (cst_val *)&val_0030},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0005 },
{ 1, CST_CART_OP_IS, CTNODE_us_pos_NO_0323, (cst_val *)&val_0081},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0005 },
{ 1, CST_CART_OP_IS, CTNODE_us_pos_NO_0325, (cst_val *)&val_0076},
{ 3, CST_CART_OP_IS, CTNODE_us_pos_NO_0326, (cst_val *)&val_0026},
{ 4, CST_CART_OP_IS, CTNODE_us_pos_NO_0327, (cst_val *)&val_0000},
{ 2, CST_CART_OP_IS, CTNODE_us_pos_NO_0328, (cst_val *)&val_0004},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0002 },
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0005 },
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0002 },
{ 4, CST_CART_OP_IS, CTNODE_us_pos_NO_0332, (cst_val *)&val_0075},
{ 8, CST_CART_OP_IS, CTNODE_us_pos_NO_0333, (cst_val *)&val_0021},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0002 },
{ 9, CST_CART_OP_IS, CTNODE_us_pos_NO_0335, (cst_val *)&val_0004},
{ 6, CST_CART_OP_IS, CTNODE_us_pos_NO_0336, (cst_val *)&val_0026},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0005 },
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0002 },
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0002 },
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0002 },
{ 9, CST_CART_OP_IS, CTNODE_us_pos_NO_0341, (cst_val *)&val_0086},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0078 },
{ 2, CST_CART_OP_IS, CTNODE_us_pos_NO_0343, (cst_val *)&val_0054},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0005 },
{ 9, CST_CART_OP_IS, CTNODE_us_pos_NO_0345, (cst_val *)&val_0058},
{ 1, CST_CART_OP_IS, CTNODE_us_pos_NO_0346, (cst_val *)&val_0087},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0005 },
{ 1, CST_CART_OP_IS, CTNODE_us_pos_NO_0348, (cst_val *)&val_0088},
{ 7, CST_CART_OP_IS, CTNODE_us_pos_NO_0349, (cst_val *)&val_0000},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0002 },
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0005 },
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0002 },
{ 9, CST_CART_OP_IS, CTNODE_us_pos_NO_0353, (cst_val *)&val_0089},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0005 },
{ 1, CST_CART_OP_IS, CTNODE_us_pos_NO_0355, (cst_val *)&val_0042},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0005 },
{ 4, CST_CART_OP_IS, CTNODE_us_pos_NO_0357, (cst_val *)&val_0007},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0002 },
{ 6, CST_CART_OP_IS, CTNODE_us_pos_NO_0359, (cst_val *)&val_0079},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0002 },
{ 1, CST_CART_OP_IS, CTNODE_us_pos_NO_0361, (cst_val *)&val_0090},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0002 },
{ 6, CST_CART_OP_IS, CTNODE_us_pos_NO_0363, (cst_val *)&val_0008},
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0005 },
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0002 },
{ 255, CST_CART_OP_NONE, 0, (cst_val *)&val_0091 },
{ 255, CST_CART_OP_NONE, 0, 0}};
static const char * const us_pos_feat_table[] = {
"gpos",
"name",
"p.name",
"n.gpos",
"p.gpos",
"n.n.name",
"p.p.gpos",
"n.n.gpos",
"p.p.name",
"n.name",
NULL };
const cst_cart us_pos_cart = {
us_pos_cart_nodes,
us_pos_feat_table
};
@@ -0,0 +1,280 @@
/*******************************************************/
/** Autogenerated cart tree for us_pos */
/** from . */
/*******************************************************/
DEF_STATIC_CONST_VAL_STRING(val_0000,"content");
DEF_STATIC_CONST_VAL_STRING(val_0001,"house");
DEF_STATIC_CONST_VAL_STRING(val_0002,"n");
#define CTNODE_us_pos_NO_0001 3
DEF_STATIC_CONST_VAL_STRING(val_0003,"to");
DEF_STATIC_CONST_VAL_STRING(val_0004,"_other_");
#define CTNODE_us_pos_NO_0004 6
DEF_STATIC_CONST_VAL_STRING(val_0005,"v");
#define CTNODE_us_pos_NO_0003 7
DEF_STATIC_CONST_VAL_STRING(val_0006,"does");
#define CTNODE_us_pos_NO_0007 9
DEF_STATIC_CONST_VAL_STRING(val_0007,"det");
#define CTNODE_us_pos_NO_0010 12
#define CTNODE_us_pos_NO_0009 13
DEF_STATIC_CONST_VAL_STRING(val_0008,"md");
#define CTNODE_us_pos_NO_0013 15
DEF_STATIC_CONST_VAL_STRING(val_0009,"separate");
DEF_STATIC_CONST_VAL_STRING(val_0010,"j");
#define CTNODE_us_pos_NO_0017 19
DEF_STATIC_CONST_VAL_STRING(val_0011,"overall");
#define CTNODE_us_pos_NO_0019 21
DEF_STATIC_CONST_VAL_STRING(val_0012,"perfect");
#define CTNODE_us_pos_NO_0021 23
DEF_STATIC_CONST_VAL_STRING(val_0013,"close");
#define CTNODE_us_pos_NO_0023 25
DEF_STATIC_CONST_VAL_STRING(val_0014,"present");
#define CTNODE_us_pos_NO_0025 27
DEF_STATIC_CONST_VAL_STRING(val_0015,"appropriate");
#define CTNODE_us_pos_NO_0027 29
DEF_STATIC_CONST_VAL_STRING(val_0016,"live");
#define CTNODE_us_pos_NO_0029 31
DEF_STATIC_CONST_VAL_STRING(val_0017,"moderate");
#define CTNODE_us_pos_NO_0031 33
DEF_STATIC_CONST_VAL_STRING(val_0018,"lead");
#define CTNODE_us_pos_NO_0033 35
DEF_STATIC_CONST_VAL_STRING(val_0019,"rebel");
#define CTNODE_us_pos_NO_0035 37
DEF_STATIC_CONST_VAL_STRING(val_0020,"the");
DEF_STATIC_CONST_VAL_STRING(val_0021,"of");
#define CTNODE_us_pos_NO_0038 40
#define CTNODE_us_pos_NO_0037 41
DEF_STATIC_CONST_VAL_STRING(val_0022,"elaborate");
#define CTNODE_us_pos_NO_0041 43
#define CTNODE_us_pos_NO_0043 45
DEF_STATIC_CONST_VAL_STRING(val_0023,"record");
#define CTNODE_us_pos_NO_0046 48
#define CTNODE_us_pos_NO_0045 49
DEF_STATIC_CONST_VAL_STRING(val_0024,"an");
#define CTNODE_us_pos_NO_0050 52
#define CTNODE_us_pos_NO_0049 53
#define CTNODE_us_pos_NO_0016 54
DEF_STATIC_CONST_VAL_STRING(val_0025,"punc");
#define CTNODE_us_pos_NO_0055 57
DEF_STATIC_CONST_VAL_STRING(val_0026,"in");
#define CTNODE_us_pos_NO_0057 59
DEF_STATIC_CONST_VAL_STRING(val_0027,"adv");
DEF_STATIC_CONST_VAL_STRING(val_0028,"nineteen");
#define CTNODE_us_pos_NO_0060 62
DEF_STATIC_CONST_VAL_STRING(val_0029,"six");
#define CTNODE_us_pos_NO_0062 64
#define CTNODE_us_pos_NO_0059 65
#define CTNODE_us_pos_NO_0054 66
#define CTNODE_us_pos_NO_0066 68
#define CTNODE_us_pos_NO_0068 70
DEF_STATIC_CONST_VAL_STRING(val_0030,"putting");
#define CTNODE_us_pos_NO_0070 72
#define CTNODE_us_pos_NO_0072 74
#define CTNODE_us_pos_NO_0074 76
#define CTNODE_us_pos_NO_0077 79
#define CTNODE_us_pos_NO_0079 81
#define CTNODE_us_pos_NO_0081 83
#define CTNODE_us_pos_NO_0083 85
#define CTNODE_us_pos_NO_0076 86
DEF_STATIC_CONST_VAL_STRING(val_0031,"frequent");
#define CTNODE_us_pos_NO_0086 88
#define CTNODE_us_pos_NO_0088 90
DEF_STATIC_CONST_VAL_STRING(val_0032,"bought");
#define CTNODE_us_pos_NO_0090 92
DEF_STATIC_CONST_VAL_STRING(val_0033,"read");
#define CTNODE_us_pos_NO_0092 94
DEF_STATIC_CONST_VAL_STRING(val_0034,"use");
#define CTNODE_us_pos_NO_0095 97
DEF_STATIC_CONST_VAL_STRING(val_0035,"it");
#define CTNODE_us_pos_NO_0097 99
#define CTNODE_us_pos_NO_0099 101
#define CTNODE_us_pos_NO_0094 102
DEF_STATIC_CONST_VAL_STRING(val_0036,"lived");
#define CTNODE_us_pos_NO_0102 104
DEF_STATIC_CONST_VAL_STRING(val_0037,"aged");
#define CTNODE_us_pos_NO_0104 106
DEF_STATIC_CONST_VAL_STRING(val_0038,"uses");
#define CTNODE_us_pos_NO_0106 108
#define CTNODE_us_pos_NO_0108 110
#define CTNODE_us_pos_NO_0110 112
#define CTNODE_us_pos_NO_0112 114
DEF_STATIC_CONST_VAL_STRING(val_0039,"associate");
#define CTNODE_us_pos_NO_0114 116
DEF_STATIC_CONST_VAL_STRING(val_0040,"compact");
#define CTNODE_us_pos_NO_0116 118
DEF_STATIC_CONST_VAL_STRING(val_0041,"suspect");
#define CTNODE_us_pos_NO_0118 120
#define CTNODE_us_pos_NO_0120 122
#define CTNODE_us_pos_NO_0123 125
#define CTNODE_us_pos_NO_0122 126
DEF_STATIC_CONST_VAL_STRING(val_0042,"produce");
#define CTNODE_us_pos_NO_0126 128
DEF_STATIC_CONST_VAL_STRING(val_0043,"produces");
#define CTNODE_us_pos_NO_0128 130
DEF_STATIC_CONST_VAL_STRING(val_0044,"excess");
#define CTNODE_us_pos_NO_0130 132
DEF_STATIC_CONST_VAL_STRING(val_0045,"combine");
#define CTNODE_us_pos_NO_0132 134
DEF_STATIC_CONST_VAL_STRING(val_0046,"tear");
#define CTNODE_us_pos_NO_0134 136
DEF_STATIC_CONST_VAL_STRING(val_0047,"presents");
#define CTNODE_us_pos_NO_0136 138
DEF_STATIC_CONST_VAL_STRING(val_0048,"minute");
#define CTNODE_us_pos_NO_0138 140
DEF_STATIC_CONST_VAL_STRING(val_0049,"rejects");
#define CTNODE_us_pos_NO_0140 142
#define CTNODE_us_pos_NO_0142 144
DEF_STATIC_CONST_VAL_STRING(val_0050,"mrs");
#define CTNODE_us_pos_NO_0144 146
DEF_STATIC_CONST_VAL_STRING(val_0051,"subject");
#define CTNODE_us_pos_NO_0146 148
DEF_STATIC_CONST_VAL_STRING(val_0052,"permits");
#define CTNODE_us_pos_NO_0148 150
DEF_STATIC_CONST_VAL_STRING(val_0053,"reading");
#define CTNODE_us_pos_NO_0152 154
#define CTNODE_us_pos_NO_0151 155
#define CTNODE_us_pos_NO_0150 156
DEF_STATIC_CONST_VAL_STRING(val_0054,"not");
#define CTNODE_us_pos_NO_0156 158
DEF_STATIC_CONST_VAL_STRING(val_0055,"who");
#define CTNODE_us_pos_NO_0158 160
DEF_STATIC_CONST_VAL_STRING(val_0056,"collect");
#define CTNODE_us_pos_NO_0160 162
#define CTNODE_us_pos_NO_0162 164
DEF_STATIC_CONST_VAL_STRING(val_0057,"permit");
#define CTNODE_us_pos_NO_0164 166
#define CTNODE_us_pos_NO_0166 168
DEF_STATIC_CONST_VAL_STRING(val_0058,"that");
#define CTNODE_us_pos_NO_0169 171
#define CTNODE_us_pos_NO_0168 172
#define CTNODE_us_pos_NO_0172 174
DEF_STATIC_CONST_VAL_STRING(val_0059,"records");
#define CTNODE_us_pos_NO_0174 176
DEF_STATIC_CONST_VAL_STRING(val_0060,"survey");
#define CTNODE_us_pos_NO_0176 178
DEF_STATIC_CONST_VAL_STRING(val_0061,"allies");
#define CTNODE_us_pos_NO_0178 180
DEF_STATIC_CONST_VAL_STRING(val_0062,"abuse");
#define CTNODE_us_pos_NO_0180 182
DEF_STATIC_CONST_VAL_STRING(val_0063,"project");
#define CTNODE_us_pos_NO_0182 184
DEF_STATIC_CONST_VAL_STRING(val_0064,"contract");
#define CTNODE_us_pos_NO_0184 186
DEF_STATIC_CONST_VAL_STRING(val_0065,"nasa");
#define CTNODE_us_pos_NO_0186 188
DEF_STATIC_CONST_VAL_STRING(val_0066,"impact");
#define CTNODE_us_pos_NO_0189 191
DEF_STATIC_CONST_VAL_STRING(val_0067,"concert");
#define CTNODE_us_pos_NO_0191 193
DEF_STATIC_CONST_VAL_STRING(val_0068,"progress");
#define CTNODE_us_pos_NO_0193 195
#define CTNODE_us_pos_NO_0195 197
DEF_STATIC_CONST_VAL_STRING(val_0069,"rebels");
#define CTNODE_us_pos_NO_0197 199
DEF_STATIC_CONST_VAL_STRING(val_0070,"associates");
#define CTNODE_us_pos_NO_0199 201
DEF_STATIC_CONST_VAL_STRING(val_0071,"graduate");
#define CTNODE_us_pos_NO_0201 203
#define CTNODE_us_pos_NO_0203 205
DEF_STATIC_CONST_VAL_STRING(val_0072,"export");
#define CTNODE_us_pos_NO_0205 207
DEF_STATIC_CONST_VAL_STRING(val_0073,"increases");
#define CTNODE_us_pos_NO_0207 209
#define CTNODE_us_pos_NO_0209 211
DEF_STATIC_CONST_VAL_STRING(val_0074,"and");
#define CTNODE_us_pos_NO_0211 213
DEF_STATIC_CONST_VAL_STRING(val_0075,"pps");
#define CTNODE_us_pos_NO_0213 215
#define CTNODE_us_pos_NO_0215 217
#define CTNODE_us_pos_NO_0217 219
#define CTNODE_us_pos_NO_0219 221
#define CTNODE_us_pos_NO_0188 222
DEF_STATIC_CONST_VAL_STRING(val_0076,"lives");
#define CTNODE_us_pos_NO_0222 224
#define CTNODE_us_pos_NO_0015 225
#define CTNODE_us_pos_NO_0226 228
DEF_STATIC_CONST_VAL_STRING(val_0077,"sources");
DEF_STATIC_CONST_VAL_STRING(val_0078,"r");
#define CTNODE_us_pos_NO_0228 230
DEF_STATIC_CONST_VAL_STRING(val_0079,"aux");
#define CTNODE_us_pos_NO_0230 232
#define CTNODE_us_pos_NO_0232 234
#define CTNODE_us_pos_NO_0234 236
DEF_STATIC_CONST_VAL_STRING(val_0080,"source");
#define CTNODE_us_pos_NO_0236 238
#define CTNODE_us_pos_NO_0238 240
#define CTNODE_us_pos_NO_0241 243
#define CTNODE_us_pos_NO_0240 244
#define CTNODE_us_pos_NO_0244 246
#define CTNODE_us_pos_NO_0246 248
#define CTNODE_us_pos_NO_0248 250
#define CTNODE_us_pos_NO_0225 251
#define CTNODE_us_pos_NO_0252 254
#define CTNODE_us_pos_NO_0254 256
DEF_STATIC_CONST_VAL_STRING(val_0081,"upset");
#define CTNODE_us_pos_NO_0256 258
#define CTNODE_us_pos_NO_0258 260
#define CTNODE_us_pos_NO_0260 262
#define CTNODE_us_pos_NO_0262 264
#define CTNODE_us_pos_NO_0264 266
#define CTNODE_us_pos_NO_0266 268
#define CTNODE_us_pos_NO_0268 270
#define CTNODE_us_pos_NO_0270 272
#define CTNODE_us_pos_NO_0251 273
#define CTNODE_us_pos_NO_0274 276
#define CTNODE_us_pos_NO_0273 277
#define CTNODE_us_pos_NO_0277 279
#define CTNODE_us_pos_NO_0280 282
#define CTNODE_us_pos_NO_0279 283
#define CTNODE_us_pos_NO_0283 285
#define CTNODE_us_pos_NO_0285 287
#define CTNODE_us_pos_NO_0287 289
DEF_STATIC_CONST_VAL_STRING(val_0082,"object");
#define CTNODE_us_pos_NO_0289 291
#define CTNODE_us_pos_NO_0291 293
#define CTNODE_us_pos_NO_0293 295
#define CTNODE_us_pos_NO_0295 297
#define CTNODE_us_pos_NO_0297 299
#define CTNODE_us_pos_NO_0299 301
#define CTNODE_us_pos_NO_0302 304
DEF_STATIC_CONST_VAL_STRING(val_0083,"at");
#define CTNODE_us_pos_NO_0304 306
#define CTNODE_us_pos_NO_0301 307
DEF_STATIC_CONST_VAL_STRING(val_0084,"refuse");
#define CTNODE_us_pos_NO_0308 310
DEF_STATIC_CONST_VAL_STRING(val_0085,"contrary");
#define CTNODE_us_pos_NO_0310 312
#define CTNODE_us_pos_NO_0312 314
#define CTNODE_us_pos_NO_0314 316
#define CTNODE_us_pos_NO_0307 317
#define CTNODE_us_pos_NO_0317 319
#define CTNODE_us_pos_NO_0319 321
#define CTNODE_us_pos_NO_0321 323
#define CTNODE_us_pos_NO_0323 325
#define CTNODE_us_pos_NO_0328 330
#define CTNODE_us_pos_NO_0327 331
#define CTNODE_us_pos_NO_0326 332
#define CTNODE_us_pos_NO_0333 335
#define CTNODE_us_pos_NO_0336 338
#define CTNODE_us_pos_NO_0335 339
#define CTNODE_us_pos_NO_0332 340
#define CTNODE_us_pos_NO_0325 341
DEF_STATIC_CONST_VAL_STRING(val_0086,"be");
#define CTNODE_us_pos_NO_0341 343
#define CTNODE_us_pos_NO_0343 345
DEF_STATIC_CONST_VAL_STRING(val_0087,"estimate");
#define CTNODE_us_pos_NO_0346 348
DEF_STATIC_CONST_VAL_STRING(val_0088,"estimates");
#define CTNODE_us_pos_NO_0349 351
#define CTNODE_us_pos_NO_0348 352
#define CTNODE_us_pos_NO_0345 353
DEF_STATIC_CONST_VAL_STRING(val_0089,"up");
#define CTNODE_us_pos_NO_0353 355
#define CTNODE_us_pos_NO_0355 357
#define CTNODE_us_pos_NO_0357 359
#define CTNODE_us_pos_NO_0359 361
DEF_STATIC_CONST_VAL_STRING(val_0090,"tears");
#define CTNODE_us_pos_NO_0361 363
#define CTNODE_us_pos_NO_0363 365
#define CTNODE_us_pos_NO_0000 366
DEF_STATIC_CONST_VAL_STRING(val_0091,"0");
@@ -0,0 +1,224 @@
/* Autogenerated from make_us_regexes */
static const unsigned char ordinal_number_rxprog[] = {
156, 6, 0, 119, 1, 0, 3, 4, 0, 14, 48, 49, 50, 51, 52, 53,
54, 55, 56, 57, 0, 10, 0, 18, 4, 0, 0, 48, 49, 50, 51, 52,
53, 54, 55, 56, 57, 44, 0, 21, 0, 3, 6, 0, 9, 8, 0, 69,
116, 104, 0, 6, 0, 9, 8, 0, 60, 84, 72, 0, 6, 0, 9, 8,
0, 51, 115, 116, 0, 6, 0, 9, 8, 0, 42, 83, 84, 0, 6, 0,
9, 8, 0, 33, 110, 100, 0, 6, 0, 9, 8, 0, 24, 78, 68, 0,
6, 0, 9, 8, 0, 15, 114, 100, 0, 6, 0, 9, 8, 0, 6, 82,
68, 0, 31, 0, 3, 2, 0, 3, 0, 0, 0,
};
static const cst_regex ordinal_number_rx = {
0, 1, NULL, 0, 123,
(char *)ordinal_number_rxprog
};
const cst_regex * const ordinal_number = &ordinal_number_rx;
static const unsigned char hasvowel_rxprog[] = {
156, 6, 0, 35, 1, 0, 3, 10, 0, 6, 3, 0, 0, 4, 0, 14,
97, 101, 105, 111, 117, 65, 69, 73, 79, 85, 0, 10, 0, 6, 3, 0,
0, 2, 0, 3, 0, 0, 0,
};
static const cst_regex hasvowel_rx = {
0, 1, NULL, 0, 39,
(char *)hasvowel_rxprog
};
const cst_regex * const hasvowel = &hasvowel_rx;
static const unsigned char usmoney_rxprog[] = {
156, 6, 0, 72, 1, 0, 3, 8, 0, 5, 36, 0, 11, 0, 18, 4,
0, 0, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 44, 0, 6, 0,
34, 21, 0, 3, 6, 0, 25, 8, 0, 5, 46, 0, 11, 0, 17, 4,
0, 0, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 0, 31, 0, 6,
6, 0, 3, 9, 0, 3, 2, 0, 3, 0, 0, 0,
};
static const cst_regex usmoney_rx = {
0, 1, NULL, 0, 76,
(char *)usmoney_rxprog
};
const cst_regex * const usmoney = &usmoney_rx;
static const unsigned char illion_rxprog[] = {
156, 6, 0, 25, 1, 0, 3, 10, 0, 6, 3, 0, 0, 8, 0, 10,
105, 108, 108, 105, 111, 110, 0, 2, 0, 3, 0, 0, 0,
};
static const cst_regex illion_rx = {
0, 1, NULL, 0, 29,
(char *)illion_rxprog
};
const cst_regex * const illion = &illion_rx;
static const unsigned char romannums_rxprog[] = {
156, 6, 0, 137, 1, 0, 3, 21, 0, 3, 6, 0, 36, 8, 0, 5,
73, 0, 6, 0, 8, 8, 0, 8, 73, 0, 6, 0, 3, 9, 0, 3,
6, 0, 8, 8, 0, 8, 73, 0, 6, 0, 3, 9, 0, 89, 6, 0,
9, 8, 0, 83, 73, 86, 0, 6, 0, 50, 8, 0, 5, 86, 0, 6,
0, 8, 8, 0, 8, 73, 0, 6, 0, 3, 9, 0, 3, 6, 0, 8,
8, 0, 8, 73, 0, 6, 0, 3, 9, 0, 3, 6, 0, 8, 8, 0,
8, 73, 0, 6, 0, 3, 9, 0, 30, 6, 0, 9, 8, 0, 24, 73,
88, 0, 6, 0, 18, 8, 0, 5, 88, 0, 10, 0, 10, 4, 0, 0,
86, 73, 88, 0, 31, 0, 3, 2, 0, 3, 0, 0, 0,
};
static const cst_regex romannums_rx = {
0, 1, NULL, 0, 141,
(char *)romannums_rxprog
};
const cst_regex * const romannums = &romannums_rx;
static const unsigned char drst_rxprog[] = {
156, 6, 0, 45, 1, 0, 3, 21, 0, 3, 6, 0, 15, 4, 0, 6,
100, 68, 0, 4, 0, 21, 82, 114, 0, 6, 0, 15, 4, 0, 6, 83,
115, 0, 4, 0, 6, 116, 84, 0, 31, 0, 3, 2, 0, 3, 0, 0,
0,
};
static const cst_regex drst_rx = {
0, 1, NULL, 0, 49,
(char *)drst_rxprog
};
const cst_regex * const drst = &drst_rx;
static const unsigned char numess_rxprog[] = {
156, 6, 0, 31, 1, 0, 3, 11, 0, 17, 4, 0, 0, 48, 49, 50,
51, 52, 53, 54, 55, 56, 57, 0, 8, 0, 5, 115, 0, 2, 0, 3,
0, 0, 0,
};
static const cst_regex numess_rx = {
0, 1, NULL, 0, 35,
(char *)numess_rxprog
};
const cst_regex * const numess = &numess_rx;
static const unsigned char sevenphonenumber_rxprog[] = {
156, 6, 0, 112, 1, 0, 3, 4, 0, 14, 48, 49, 50, 51, 52, 53,
54, 55, 56, 57, 0, 4, 0, 14, 48, 49, 50, 51, 52, 53, 54, 55,
56, 57, 0, 4, 0, 14, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57,
0, 8, 0, 5, 45, 0, 4, 0, 14, 48, 49, 50, 51, 52, 53, 54,
55, 56, 57, 0, 4, 0, 14, 48, 49, 50, 51, 52, 53, 54, 55, 56,
57, 0, 4, 0, 14, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 0,
4, 0, 14, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 0, 2, 0,
3, 0, 0, 0,
};
static const cst_regex sevenphonenumber_rx = {
0, 1, NULL, 0, 116,
(char *)sevenphonenumber_rxprog
};
const cst_regex * const sevenphonenumber = &sevenphonenumber_rx;
static const unsigned char fourdigits_rxprog[] = {
156, 6, 0, 65, 1, 0, 3, 4, 0, 14, 48, 49, 50, 51, 52, 53,
54, 55, 56, 57, 0, 4, 0, 14, 48, 49, 50, 51, 52, 53, 54, 55,
56, 57, 0, 4, 0, 14, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57,
0, 4, 0, 14, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 0, 2,
0, 3, 0, 0, 0,
};
static const cst_regex fourdigits_rx = {
0, 1, NULL, 0, 69,
(char *)fourdigits_rxprog
};
const cst_regex * const fourdigits = &fourdigits_rx;
static const unsigned char threedigits_rxprog[] = {
156, 6, 0, 51, 1, 0, 3, 4, 0, 14, 48, 49, 50, 51, 52, 53,
54, 55, 56, 57, 0, 4, 0, 14, 48, 49, 50, 51, 52, 53, 54, 55,
56, 57, 0, 4, 0, 14, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57,
0, 2, 0, 3, 0, 0, 0,
};
static const cst_regex threedigits_rx = {
0, 1, NULL, 0, 55,
(char *)threedigits_rxprog
};
const cst_regex * const threedigits = &threedigits_rx;
static const unsigned char numbertime_rxprog[] = {
156, 6, 0, 75, 1, 0, 3, 6, 0, 17, 4, 0, 17, 48, 49, 50,
51, 52, 53, 54, 55, 56, 57, 0, 6, 0, 3, 9, 0, 3, 4, 0,
14, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 0, 8, 0, 5, 58,
0, 4, 0, 10, 48, 49, 50, 51, 52, 53, 0, 4, 0, 14, 48, 49,
50, 51, 52, 53, 54, 55, 56, 57, 0, 2, 0, 3, 0, 0, 0,
};
static const cst_regex numbertime_rx = {
0, 1, NULL, 0, 79,
(char *)numbertime_rxprog
};
const cst_regex * const numbertime = &numbertime_rx;
static const unsigned char numbertimexm_rxprog[] = {
156, 6, 0, 87, 1, 0, 3, 6, 0, 17, 4, 0, 17, 48, 49, 50,
51, 52, 53, 54, 55, 56, 57, 0, 6, 0, 3, 9, 0, 3, 4, 0,
14, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 0, 4, 0, 6, 58,
46, 0, 4, 0, 10, 48, 49, 50, 51, 52, 53, 0, 4, 0, 14, 48,
49, 50, 51, 52, 53, 54, 55, 56, 57, 0, 4, 0, 6, 97, 112, 0,
8, 0, 5, 109, 0, 2, 0, 3, 0, 0, 0,
};
static const cst_regex numbertimexm_rx = {
0, 1, NULL, 0, 91,
(char *)numbertimexm_rxprog
};
const cst_regex * const numbertimexm = &numbertimexm_rx;
static const unsigned char dottedabbrevs_rxprog[] = {
156, 6, 0, 161, 1, 0, 3, 21, 0, 3, 6, 0, 64, 4, 0, 56,
65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,
81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 97, 98, 99, 100, 101, 102,
103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118,
119, 120, 121, 122, 0, 8, 0, 5, 46, 0, 31, 0, 3, 6, 0, 6,
7, 0, 73, 6, 0, 3, 9, 0, 3, 4, 0, 56, 65, 66, 67, 68,
69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
85, 86, 87, 88, 89, 90, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106,
107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122,
0, 6, 0, 8, 8, 0, 8, 46, 0, 6, 0, 3, 9, 0, 3, 2,
0, 3, 0, 0, 0,
};
static const cst_regex dottedabbrevs_rx = {
0, 1, NULL, 0, 165,
(char *)dottedabbrevs_rxprog
};
const cst_regex * const dottedabbrevs = &dottedabbrevs_rx;
static const unsigned char digitsslashdigits_rxprog[] = {
156, 6, 0, 48, 1, 0, 3, 11, 0, 17, 4, 0, 0, 48, 49, 50,
51, 52, 53, 54, 55, 56, 57, 0, 8, 0, 5, 47, 0, 11, 0, 17,
4, 0, 0, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 0, 2, 0,
3, 0, 0, 0,
};
static const cst_regex digitsslashdigits_rx = {
0, 1, NULL, 0, 52,
(char *)digitsslashdigits_rxprog
};
const cst_regex * const digitsslashdigits = &digitsslashdigits_rx;
static const unsigned char digits2dash_rxprog[] = {
156, 6, 0, 72, 1, 0, 3, 21, 0, 3, 6, 0, 28, 11, 0, 17,
4, 0, 0, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 0, 8, 0,
5, 45, 0, 3, 0, 3, 31, 0, 3, 6, 0, 6, 7, 0, 37, 6,
0, 3, 9, 0, 3, 11, 0, 17, 4, 0, 0, 48, 49, 50, 51, 52,
53, 54, 55, 56, 57, 0, 2, 0, 3, 0, 0, 0,
};
static const cst_regex digits2dash_rx = {
0, 1, NULL, 0, 76,
(char *)digits2dash_rxprog
};
const cst_regex * const digits2dash = &digits2dash_rx;
static const unsigned char wandm_rxprog[] = {
156, 6, 0, 190, 1, 0, 3, 10, 0, 18, 4, 0, 0, 48, 49, 50,
51, 52, 53, 54, 55, 56, 57, 44, 0, 11, 0, 17, 4, 0, 0, 48,
49, 50, 51, 52, 53, 54, 55, 56, 57, 0, 21, 0, 3, 6, 0, 9,
8, 0, 137, 108, 98, 0, 6, 0, 9, 8, 0, 128, 76, 66, 0, 6,
0, 10, 8, 0, 119, 108, 98, 115, 0, 6, 0, 10, 8, 0, 109, 76,
66, 83, 0, 6, 0, 9, 8, 0, 99, 102, 116, 0, 6, 0, 9, 8,
0, 90, 70, 84, 0, 6, 0, 9, 8, 0, 81, 107, 103, 0, 6, 0,
9, 8, 0, 72, 107, 109, 0, 6, 0, 9, 8, 0, 63, 111, 122, 0,
6, 0, 9, 8, 0, 54, 104, 122, 0, 6, 0, 9, 8, 0, 45, 72,
122, 0, 6, 0, 9, 8, 0, 36, 72, 90, 0, 6, 0, 10, 8, 0,
27, 75, 72, 122, 0, 6, 0, 10, 8, 0, 17, 77, 72, 122, 0, 6,
0, 10, 8, 0, 7, 71, 72, 122, 0, 31, 0, 3, 2, 0, 3, 0,
0, 0,
};
static const cst_regex wandm_rx = {
0, 1, NULL, 0, 194,
(char *)wandm_rxprog
};
const cst_regex * const wandm = &wandm_rx;
+902
View File
@@ -0,0 +1,902 @@
/*************************************************************************/
/* */
/* 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 */
/*************************************************************************/
/* */
/* US English text analysis functions */
/* */
/*************************************************************************/
#include <ctype.h>
#include "flite.h"
#include "usenglish.h"
#include "us_text.h"
#include "cst_regex.h"
static int text_splitable(const char *s,int i);
static cst_val *state_name(const char *name,cst_item *t);
/* compiled us regexes */
#include "us_regexes.h"
static const char * const wandm_abbrevs[99][2] =
{
{ "LB", "pounds" },
{ "LBS", "pounds" },
{ "lb", "pounds" },
{ "lbs", "pounds" },
{ "ft", "feet" },
{ "FT", "feet" },
{ "kg", "kilograms" },
{ "km", "kilometers" },
{ "oz", "ounces" },
{ "hz", "hertz" },
{ "Hz", "hertz" },
{ "HZ", "hertz" },
{ "KHz", "kilohertz" },
{ "MHz", "megahertz" },
{ "GHz", "gigahertz" },
{ NULL, NULL },
};
static const char * const eedwords[] = {
"to",
"can",
"can't",
"cannot",
"cant",
"could",
"couldn't",
"couldnt",
"will",
"shall",
NULL};
void us_text_init()
{
/* Nothing */
}
void us_text_deinit()
{
/* Nothing */
}
static int rex_like(const cst_item *t)
{
/* returns 1 if this is in a king like context */
char *pn = cst_downcase(ffeature_string(t,"p.name"));
char *ppn = cst_downcase(ffeature_string(t,"p.p.name"));
int v = 0;
if (cst_streq(pn,"louis") ||
cst_streq(pn,"henry") ||
cst_streq(pn,"charles") ||
cst_streq(pn,"philip") ||
cst_streq(pn,"george") ||
cst_streq(pn,"edward") ||
cst_streq(pn,"pius") ||
cst_streq(pn,"william") ||
cst_streq(pn,"richard") ||
cst_streq(pn,"ptolemy") ||
cst_streq(pn,"john") ||
cst_streq(pn,"paul") ||
cst_streq(pn,"peter") ||
cst_streq(pn,"nicholas") ||
cst_streq(pn,"frederick") ||
cst_streq(pn,"james") ||
cst_streq(pn,"alfonso") ||
cst_streq(pn,"ivan") ||
cst_streq(pn,"napolean") ||
cst_streq(pn,"leo") ||
cst_streq(pn,"gregory") ||
cst_streq(pn,"catherine") ||
cst_streq(pn,"alexandria") ||
cst_streq(pn,"pierre") ||
cst_streq(pn,"elizabeth") ||
cst_streq(pn,"mary"))
v = 1;
else if (cst_streq(ppn,"king") ||
cst_streq(ppn,"queen") ||
cst_streq(ppn,"pope") ||
cst_streq(ppn,"duke") ||
cst_streq(ppn,"tsar") ||
cst_streq(ppn,"emperor") ||
cst_streq(ppn,"shah") ||
cst_streq(ppn,"ceasar") ||
cst_streq(ppn,"duchess") ||
cst_streq(ppn,"tsarina") ||
cst_streq(ppn,"empress") ||
cst_streq(ppn,"baron") ||
cst_streq(ppn,"baroness") ||
cst_streq(ppn,"sultan") ||
cst_streq(ppn,"count") ||
cst_streq(ppn,"countess"))
v = 1;
cst_free(pn);
cst_free(ppn);
return v;
}
static int section_like(const cst_item *t)
{
/* returns 1 if this is in a king like context */
char *pn = cst_downcase(ffeature_string(t,"p.name"));
int v = 0;
if (cst_streq(pn,"section") ||
cst_streq(pn,"chapter") ||
cst_streq(pn,"part") ||
cst_streq(pn,"phrase") ||
cst_streq(pn,"verse") ||
cst_streq(pn,"scene") ||
cst_streq(pn,"act") ||
cst_streq(pn,"book") ||
cst_streq(pn,"volume") ||
cst_streq(pn,"chap") ||
cst_streq(pn,"war") ||
cst_streq(pn,"apollo") ||
cst_streq(pn,"trek") ||
cst_streq(pn,"fortran"))
v = 1;
cst_free(pn);
return v;
}
cst_utterance *us_textanalysis(cst_utterance *u)
{
if (!feat_present(u->features, "tokentowords_func"))
utt_set_feat(u, "tokentowords_func", itemfunc_val(us_tokentowords));
return default_textanalysis(u);
}
static cst_val *us_tokentowords_one(cst_item *token, const char *name);
cst_val *us_tokentowords(cst_item *token)
{
return us_tokentowords_one(token, item_feat_string(token, "name"));
}
static cst_val *add_break(cst_val *l)
{
/* add feature (break 1) to last item in this list */
const cst_val *i;
cst_val *t;
cst_features *f;
for (i=l; val_cdr(i); i=val_cdr(i));
if (i) /* might be empty list */
{
f = new_features();
feat_set_string(f,"break","1");
t = cons_val(val_car(i),features_val(f));
set_car((cst_val *)i,t);
}
return l;
}
static cst_val *us_tokentowords_one(cst_item *token, const char *name)
{
/* Return list of words that expand token/name */
char *p, *aaa, *bbb, *ccc;
int i,j,k,l;
cst_val *r, *s;
const char *nsw = "";
cst_lexicon *lex;
cst_utterance *utt;
/* printf("token_name %s name %s\n",item_name(token),name); */
/* FIXME: For SAPI and friends, any tokens with explicit
pronunciations need to be passed through as-is. This should be
done in the interface code rather than here once the
tokentowords hook is accessible. AWB: no, they should set the
nsw feature and this function should deal with it (doesn't yet though)*/
if (item_feat_present(token,"phones"))
return cons_val(string_val(name),NULL);
if (item_feat_present(token,"nsw"))
nsw = item_feat_string(token,"nsw");
utt = item_utt(token);
lex = val_lexicon(feat_val(utt->features,"lexicon"));
if ((cst_streq("a",name) || cst_streq("A",name)) &&
((item_next(token) == 0) ||
(!cst_streq(name,item_name(token))) ||
(!cst_streq("",ffeature_string(token,"punc")))))
{ /* if A is a sub part of a token, then its ey not ah */
r = cons_val(string_val("_a"),0);
}
else if (cst_strlen(name) == 0)
r = NULL;
else if (cst_regex_match(dottedabbrevs,name))
{ /* X.X.X */
aaa = cst_strdup(name);
for (i=j=0; aaa[i]; i++)
if (aaa[i] != '.')
{
aaa[j] = aaa[i];
j++;
}
aaa[j] = '\0';
r = en_exp_letters(aaa);
cst_free(aaa);
}
else if (cst_regex_match(cst_rx_commaint,name))
{ /* 99,999,999 */
aaa = cst_strdup(name);
for (j=i=0; i < cst_strlen(name); i++)
if (name[i] != ',')
{
aaa[j] = name[i];
j++;
}
aaa[j] = '\0';
r = en_exp_real(aaa);
cst_free(aaa);
}
else if (cst_regex_match(sevenphonenumber,name))
{ /* 234-3434 telephone numbers */
p=strchr(name,'-');
aaa = cst_strdup(name);
aaa[cst_strlen(name)-cst_strlen(p)] = '\0';
bbb = cst_strdup(p+1);
r = val_append(add_break(en_exp_digits(aaa)),
en_exp_digits(bbb));
cst_free(aaa);
cst_free(bbb);
}
else if
((cst_regex_match(threedigits,name) &&
((!cst_regex_match(cst_rx_digits,ffeature_string(token,"p.name"))
&& cst_regex_match(threedigits,ffeature_string(token,"n.name"))
&& cst_regex_match(fourdigits,ffeature_string(token,"n.n.name"))) ||
(cst_regex_match(sevenphonenumber,ffeature_string(token,"n.name"))) ||
(!cst_regex_match(cst_rx_digits,ffeature_string(token,"p.p.name"))
&& cst_regex_match(threedigits,ffeature_string(token,"p.name"))
&& cst_regex_match(fourdigits,ffeature_string(token,"n.name"))))) ||
(cst_regex_match(fourdigits,name) &&
(!cst_regex_match(cst_rx_digits,ffeature_string(token,"n.name"))
&& cst_regex_match(threedigits,ffeature_string(token,"p.name"))
&& cst_regex_match(threedigits,ffeature_string(token,"p.p.name")))))
{
/* part of a telephone number */
if (cst_streq("",ffeature_string(token,"punc")))
item_set_string(token,"punc",",");
r = add_break(en_exp_digits(name));
}
else if (cst_regex_match(numbertime,name))
{
p=strchr(name,':');
aaa = cst_strdup(name);
aaa[cst_strlen(name)-cst_strlen(p)] = '\0';
bbb = cst_strdup(p+1);
r = en_exp_number(aaa);
if (!cst_streq("00",bbb))
r = val_append(r,en_exp_id(bbb));
/* r = add_break(r); */
cst_free(aaa);
cst_free(bbb);
}
else if (cst_regex_match(numbertimexm,name))
{
p=strchr(name,':');
if (!p) p=strchr(name,'.');
aaa = cst_strdup(name);
aaa[cst_strlen(name)-cst_strlen(p)] = '\0';
bbb = cst_strdup(p+1);
bbb[2] = '\0';
ccc = cst_strdup(p+3);
r = en_exp_number(aaa);
if (!cst_streq("00",bbb))
r = val_append(r,en_exp_id(bbb));
/* r = add_break(r); */
r = val_append(r,en_exp_letters(ccc));
cst_free(aaa);
cst_free(bbb);
cst_free(ccc);
}
else if (cst_regex_match(digits2dash,name))
{ /* 999-999-999 etc */
bbb = cst_strdup(name);
for (r=0,aaa=p=bbb; *p; p++)
{
if (*p == '-')
{
*p = '\0';
r = val_append(val_reverse(add_break(en_exp_digits(aaa))),r);
aaa = p+1;
}
}
r = val_append(val_reverse(add_break(en_exp_digits(aaa))),r);
r = val_reverse(r);
cst_free(bbb);
}
else if (cst_regex_match(cst_rx_digits,name))
{ /* string of digits (use cart to disambiguate) */
if (cst_streq("nide",nsw))
r = en_exp_id(name);
else {
const cst_val *tv;
const char *ts;
char *rname;
rname = cst_strdup(item_feat_string(token,"name"));
if (cst_streq(name,rname))
tv = cart_interpret(token,&us_nums_cart);
else
{ /* in a recursive call */
item_set_string(token,"name",name);
tv = cart_interpret(token,&us_nums_cart);
item_set_string(token,"name",rname);
}
cst_free(rname);
ts = val_string(tv);
if (cst_streq(ts,"ordinal"))
r = en_exp_ordinal(name);
else if (cst_streq(ts,"digits"))
r = en_exp_digits(name);
else if (cst_streq(ts,"year"))
r = en_exp_id(name);
else
r = en_exp_number(name);
}
}
else if (cst_regex_match(romannums,name))
{ /* Roman numerals */
if (cst_streq("",ffeature_string(token,"p.punc")))
{ /* no preceeding punc */
char n[10];
cst_sprintf(n,"%d",en_exp_roman(name));
if (rex_like(token))
r = cons_val(string_val("the"),
en_exp_ordinal(n));
else if (section_like(token))
r = en_exp_number(n);
else
r = en_exp_letters(name);
}
else
r = en_exp_letters(name);
}
else if (cst_regex_match(drst,name))
{ /* St Andrew's St, Dr King Dr */
const char *street;
const char *saint;
if ((name[0] == 's') || (name[0] == 'S'))
{
street = "street";
saint = "saint";
}
else
{
street = "drive";
saint = "doctor";
}
if ((item_next(token) == 0) ||
strchr(item_feat_string(token,"punc"),','))
r = cons_val(string_val(street),NULL);
else if (strchr(ffeature_string(token,"punc"),','))
r = cons_val(string_val(saint),NULL);
else
{
const char *pname = ffeature_string(token,"p.name");
const char *nname = ffeature_string(token,"n.name");
if ((pname[0] >= 'A') && (pname[0] <= 'Z') &&
(nname[0] >= 'a') && (nname[0] <= 'z'))
r = cons_val(string_val(street),NULL);
else if ((pname[0] >= '0') && (pname[0] <= '9') &&
(nname[0] >= 'a') && (nname[0] <= 'z'))
r = cons_val(string_val(street),NULL);
else if ((pname[0] >= 'a') && (pname[0] <= 'z') &&
(nname[0] >= 'A') && (nname[0] <= 'Z'))
r = cons_val(string_val(saint),NULL);
else if (cst_streq(ffeature_string(token,"n.whitespace")," "))
r = cons_val(string_val(saint),NULL);
else
r = cons_val(string_val(street),NULL);
}
if (cst_streq(item_feat_string(token,"punc"),"."))
item_set_string(token,"punc","");
}
else if (cst_streq(name,"Mr"))
{
item_set_string(token,"punc","");
r = cons_val(string_val("mister"),NULL);
}
else if (cst_streq(name,"Mrs"))
{
item_set_string(token,"punc","");
r = cons_val(string_val("missus"),NULL);
}
else if ((cst_streq(name,"read")) ||
(cst_streq(name,"lead")))
{ /* checking WSJ examples, this seems a quick and easy way to */
/* get manty of these correct */
const char *pname = ffeature_string(token,"p.name");
for (i=0; eedwords[i]; i++)
if (cst_streq(pname,eedwords[i]))
break;
if (eedwords[i])
{ /* reed or leed */
if (name[0] == 'r')
r = cons_val(string_val("reed"),NULL);
else
r = cons_val(string_val("leed"),NULL);
}
else /* red or led */
{
if (name[0] == 'r')
r = cons_val(string_val("red"),NULL);
else
r = cons_val(string_val("led"),NULL);
}
}
else if (cst_streq(name,"am") || cst_streq(name,"AM"))
{
if (!cst_streq(name,item_name(token)))
r = en_exp_letters(name);
else if (item_prev(token) &&
(cst_regex_match(numbertime,ffeature_string(token,"p.name")) ||
cst_regex_match(cst_rx_digits,ffeature_string(token,"p.name"))))
r = en_exp_letters(name);
else
r = cons_val(string_val(name),NULL);
}
else if ((cst_strlen(name) == 1) &&
(name[0] >= 'A') &&
(name[0] <= 'Z') &&
(cst_streq(" ",ffeature_string(token,"n.whitespace"))) &&
(ffeature_string(token,"n.name")[0] >= 'A') &&
(ffeature_string(token,"n.name")[0] <= 'Z'))
{
item_set_string(token,"punc","");
aaa = cst_downcase(name);
if (cst_streq(aaa,"a"))
r = cons_val(string_val("_a"),0);
else
r = cons_val(string_val(aaa),0);
cst_free(aaa);
}
else if (cst_regex_match(cst_rx_double,name))
{ /* real numbers */
r = en_exp_real(name);
}
else if (cst_regex_match(ordinal_number,name))
{ /* explicit ordinals */
aaa = cst_strdup(name);
aaa[cst_strlen(name)-2] = '\0';
r = en_exp_ordinal(aaa);
cst_free(aaa);
}
else if ((cst_regex_match(illion,name)) &&
(cst_regex_match(usmoney,ffeature_string(token,"p.name"))))
{
r = cons_val(string_val(name),
cons_val(string_val("dollars"),NULL));
}
else if (cst_regex_match(usmoney,name))
{
/* US money */
/* printf("money, money, money %s\n", name); */
p = strchr(name,'.');
if (cst_regex_match(illion,ffeature_string(token,"n.name")))
{ /* carl sagan's billions and billions */
r = en_exp_real(&name[1]);
}
else if (!p)
{
aaa = cst_strdup(&name[1]);
if (cst_streq("1",aaa))
r = cons_val(string_val("dollar"),NULL);
else
r = cons_val(string_val("dollars"),NULL);
r = val_append(us_tokentowords_one(token,aaa),r);
cst_free(aaa);
}
else if ((cst_strlen(p) == 1) || (cst_strlen(p) > 3))
{ /* simply read as mumble point mumble */
r = val_append(en_exp_real(&name[1]),
cons_val(string_val("dollars"),NULL));
}
else
{
aaa = cst_strdup(name);
aaa[cst_strlen(name)-cst_strlen(p)] = '\0';
for (i=j=0; aaa[i] != '\0'; i++)
{
if (aaa[i] != ',')
{
aaa[j] = aaa[i];
j++;
}
}
aaa[j] = '\0';
if (cst_streq("00",p+1))
r = 0;
else if (cst_streq("01",p+1))
r = val_append(en_exp_number(p+1),
cons_val(string_val("cent"),NULL));
else
r = val_append(en_exp_number(p+1),
cons_val(string_val("cents"),NULL));
if (cst_streq("1",aaa+1))
r = cons_val(string_val("dollar"),r);
else
r = cons_val(string_val("dollars"),r);
r = val_append(en_exp_number(aaa+1),r);
cst_free(aaa);
}
}
else if (name[cst_strlen(name)-1] == '%')
{
aaa = cst_strdup(name);
aaa[cst_strlen(aaa)-1] = '\0';
r = val_append(us_tokentowords_one(token,aaa),
cons_val(string_val("per"),
cons_val(string_val("cent"),NULL)));
cst_free(aaa);
}
else if (cst_regex_match(numess,name))
{ /* 60s and 7s and 9s */
aaa = cst_strdup(name);
aaa[cst_strlen(name)-1] = '\0';
r = val_append(en_exp_number(aaa),
cons_val(string_val("'s"),0));
cst_free(aaa);
}
else if ((p=(cst_strrchr(name,'\''))))
{
static const char *pc[] = { "'s", "'ll", "'ve", "'d", NULL };
bbb = cst_downcase(p);
if (cst_member_string(bbb, pc))
{
aaa = cst_strdup(name);
aaa[cst_strlen(name)-cst_strlen(p)] = '\0';
r = val_append(us_tokentowords_one(token,aaa),
cons_val(string_val(bbb),0));
cst_free(aaa);
}
else if (cst_streq(p,"'tve")) /* admittedly rare and weird */
{
aaa = cst_strdup(name);
aaa[cst_strlen(name)-cst_strlen(p)+2] = '\0';
r = val_append(us_tokentowords_one(token,aaa),
cons_val(string_val("'ve"),0));
cst_free(aaa);
}
else
{
aaa = cst_strdup(name);
strcpy(&aaa[cst_strlen(name)-cst_strlen(p)],p+1);
r = us_tokentowords_one(token,aaa);
cst_free(aaa);
}
cst_free(bbb);
}
else if ((cst_regex_match(digitsslashdigits,name)) &&
(cst_streq(name,item_name(token))))
{ /* might be fraction, or not */
p=strchr(name,'/');
aaa = cst_strdup(name);
aaa[cst_strlen(name)-cst_strlen(p)] = '\0';
bbb = cst_strdup(p+1);
if ((cst_streq("1",aaa)) && (cst_streq("2",bbb)))
r = cons_val(string_val("a"),
cons_val(string_val("half"),0));
else if (atoi(aaa) < (atoi(bbb)))
{
r = val_append(en_exp_number(aaa),
en_exp_ordinal(bbb));
if (atoi(aaa) > 1)
r = val_append(r,cons_val(string_val("'s"),0));
}
else
r = val_append(en_exp_number(aaa),
cons_val(string_val("slash"),
en_exp_number(bbb)));
if ((cst_regex_match(cst_rx_digits,ffeature_string(token,"p.name")))
&& (item_prev(token))) /* don't mistake "0" as a number */
r = cons_val(string_val("and"),r);
cst_free(aaa);
cst_free(bbb);
}
else if ((p=(strchr(name,'-'))))
{ /* aaa-bbb */
aaa = cst_strdup(name);
aaa[cst_strlen(name)-cst_strlen(p)] = '\0';
bbb = cst_strdup(p+1);
if (cst_regex_match(cst_rx_digits,aaa) &&
cst_regex_match(cst_rx_digits,bbb))
{
ccc = cst_strdup(name);
item_set_string(token,"name",bbb);
r = us_tokentowords_one(token,bbb);
item_set_string(token,"name",aaa);
r = val_append(us_tokentowords_one(token,aaa),
cons_val(string_val("to"),r));
item_set_string(token,"name",ccc);
cst_free(ccc);
}
else
r = val_append(us_tokentowords_one(token,aaa),
us_tokentowords_one(token,bbb));
cst_free(aaa);
cst_free(bbb);
}
else if (cst_regex_match(wandm,name))
{ /* weights and measures */
for (j=cst_strlen(name)-1; j > 0; j--)
if (cst_strchr("0123456789",name[j]))
break;
j += 1;
for (i=0; wandm_abbrevs[i][0]; i++)
if (cst_streq(name+j,wandm_abbrevs[i][0]))
break;
aaa = cst_strdup(name);
aaa[j] = '\0';
/* remove any commas */
for (k=0,l=0; aaa[l]; k++,l++)
{
if (aaa[l] == ',') l++;
aaa[k] = aaa[l];
}
aaa[k] = '\0';
if (!wandm_abbrevs[i][0]) /* didn't find an expansion */
r = val_append(en_exp_number(aaa),
us_tokentowords_one(token,name+j));
else
r = val_append(en_exp_number(aaa),
cons_val(string_val(wandm_abbrevs[i][1]),NULL));
cst_free(aaa);
}
else if ((cst_strlen(name) > 1) && (!cst_regex_match(cst_rx_alpha,name)))
{ /* its not just alphas */
for (i=0; name[i] != '\0'; i++)
if (text_splitable(name,i))
break;
aaa = cst_strdup(name);
aaa[i+1] = '\0';
bbb = cst_strdup(&name[i+1]);
item_set_string(token,"nsw","nide");
r = val_append(us_tokentowords_one(token,aaa),
us_tokentowords_one(token,bbb));
cst_free(aaa);
cst_free(bbb);
}
else if ((s = state_name(name,token)))
{
r = s;
}
else if ((cst_strlen(name) > 1) &&
(cst_regex_match(cst_rx_alpha,name)) &&
(!in_lex(lex,name,NULL)) &&
(!us_aswd(name)))
/* Still not quiet right, if there is a user_lex we need to check */
/* it too -- but user_lex isn't user setable yet */
/* Need common exception list */
/* unpronouncable list of alphas */
r = en_exp_letters(name);
/* buckets of other stuff missing */
else /* just a word */
{
aaa = cst_downcase(name);
r = cons_val(string_val(aaa),0);
cst_free(aaa);
}
return r;
}
static int text_splitable(const char *s,int i)
{
/* should token be split after this */
if (strchr("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",s[i]) &&
strchr("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",s[i+1]))
return FALSE;
else if (strchr("0123456789",s[i]) &&
strchr("0123456789",s[i+1]))
return FALSE;
else
return TRUE;
}
static const char * const states[99][5] =
{
{ "AL", "ambiguous", "alabama" , NULL, NULL },
{ "Al", "ambiguous", "alabama" , NULL, NULL },
{ "Ala", "", "alabama" , NULL, NULL },
{ "AK", "", "alaska" , NULL, NULL },
{ "Ak", "", "alaska" , NULL, NULL },
{ "AZ", "", "arizona" , NULL, NULL },
{ "Az", "", "arizona" , NULL, NULL },
{ "CA", "", "california" , NULL, NULL },
{ "Ca", "", "california" , NULL, NULL },
{ "Cal", "ambiguous", "california" , NULL, NULL },
{ "Calif", "", "california" , NULL, NULL },
{ "CO", "ambiguous", "colorado" , NULL, NULL },
{ "Co", "ambiguous", "colorado" , NULL, NULL },
{ "Colo", "", "colorado" , NULL, NULL },
{ "DC", "", "d" , "c", NULL },
{ "DE", "", "delaware" , NULL, NULL },
{ "De", "ambiguous", "delaware" , NULL, NULL },
{ "Del", "ambiguous", "delaware" , NULL, NULL },
{ "FL", "", "florida" , NULL, NULL },
{ "Fl", "ambiguous", "florida" , NULL, NULL },
{ "Fla", "", "florida" , NULL, NULL },
{ "GA", "", "georgia" , NULL, NULL },
{ "Ga", "", "georgia" , NULL, NULL },
{ "HI", "", "hawaii" , NULL, NULL },
{ "Hi", "ambiguous", "hawaii" , NULL, NULL },
{ "IA", "", "iowa" , NULL, NULL },
{ "Ia", "ambiguous", "iowa" , NULL, NULL },
{ "Ind", "ambiguous", "indiana" , NULL, NULL },
{ "ID", "ambiguous", "idaho" , NULL, NULL },
{ "IL", "ambiguous", "illinois" , NULL, NULL },
{ "Il", "ambiguous", "illinois" , NULL, NULL },
{ "ILL", "ambiguous", "illinois" , NULL, NULL },
{ "KS", "", "kansas" , NULL, NULL },
{ "Ks", "", "kansas" , NULL, NULL },
{ "Kans", "", "kansas" , NULL, NULL },
{ "KY", "ambiguous", "kentucky" , NULL, NULL },
{ "Ky", "ambiguous", "kentucky" , NULL, NULL },
{ "LA", "ambiguous", "louisiana" , NULL, NULL },
{ "La", "ambiguous", "louisiana" , NULL, NULL },
{ "Lou", "ambiguous", "louisiana" , NULL, NULL },
{ "Lous", "ambiguous", "louisiana" , NULL, NULL },
{ "MA", "ambiguous", "massachusetts" , NULL, NULL },
{ "Mass", "ambiguous", "massachusetts" , NULL, NULL },
{ "Ma", "ambiguous", "massachusetts" , NULL, NULL },
{ "MD", "ambiguous", "maryland" , NULL, NULL },
{ "Md", "ambiguous", "maryland" , NULL, NULL },
{ "ME", "ambiguous", "maine" , NULL, NULL },
{ "Me", "ambiguous", "maine" , NULL, NULL },
{ "MI", "", "michigan" , NULL, NULL },
{ "Mi", "ambiguous", "michigan" , NULL, NULL },
{ "Mich", "ambiguous", "michigan" , NULL, NULL },
{ "MN", "ambiguous", "minnestota" , NULL, NULL },
{ "Minn", "ambiguous", "minnestota" , NULL, NULL },
{ "MS", "ambiguous", "mississippi" , NULL, NULL },
{ "Miss", "ambiguous", "mississippi" , NULL, NULL },
{ "MT", "ambiguous", "montanna" , NULL, NULL },
{ "Mt", "ambiguous", "montanna" , NULL, NULL },
{ "MO", "ambiguous", "missouri" , NULL, NULL },
{ "Mo", "ambiguous", "missouri" , NULL, NULL },
{ "NC", "ambiguous", "north" , "carolina", NULL },
{ "ND", "ambiguous", "north" , "dakota", NULL },
{ "NE", "ambiguous", "nebraska" , NULL, NULL },
{ "Ne", "ambiguous", "nebraska" , NULL, NULL },
{ "Neb", "ambiguous", "nebraska" , NULL, NULL },
{ "NH", "ambiguous", "new" , "hampshire", NULL },
{ "NV", "", "nevada" , NULL, NULL },
{ "Nev", "", "nevada" , NULL, NULL },
{ "NY", "", "new" , "york", NULL },
{ "OH", "ambiguous", "ohio" , NULL, NULL },
{ "OK", "ambiguous", "oklahoma" , NULL, NULL },
{ "Okla", "", "oklahoma" , NULL, NULL },
{ "OR", "ambiguous", "oregon" , NULL, NULL },
{ "Or", "ambiguous", "oregon" , NULL, NULL },
{ "Ore", "ambiguous", "oregon" , NULL, NULL },
{ "PA", "ambiguous", "pennsylvania" , NULL, NULL },
{ "Pa", "ambiguous", "pennsylvania" , NULL, NULL },
{ "Penn", "ambiguous", "pennsylvania" , NULL, NULL },
{ "RI", "ambiguous", "rhode" , "island", NULL },
{ "SC", "ambiguous", "south" , "carlolina", NULL },
{ "SD", "ambiguous", "south" , "dakota", NULL },
{ "TN", "ambiguous", "tennesee" , NULL, NULL },
{ "Tn", "ambiguous", "tennesee" , NULL, NULL },
{ "Tenn", "ambiguous", "tennesee" , NULL, NULL },
{ "TX", "ambiguous", "texas" , NULL, NULL },
{ "Tx", "ambiguous", "texas" , NULL, NULL },
{ "Tex", "ambiguous", "texas" , NULL, NULL },
{ "UT", "ambiguous", "utah" , NULL, NULL },
{ "VA", "ambiguous", "virginia" , NULL, NULL },
{ "WA", "ambiguous", "washington" , NULL, NULL },
{ "Wa", "ambiguous", "washington" , NULL, NULL },
{ "Wash", "ambiguous", "washington" , NULL, NULL },
{ "WI", "ambiguous", "wisconsin" , NULL, NULL },
{ "Wi", "ambiguous", "wisconsin" , NULL, NULL },
{ "WV", "ambiguous", "west" , "virginia", NULL },
{ "WY", "ambiguous", "wyoming" , NULL, NULL },
{ "Wy", "ambiguous", "wyoming" , NULL, NULL },
{ "Wyo", "", "wyoming" , NULL, NULL },
{ "PR", "ambiguous", "puerto" , "rico", NULL },
{ NULL, NULL, "puerto" , "rico", NULL }
};
static cst_val *state_name(const char *name,cst_item *t)
{
int s,j;
int do_it = 0;
cst_val *r = 0;
for (s=0; states[s][0]; s++)
{
if (cst_streq(states[s][0],name))
{
if (cst_streq(states[s][1],"ambiguous"))
{
const char *pname = ffeature_string(t,"p.name");
const char *nname = ffeature_string(t,"n.name");
/* previous name is capitalized */
if (((strchr("ABCDEFGHIJKLMNOPQRSTUVWXYZ",pname[0])) &&
(cst_strlen(pname) > 2) &&
(cst_regex_match(cst_rx_alpha,pname))) &&
((strchr("abcdefghijklmnopqrstuvwxyz",nname[0])) ||
(item_next(t) == 0) ||
(cst_streq(".",item_feat_string(t,"punc"))) ||
(((cst_strlen(nname) == 5 || (cst_strlen(nname) == 10)) &&
cst_regex_match(cst_rx_digits,nname)))))
do_it = 1;
else
do_it = 0;
}
else
do_it = 1;
if (do_it)
{
for (j=2; states[s][j]; j++)
r = cons_val(string_val(states[s][j]),r);
return val_reverse(r);
}
}
}
return r;
}
@@ -0,0 +1,64 @@
/*************************************************************************/
/* */
/* 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 */
/*************************************************************************/
/* */
/* US Text analysis */
/* */
/*************************************************************************/
#ifndef _US_TEXT_H__
#define _US_TEXT_H__
#include "cst_val.h"
#include "cst_hrg.h"
#include "cst_cart.h"
cst_val *en_exp_number(const char *numstring);
cst_val *en_exp_digits(const char *numstring);
cst_val *en_exp_id(const char *numstring);
cst_val *en_exp_ordinal(const char *numstring);
cst_val *en_exp_letters(const char *lets);
cst_val *en_exp_real(const char *numstring);
int en_exp_roman(const char *roman);
extern const cst_cart us_nums_cart;
void us_text_init();
cst_utterance *us_textanalysis(cst_utterance *u);
cst_val *us_tokentowords(cst_item *token);
int us_aswd(const char *w);
#endif
@@ -0,0 +1,137 @@
/*************************************************************************/
/* */
/* 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 2001 */
/*************************************************************************/
/* Generic models for US English */
/*************************************************************************/
/* ----------------------------------------------------------------- */
/* 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. */
/* ----------------------------------------------------------------- */
#include "flite.h"
#include "usenglish.h"
#ifndef FLITE_PLUS_HTS_ENGINE
#include "us_f0.h"
#endif /* !FLITE_PLUS_HTS_ENGINE */
#include "us_text.h"
#include "us_ffeatures.h"
static const char * const us_english_punctuation = "\"'`.,:;!?(){}[]";
static const char * const us_english_prepunctuation = "\"'`({[";
static const char * const us_english_singlecharsymbols = "";
static const char * const us_english_whitespace = " \t\n\r";
void usenglish_init(cst_voice *v)
{
us_text_init();
/* utterance break function */
feat_set(v->features,"utt_break",breakfunc_val(&default_utt_break));
/* Phoneset */
feat_set(v->features,"phoneset",phoneset_val(&us_phoneset));
feat_set_string(v->features,"silence",us_phoneset.silence);
/* Text analyser */
feat_set_string(v->features,"text_whitespace",us_english_whitespace);
feat_set_string(v->features,"text_postpunctuation",us_english_punctuation);
feat_set_string(v->features,"text_prepunctuation",
us_english_prepunctuation);
feat_set_string(v->features,"text_singlecharsymbols",
us_english_singlecharsymbols);
feat_set(v->features,"tokentowords_func",itemfunc_val(&us_tokentowords));
/* very simple POS tagger */
feat_set(v->features,"pos_tagger_cart",cart_val(&us_pos_cart));
/* Phrasing */
feat_set(v->features,"phrasing_cart",cart_val(&us_phrasing_cart));
/* Intonation */
feat_set(v->features,"int_cart_accents",cart_val(&us_int_accent_cart));
feat_set(v->features,"int_cart_tones",cart_val(&us_int_tone_cart));
#ifndef FLITE_PLUS_HTS_ENGINE
/* Duration */
feat_set(v->features,"dur_cart",cart_val(&us_durz_cart));
feat_set(v->features,"dur_stats",dur_stats_val((dur_stats *)us_dur_stats));
/* f0 model */
feat_set(v->features,"f0_model_func",uttfunc_val(&us_f0_model));
#endif /* !FLITE_PLUS_HTS_ENGINE */
us_ff_register(v->ffunctions);
}
@@ -0,0 +1,120 @@
/*************************************************************************/
/* */
/* 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: December 2000 */
/*************************************************************************/
/* Generic models for US English */
/*************************************************************************/
/* ----------------------------------------------------------------- */
/* 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 _US_ENGLISH_H_
#define _US_ENGLISH_H_
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#include "cst_utterance.h"
#include "cst_cart.h"
#include "cst_val.h"
#include "cst_phoneset.h"
#include "cst_lexicon.h"
#include "cst_synth.h"
/* Voices call this to use usenglish. */
void usenglish_init(cst_voice *v);
/* Default functions and values that you might need. */
#ifndef FLITE_PLUS_HTS_ENGINE
cst_utterance *us_f0_model(cst_utterance *u);
#endif /* !FLITE_PLUS_HTS_ENGINE */
extern const cst_phoneset us_phoneset;
extern const cst_cart us_phrasing_cart;
extern const cst_cart us_int_accent_cart;
extern const cst_cart us_int_tone_cart;
#ifndef FLITE_PLUS_HTS_ENGINE
extern const cst_cart us_durz_cart;
#endif /* !FLITE_PLUS_HTS_ENGINE */
extern const cst_cart us_pos_cart;
#ifndef FLITE_PLUS_HTS_ENGINE
extern const dur_stat * const us_dur_stats[];
#endif /* !FLITE_PLUS_HTS_ENGINE */
#ifdef __cplusplus
} /* extern "C" */
#endif /* __cplusplus */
#endif
+198
View File
@@ -0,0 +1,198 @@
/*************************************************************************/
/* */
/* Language Technologies Institute */
/* Carnegie Mellon University */
/* Copyright (c) 1999-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: April 2000 */
/*************************************************************************/
/* */
/* Item features and paths */
/* */
/*************************************************************************/
#include "cst_alloc.h"
#include "cst_item.h"
#include "cst_relation.h"
#include "cst_utterance.h"
#include "cst_tokenstream.h"
CST_VAL_REGISTER_FUNCPTR(ffunc,cst_ffunction)
DEF_STATIC_CONST_VAL_STRING(ffeature_default_val,"0");
static const void *internal_ff(const cst_item *item,
const char *featpath,int type);
const char *ffeature_string(const cst_item *item,const char *featpath)
{
return val_string(ffeature(item,featpath));
}
int ffeature_int(const cst_item *item,const char *featpath)
{
return val_int(ffeature(item,featpath));
}
float ffeature_float(const cst_item *item,const char *featpath)
{
return val_float(ffeature(item,featpath));
}
cst_item* path_to_item(const cst_item *item,const char *featpath)
{
return (cst_item *)internal_ff(item,featpath,1);
}
const cst_val *ffeature(const cst_item *item,const char *featpath)
{
return (cst_val *)internal_ff(item,featpath,0);
}
static const void *internal_ff(const cst_item *item,
const char *featpath,int type)
{
const char *tk, *relation;
cst_utterance *utt;
const cst_item *pitem;
void *void_v;
const cst_val *ff;
cst_ffunction ffunc;
char tokenstring[200]; /* we don't seem to have featpaths longer than 72 */
char *tokens[100];
int i,j;
/* This used to use cst_tokenstream but that was too slow */
for (i=0; i<199 && featpath[i]; i++)
tokenstring[i] = featpath[i];
tokenstring[i]='\0';
tokens[0] = tokenstring;
for (i=0,j=1; tokenstring[i]; i++)
{
if (strchr(":.",tokenstring[i]))
{
tokenstring[i] = '\0';
tokens[j] = &tokenstring[i+1];
j++;
}
}
tokens[j] = NULL;
j=0;
for (tk = tokens[j], pitem=item;
pitem &&
(((type == 0) && tokens[j+1]) ||
((type == 1) && tk));
j++, tk = tokens[j])
{
if (cst_streq(tk,"n"))
pitem = item_next(pitem);
else if (cst_streq(tk,"p"))
pitem = item_prev(pitem);
else if (cst_streq(tk,"pp"))
{
if (item_prev(pitem))
pitem = item_prev(item_prev(pitem));
else
pitem = NULL;
}
else if (cst_streq(tk,"nn"))
{
if (item_next(pitem))
pitem = item_next(item_next(pitem));
else
pitem = NULL;
}
else if (cst_streq(tk,"parent"))
pitem = item_parent(pitem);
else if ((cst_streq(tk,"daughter")) ||
(cst_streq(tk,"daughter1")))
pitem = item_daughter(pitem);
else if (cst_streq(tk,"daughtern"))
pitem = item_last_daughter(pitem);
else if (cst_streq(tk,"R"))
{
/* A relation move */
j++;
relation = tokens[j];
pitem = item_as(pitem,relation);
}
else
{
cst_errmsg("ffeature: unknown directive \"%s\" ignored\n",tk);
return NULL;
}
}
if (type == 0)
{
if (pitem && (utt = item_utt(pitem)))
ff = feat_val(utt->ffunctions,tk);
else
ff = NULL;
void_v = NULL;
if (!ff)
void_v = (void *)item_feat(pitem,tk);
else if (pitem)
{
ffunc = val_ffunc(ff);
void_v = (void *)(*ffunc)(pitem);
}
if (void_v == NULL)
{
#if 0
if (pitem)
printf("awb_debug didn't find %s in %s\n",tk,
get_param_string(pitem->contents->features,"name","noname"));
else
{
if (cst_streq("gpos",tk))
printf("awb_debug2\n");
printf("awb_debug didn't find %s %s\n",tk,featpath);
}
#endif
void_v = (void *)&ffeature_default_val;
}
}
else
void_v = (void *)pitem;
return void_v;
}
void ff_register(cst_features *ffunctions, const char *name, cst_ffunction f)
{
/* Register features functions */
if (feat_present(ffunctions, name))
cst_errmsg("warning: ffunction %s redefined\n", name);
feat_set(ffunctions, name, ffunc_val(f));
}
void ff_unregister(cst_features *ffunctions, const char *name)
{
feat_remove(ffunctions, name);
}
+383
View File
@@ -0,0 +1,383 @@
/*************************************************************************/
/* */
/* 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 */
/*************************************************************************/
/* */
/* Items (and Item Contents) */
/* */
/*************************************************************************/
#include "cst_alloc.h"
#include "cst_item.h"
#include "cst_relation.h"
#include "cst_utterance.h"
/* Define functions for using items, rels and utts as vals */
CST_VAL_REGISTER_TYPE_NODEL(relation,cst_relation)
CST_VAL_REGISTER_TYPE_NODEL(item,cst_item)
CST_VAL_REGISTER_TYPE(utterance,cst_utterance)
CST_VAL_REGISTER_FUNCPTR(itemfunc,cst_itemfunc)
cst_item *new_item_relation(cst_relation *r,cst_item *i)
{
cst_item *ni;
ni = cst_utt_alloc(r->utterance, cst_item, 1);
ni->contents = 0;
ni->n = ni->p = ni->u = ni->d = 0;
ni->relation = r;
item_contents_set(ni,i);
return ni;
}
void item_contents_set(cst_item *current, cst_item *i)
{
cst_item_contents *c = 0;
cst_item *nn_item;
if (i == 0)
c = new_item_contents(current);
else
c = i->contents;
if (c != current->contents)
{
item_unref_contents(current);
current->contents = c;
/* If this contents is already in this relation */
/* empty the other reference */
if (feat_present(current->contents->relations,current->relation->name))
{ /* oops this is already in this relation */
nn_item = val_item(feat_val(current->contents->relations,
current->relation->name));
feat_set(nn_item->contents->relations,
current->relation->name,
item_val(nn_item));
}
/* Add back reference */
feat_set(current->contents->relations,
current->relation->name,
item_val(current));
}
}
void delete_item(cst_item *item)
{
cst_item *ds, *nds;
if (item->n != NULL)
{
item->n->p = item->p;
item->n->u = item->u; /* in trees if this is first daughter */
}
if (item->p != NULL) item->p->n = item->n;
if (item->u != NULL) item->u->d = item->n; /* when first daughter */
if (item->relation)
{
if (item->relation->head == item)
item->relation->head = item->n;
if (item->relation->tail == item)
item->relation->tail = item->p;
}
/* Delete all the daughters of item */
for (ds = item->d; ds; ds=nds)
{
nds = ds->n;
delete_item(ds);
}
item_unref_contents(item);
cst_utt_free(item->relation->utterance, item);
}
void item_unref_contents(cst_item *item)
{
/* unreference this item from contents, and delete contents */
/* if no one else is referencing it */
if (item && item->contents)
{
feat_remove(item->contents->relations,item->relation->name);
if (feat_length(item->contents->relations) == 0)
{
delete_features(item->contents->relations);
delete_features(item->contents->features);
cst_utt_free(item->relation->utterance,item->contents);
}
item->contents = NULL;
}
}
cst_item_contents *new_item_contents(cst_item *i)
{
cst_item_contents *ic;
ic = cst_utt_alloc(i->relation->utterance,cst_item_contents,1);
ic->features = new_features_local(i->relation->utterance->ctx);
ic->relations = new_features_local(i->relation->utterance->ctx);
return ic;
}
cst_item *item_as(const cst_item *i,const char *rname)
{
/* return i as relation rname or null */
const cst_val *v;
if (i == NULL)
return NULL;
else
{
v = feat_val(i->contents->relations,rname);
if (v != NULL)
return val_item(v);
else
return NULL;
}
}
/********************************************************************/
/* List relation related functions */
/********************************************************************/
cst_item *item_next(const cst_item *i)
{
if (i == NULL)
return NULL;
else
return i->n;
}
cst_item *item_prev(const cst_item *i)
{
if (i == NULL)
return NULL;
else
return i->p;
}
cst_item *item_append(cst_item *current, cst_item *ni)
{
cst_item *rni = 0;
if (ni && (ni->relation == current->relation))
{
/* got to delete it first as an item can't be in a relation twice */
}
else
rni = new_item_relation(current->relation,ni);
rni->n = current->n;
if (current->n != NULL)
current->n->p = rni;
rni->p = current;
current->n = rni;
if (current->relation->tail == current)
current->relation->tail = rni;
return rni;
}
cst_item *item_prepend(cst_item *current, cst_item *ni)
{
cst_item *rni = 0;
if (ni && (ni->relation == current->relation))
{
/* got to delete it first as an item can't be in a relation twice */
}
else
rni = new_item_relation(current->relation,ni);
rni->p = current->p;
if (current->p != NULL)
current->p->n = rni;
rni->n = current;
current->p = rni;
if (current->u) /* in a tree */
{
current->u->d = rni;
rni->u = current->u;
current->u = NULL;
}
if (current->relation->head == current)
current->relation->head = rni;
return rni;
}
/********************************************************************/
/* Tree relation related functions */
/********************************************************************/
cst_item *item_parent(const cst_item *i)
{
const cst_item *n;
for (n=i; item_prev(n); n=item_prev(n));
if (n == NULL)
return NULL;
else
return n->u;
}
cst_item *item_daughter(const cst_item *i)
{
if (i == NULL)
return NULL;
else
return i->d;
}
cst_item *item_nth_daughter(const cst_item *i,int n)
{
int d;
cst_item *p;
for (d=0,p=item_daughter(i); p && (d < n); p=item_next(p),d++);
return p;
}
cst_item *item_last_daughter(const cst_item *i)
{
cst_item *p;
for (p=item_daughter(i); item_next(p); p=item_next(p));
return p;
}
cst_item *item_add_daughter(cst_item *i,cst_item *nd)
{
cst_item *p,*rnd;
p = item_last_daughter(i);
if (p)
rnd=item_append(p,nd);
else
{ /* first new daughter */
if (nd && (nd->relation == i->relation))
{
/* got to delete it first as nd can't be in a relation twice */
cst_errmsg("item_add_daughter: already in relation\n");
return 0;
}
else
rnd = new_item_relation(i->relation,nd);
rnd->u = i;
i->d = rnd;
}
return rnd;
}
/********************************************************************/
/* Feature functions */
/********************************************************************/
int item_feat_present(const cst_item *i,const char *name)
{
return feat_present(item_feats(i),name);
}
int item_feat_remove(const cst_item *i,const char *name)
{
return feat_remove(item_feats(i),name);
}
cst_features *item_feats(const cst_item *i)
{
return (i ? i->contents->features : NULL);
}
const cst_val *item_feat(const cst_item *i,const char *name)
{
return feat_val(item_feats(i),name);
}
int item_feat_int(const cst_item *i,const char *name)
{
return feat_int(item_feats(i),name);
}
float item_feat_float(const cst_item *i,const char *name)
{
return feat_float(item_feats(i),name);
}
const char *item_feat_string(const cst_item *i,const char *name)
{
return feat_string(item_feats(i),name);
}
void item_set(const cst_item *i,const char *name,const cst_val *val)
{
feat_set(item_feats(i),name,val);
}
void item_set_int(const cst_item *i,const char *name,int val)
{
feat_set_int(item_feats(i),name,val);
}
void item_set_float(const cst_item *i,const char *name,float val)
{
feat_set_float(item_feats(i),name,val);
}
void item_set_string(const cst_item *i,const char *name,const char *val)
{
feat_set_string(item_feats(i),name,val);
}
cst_utterance *item_utt(const cst_item *i)
{
if (i && i->relation)
return i->relation->utterance;
else
return NULL;
}
int item_equal(const cst_item *a, const cst_item *b)
{
if ((a == b) ||
(a && b && (a->contents == b->contents)))
return TRUE;
else
return FALSE;
}
+117
View File
@@ -0,0 +1,117 @@
/*************************************************************************/
/* */
/* 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 */
/*************************************************************************/
/* */
/* Relations */
/* */
/*************************************************************************/
#include "cst_item.h"
#include "cst_relation.h"
#include "cst_utterance.h"
static const char * const cst_relation_noname = "NoName";
cst_relation *new_relation(const char *name, cst_utterance *u)
{
cst_relation *r = cst_utt_alloc(u,cst_relation,1);
r->name = cst_strdup(name);
r->features = new_features_local(u->ctx);
r->head = NULL;
r->utterance = u;
return r;
}
void delete_relation(cst_relation *r)
{
cst_item *p, *np;
if (r != NULL)
{
/* This needs to traverse the *all* items */
for(p=r->head; p; p=np)
{
np = item_next(p);
delete_item(p); /* this *does* go down daughters too */
}
delete_features(r->features);
cst_free(r->name);
cst_utt_free(r->utterance,r);
}
}
cst_item *relation_head(cst_relation *r)
{
return ( r == NULL ? NULL : r->head);
}
cst_item *relation_tail(cst_relation *r)
{
return (r == NULL ? NULL : r->tail);
}
const char *relation_name(cst_relation *r)
{
return (r == NULL ? cst_relation_noname : r->name);
}
cst_item *relation_append(cst_relation *r, cst_item *i)
{
cst_item *ni = new_item_relation(r,i);
if (r->head == NULL)
r->head = ni;
ni->p = r->tail;
if (r->tail)
r->tail->n = ni;
r->tail = ni;
return ni;
}
cst_item *relation_prepend(cst_relation *r, cst_item *i)
{
cst_item *ni = new_item_relation(r,i);
if (r->tail == NULL)
r->tail = ni;
ni->n = r->head;
if (r->head)
r->head->p = ni;
r->head = ni;
return ni;
}
+111
View File
@@ -0,0 +1,111 @@
/*************************************************************************/
/* */
/* 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 */
/* */
/*************************************************************************/
#include "cst_alloc.h"
#include "cst_utterance.h"
/* utterance functions are the modules that do the meat in synthesis */
CST_VAL_REGISTER_FUNCPTR(uttfunc,cst_uttfunc)
cst_utterance *new_utterance()
{
cst_utterance *u;
u = cst_alloc(struct cst_utterance_struct,1);
u->ctx = new_alloc_context(128*1024);
u->features = new_features_local(u->ctx);
u->ffunctions = new_features_local(u->ctx);
u->relations = new_features_local(u->ctx);
return u;
}
void delete_utterance(cst_utterance *u)
{
cst_featvalpair *fp;
if (u)
{
delete_features(u->features);
delete_features(u->ffunctions);
/* Relation vals don't delete their contents */
for (fp=u->relations->head; fp; fp=fp->next)
delete_relation(val_relation(fp->val));
delete_features(u->relations);
delete_alloc_context(u->ctx);
cst_free(u);
}
}
cst_relation *utt_relation_create(cst_utterance *u,const char *name)
{
cst_relation *r;
utt_relation_delete(u,name); /* remove if already there */
r = new_relation(name,u);
feat_set(u->relations,name,relation_val(r));
return r;
}
int utt_relation_delete(cst_utterance *u,const char *name)
{
/* Relation vals don't delete their contents */
if (feat_present(u->relations, name))
delete_relation(val_relation(feat_val(u->relations,name)));
return feat_remove(u->relations,name);
}
int utt_relation_present(cst_utterance *u,const char *name)
{
return feat_present(u->relations,name);
}
cst_relation *utt_relation(cst_utterance *u,const char *name)
{
const cst_val *v = feat_val(u->relations,name);
if (v != NULL)
return val_relation(v);
else
{
cst_errmsg("Relation: %s not present in utterance\n",
name);
cst_error();
}
return NULL;
}
@@ -0,0 +1,529 @@
/*************************************************************************/
/* */
/* 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 */
/* */
/*************************************************************************/
/* ----------------------------------------------------------------- */
/* 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. */
/* ----------------------------------------------------------------- */
#include "cst_features.h"
#include "cst_lexicon.h"
#include "cst_tokenstream.h"
CST_VAL_REGISTER_TYPE_NODEL(lexicon,cst_lexicon)
#define WP_SIZE 64
static int no_syl_boundaries(const cst_item *i, const cst_val *p);
static cst_val *lex_lookup_addenda(const char *wp,const cst_lexicon *l,
int *found);
static int lex_match_entry(const char *a, const char *b);
static int lex_lookup_bsearch(const cst_lexicon *l,const char *word);
static int find_full_match(const cst_lexicon *l,
int i,const char *word);
#ifndef FLITE_PLUS_HTS_ENGINE
cst_lexicon *new_lexicon()
{
cst_lexicon *l = cst_alloc(cst_lexicon,1);
l->syl_boundary = no_syl_boundaries;
return l;
}
void delete_lexicon(cst_lexicon *lex)
{ /* But I doubt if this will ever be called, lexicons are mapped */
/* This probably isn't complete */
if (lex)
{
cst_free(lex->data);
cst_free(lex);
}
}
cst_val *cst_lex_load_addenda(const cst_lexicon *lex, const char *lexfile)
{ /* Load an addend from given file, check its phones wrt lex */
cst_tokenstream *lf;
const cst_string *line;
cst_val *e = NULL;
cst_val *na = NULL;
int i;
lf = ts_open(lexfile,"\n","","","");
if (lf == NULL)
{
cst_errmsg("lex_add_addenda: cannot open lexicon file\n");
return NULL;;
}
while (!ts_eof(lf))
{
line = ts_get(lf);
if (line[0] == '#')
continue; /* a comment */
for (i=0; line[i]; i++)
{
if (line[i] != ' ')
break;
}
if (line[i])
{
e = cst_lex_make_entry(lex,line);
if (e)
na = cons_val(e,na);
}
else
continue; /* a blank line */
}
ts_close(lf);
return val_reverse(na);
}
cst_val *cst_lex_make_entry(const cst_lexicon *lex, const cst_string *entry)
{ /* if replace then replace entry in addenda of lex with entry */
/* else append entry to addenda of lex */
cst_tokenstream *e;
cst_val *phones = NULL;
cst_val *ventry;
const cst_string *w, *p;
cst_string *word;
cst_string *pos;
int i;
e = ts_open_string(entry,
cst_ts_default_whitespacesymbols,
"","","");
w = ts_get(e);
if (w[0] == '"') /* it was a quoted entry */
{ /* so reparse it */
ts_close(e);
e = ts_open_string(entry,
cst_ts_default_whitespacesymbols,
"","","");
w = ts_get_quoted_token(e,'"','\\');
}
word = cst_strdup(w);
p = ts_get(e);
if (!cst_streq(":",p)) /* there is a real pos */
{
pos = cst_strdup(p);
p = ts_get(e);
if (!cst_streq(":",p)) /* there is a real pos */
{
cst_fprintf(stdout,"add_addenda: lex %s: expected \":\" in %s\n",
lex->name,
word);
cst_free(word); cst_free(pos); ts_close(e);
return NULL;
}
}
else
pos = cst_strdup("nil");
while (!ts_eof(e))
{
p = ts_get(e);
/* Check its a legal phone */
for (i=0; lex->phone_table[i]; i++)
if (cst_streq(p,lex->phone_table[i]))
break;
if (cst_streq("#",p)) /* comment to end of line */
break;
else if (lex->phone_table[i])
/* Only add it if its a valid phone */
phones = cons_val(string_val(p),phones);
else
{
cst_fprintf(stdout,"add_addenda: lex: %s word %s phone %s not in lexicon phoneset\n",
lex->name,
word,
p);
}
}
ventry = cons_val(string_val(word),cons_val(string_val(pos),
val_reverse(phones)));
cst_free(word); cst_free(pos); ts_close(e);
#if 0
printf("entry: ");
val_print(stdout,ventry);
printf("\n");
#endif
return ventry;
}
#if 0
void lexicon_register(cst_lexicon *lex)
{
/* Add given lexicon to list of known lexicons */
cst_lexicon **old_lexs;
int i;
old_lexs = flite_lexicons;
flite_num_lexicons++;
flite_lexicons = cst_alloc(cst_lexicon *,flite_num_lexicons);
for (i=0; i<flite_num_lexicons-1; i++)
flite_lexicons[i] = old_lexs[i];
flite_lexicons[i] = lex;
cst_free(old_lexs);
}
cst_lexicon *lexicon_select(const char *name)
{
int i;
for (i=0; i < flite_num_lexicons; i++)
if (cst_streq(name,flite_lexicons[i]->name))
return flite_lexicons[i];
return NULL;
}
#endif
static int no_syl_boundaries(const cst_item *i, const cst_val *p)
{
/* This is a default function that will normally be replaced */
/* for each lexicon */
(void)i;
(void)p;
return FALSE;
}
#endif /* !FLITE_PLUS_HTS_ENGINE */
int in_lex(const cst_lexicon *l, const char *word, const char *pos)
{
/* return TRUE is its in the lexicon */
int r = FALSE, i;
char *wp;
wp = cst_alloc(char,cst_strlen(word)+2);
cst_sprintf(wp,"%c%s",(pos ? pos[0] : '0'),word);
for (i=0; l->addenda && l->addenda[i]; i++)
{
if (((wp[0] == '0') || (wp[0] == l->addenda[i][0][0])) &&
(cst_streq(wp+1,l->addenda[i][0]+1)))
{
r = TRUE;
break;
}
}
if (!r && (lex_lookup_bsearch(l,wp) >= 0))
r = TRUE;
cst_free(wp);
return r;
}
cst_val *lex_lookup(const cst_lexicon *l, const char *word, const char *pos)
{
int index;
int p;
const char *q;
char *wp;
cst_val *phones = 0;
int found = FALSE;
wp = cst_alloc(char,cst_strlen(word)+2);
cst_sprintf(wp,"%c%s",(pos ? pos[0] : '0'),word);
if (l->addenda)
phones = lex_lookup_addenda(wp,l,&found);
if (!found)
{
index = lex_lookup_bsearch(l,wp);
if (index >= 0)
{
if (l->phone_hufftable)
{
for (p=index-2; l->data[p]; p--)
for (q=l->phone_hufftable[l->data[p]]; *q; q++)
phones = cons_val(string_val(l->phone_table[(unsigned char)*q]),
phones);
}
else /* no compression -- should we still support this ? */
{
for (p=index-2; l->data[p]; p--)
phones = cons_val(string_val(l->phone_table[l->data[p]]),
phones);
}
phones = val_reverse(phones);
}
else if (l->lts_function)
{
phones = (l->lts_function)(l,word,"");
}
else if (l->lts_rule_set)
{
phones = lts_apply(word,
"", /* more features if we had them */
l->lts_rule_set);
}
}
cst_free(wp);
return phones;
}
static cst_val *lex_lookup_addenda(const char *wp,const cst_lexicon *l,
int *found)
{
/* For those other words */
int i,j;
cst_val *phones;
phones = NULL;
for (i=0; l->addenda[i]; i++)
{
if (((wp[0] == '0') || (wp[0] == l->addenda[i][0][0])) &&
(cst_streq(wp+1,l->addenda[i][0]+1)))
{
for (j=1; l->addenda[i][j]; j++)
phones = cons_val(string_val(l->addenda[i][j]),phones);
*found = TRUE;
return val_reverse(phones);
}
}
return NULL;
}
static int lex_uncompress_word(char *ucword,int max_size,
int p,const cst_lexicon *l)
{
int i,j=0,length;
unsigned char *cword;
if (l->entry_hufftable == 0)
/* can have "compressed" lexicons without compression */
cst_sprintf(ucword,"%s",&l->data[p]);
else
{
cword = &l->data[p];
for (i=0,j=0; cword[i]; i++)
{
length = cst_strlen(l->entry_hufftable[cword[i]]);
if (j+length+1<max_size)
{
memmove(ucword+j,l->entry_hufftable[cword[i]],length);
j += length;
}
else
break;
}
ucword[j] = '\0';
}
return j;
}
static int lex_data_next_entry(const cst_lexicon *l,int p,int end)
{
for (p++; p < end; p++)
if (l->data[p-1] == 255)
return p;
return end;
}
static int lex_data_prev_entry(const cst_lexicon *l,int p,int start)
{
for (p--; p > start; p--)
if (l->data[p-1] == 255)
return p;
return start;
}
static int lex_data_closest_entry(const cst_lexicon *l,int p,int start,int end)
{
int d;
d=0;
while ((p-d > start) &&
(p+d < end))
{
if (l->data[(p+d)-1] == 255)
return p+d;
else if (l->data[(p-d)-1] == 255)
return p-d;
d++;
}
return p-d;
}
static int lex_lookup_bsearch(const cst_lexicon *l, const char *word)
{
int start,mid,end,c;
/* needs to be longer than longest word in lexicon */
char word_pos[WP_SIZE];
start = 0;
end = l->num_bytes;
while (start < end) {
mid = (start + end)/2;
/* find previous entry start */
mid = lex_data_closest_entry(l,mid,start,end);
lex_uncompress_word(word_pos,WP_SIZE,mid,l);
c = lex_match_entry(word_pos,word);
if (c == 0)
return find_full_match(l,mid,word);
else if (c > 0)
end = mid;
else
start = lex_data_next_entry(l,mid + 1,end);
#if 0
if (l->data[start-1] == 255)
{
lex_uncompress_word(word_pos,WP_SIZE,start,l);
printf("start %s %d ",word_pos,start);
}
else
printf("start NULL %d ",start);
if (l->data[mid-1] == 255)
{
lex_uncompress_word(word_pos,WP_SIZE,mid,l);
printf("mid %s %d ",word_pos,mid);
}
else
printf("mid NULL %d ",mid);
if (l->data[end-1] == 255)
{
lex_uncompress_word(word_pos,WP_SIZE,end,l);
printf("end %s %d ",word_pos,end);
}
else
printf("end NULL %d ",end);
printf("\n");
#endif
}
return -1;
}
static int find_full_match(const cst_lexicon *l,
int i,const char *word)
{
/* found word, now look for actual match including pos */
int w, match=i;
/* needs to be longer than longest word in lexicon */
char word_pos[WP_SIZE];
for (w=i; w > 0; )
{
lex_uncompress_word(word_pos,WP_SIZE,w,l);
if (!cst_streq(word+1,word_pos+1))
break;
else if (cst_streq(word,word_pos))
return w;
match = w; /* if we can't find an exact match we'll take this one */
/* go back to last entry */
w = lex_data_prev_entry(l,w,0);
}
for (w=i; w < l->num_bytes;)
{
lex_uncompress_word(word_pos,WP_SIZE,w,l);
if (!cst_streq(word+1,word_pos+1))
break;
else if (cst_streq(word,word_pos))
return w;
/* go to next entry */
w = lex_data_next_entry(l,w,l->num_bytes);
}
return match;
}
static int lex_match_entry(const char *a, const char *b)
{
int c;
c = strcmp(a+1,b+1);
return c;
}
+278
View File
@@ -0,0 +1,278 @@
/*************************************************************************/
/* */
/* 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 rule support */
/* */
/*************************************************************************/
/* ----------------------------------------------------------------- */
/* 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. */
/* ----------------------------------------------------------------- */
#include "cst_features.h"
#include "cst_lts.h"
#include "cst_endian.h"
static cst_lts_phone apply_model(cst_lts_letter *vals,
cst_lts_addr start,
const cst_lts_model *model);
#ifndef FLITE_PLUS_HTS_ENGINE
cst_lts_rules *new_lts_rules()
{
cst_lts_rules *lt = cst_alloc(cst_lts_rules,1);
lt->name = 0;
lt->letter_index = 0;
lt->models = 0;
lt->phone_table = 0;
lt->context_window_size = 0;
lt->context_extra_feats = 0;
lt->letter_table = 0;
return lt;
}
cst_val *lts_apply_val(const cst_val *wlist,const char *feats,const cst_lts_rules *r)
{
/* for symbol to symbol mapping */
const cst_val *v;
cst_val *p;
char *word;
int i,j;
word = cst_alloc(char,val_length(wlist)+1);
for (v=wlist,i=0; v; v=val_cdr(v),i++)
{
for (j=0; r->letter_table[j]; j++)
if (cst_streq(val_string(val_car(v)),r->letter_table[j]))
{
word[i] = j;
break;
}
if (!r->letter_table[j])
{
#if 0
printf("awb_debug unknown letter >%s<\n",val_string(val_car(v)));
#endif
i--; /* can't find this letter so skip it */
}
}
p = lts_apply(word,feats,r);
cst_free(word);
return p;
}
#endif /* !FLITE_PLUS_HTS_ENGINE */
cst_val *lts_apply(const char *word,const char *feats,const cst_lts_rules *r)
{
int pos, index, i;
cst_val *phones=0;
cst_lts_letter *fval_buff;
cst_lts_letter *full_buff;
cst_lts_phone phone;
char *left, *right, *p;
char hash;
char zeros[8];
/* For feature vals for each letter */
fval_buff = cst_alloc(cst_lts_letter,
(r->context_window_size*2)+
r->context_extra_feats);
/* Buffer with added contexts */
full_buff = cst_alloc(cst_lts_letter,
(r->context_window_size*2)+
cst_strlen(word)+1); /* TBD assumes single POS feat */
if (r->letter_table)
{
for (i=0; i<8; i++) zeros[i] = 2;
cst_sprintf((char *)full_buff,
"%.*s%c%s%c%.*s",
r->context_window_size-1, zeros,
1,
word,
1,
r->context_window_size-1, zeros);
hash = 1;
}
else
{
/* Assumes l_letter is a char and context < 8 */
cst_sprintf((char *)full_buff,
"%.*s#%s#%.*s",
r->context_window_size-1, "00000000",
word,
r->context_window_size-1, "00000000");
hash = '#';
}
/* Do the prediction backwards so we don't need to reverse the answer */
for (pos = r->context_window_size + cst_strlen(word) - 1;
full_buff[pos] != hash;
pos--)
{
/* Fill the features buffer for the predictor */
cst_sprintf((char *)fval_buff,
"%.*s%.*s%s",
r->context_window_size,
full_buff+pos-r->context_window_size,
r->context_window_size,
full_buff+pos+1,
feats);
if ((!r->letter_table
&& ((full_buff[pos] < 'a') || (full_buff[pos] > 'z'))))
{
#ifdef EXCESSIVELY_CHATTY
cst_errmsg("lts:skipping unknown char \"%c\"\n",
full_buff[pos]);
#endif
continue;
}
if (r->letter_table)
index = full_buff[pos] - 3;
else
index = (full_buff[pos]-'a')%26;
phone = apply_model(fval_buff,
r->letter_index[index],
r->models);
/* delete epsilons and split dual-phones */
if (cst_streq("epsilon",r->phone_table[phone]))
continue;
else if ((p=strchr(r->phone_table[phone],'-')) != NULL)
{
left = cst_substr(r->phone_table[phone],0,
cst_strlen(r->phone_table[phone])-cst_strlen(p));
right = cst_substr(r->phone_table[phone],
(cst_strlen(r->phone_table[phone])-cst_strlen(p))+1,
(cst_strlen(p)-1));
phones = cons_val(string_val(left),
cons_val(string_val(right),phones));
cst_free(left);
cst_free(right);
}
else
phones = cons_val(string_val(r->phone_table[phone]),phones);
}
cst_free(full_buff);
cst_free(fval_buff);
return phones;
}
static void cst_lts_get_state(cst_lts_rule *state,
const cst_lts_model *model,
unsigned short n,
int rule_size)
{ /* As some OS's require a more elaborate access than a simple lookup */
memmove(state,&model[n*rule_size],rule_size);
}
static cst_lts_phone apply_model(cst_lts_letter *vals,cst_lts_addr start,
const cst_lts_model *model)
{
/* because some machines (ipaq/mips) can't deal with addrs not on */
/* word boundaries we use a static and copy the rule values each time */
/* so we know its properly aligned */
/* Hmm this still might be wrong on some machines that align the */
/* structure cst_lts_rules differently */
cst_lts_rule state;
unsigned short nstate;
static const int sizeof_cst_lts_rule = 6;
cst_lts_get_state(&state,model,start,sizeof_cst_lts_rule);
for ( ;
state.feat != CST_LTS_EOR;
)
{
/* printf("%s %c %c %d\n",vals,vals[state.feat],state.val,
(vals[state.feat] == state.val) ? 1 : 0); */
if (vals[state.feat] == state.val)
nstate = state.qtrue;
else
nstate = state.qfalse;
/* This should really happen at compilation time */
#ifndef FLITE_PLUS_HTS_ENGINE
if (CST_BIG_ENDIAN)
nstate = SWAPSHORT(nstate);
#endif /* !FLITE_PLUS_HTS_ENGINE */
cst_lts_get_state(&state,model,nstate,sizeof_cst_lts_rule);
}
return (cst_lts_phone)state.val;
}
+216
View File
@@ -0,0 +1,216 @@
/*************************************************************************/
/* */
/* 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 */
/*************************************************************************/
/* */
/* Regexes, this is just a front end to Henry Spencer's regex code */
/* Includes a mapping of fsf format regex's to hs format (escaping) */
/* */
/*************************************************************************/
/* ----------------------------------------------------------------- */
/* 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. */
/* ----------------------------------------------------------------- */
#include "cst_alloc.h"
#include "cst_regex.h"
#include "cst_regex_defs.h"
/* For access by const models */
const cst_regex *const cst_regex_table[] = {
&cst_rx_dotted_abbrev_rx
};
#ifndef FLITE_PLUS_HTS_ENGINE
static char *regularize(const char *unregex,int match);
void cst_regex_init()
{
/* no need to initialize regexes anymore, they are pre-compiled */
return;
}
#endif /* !FLITE_PLUS_HTS_ENGINE */
int cst_regex_match(const cst_regex *r, const char *str)
{
cst_regstate *s;
if (r == NULL) return 0;
s = hs_regexec(r, str);
if (s) {
cst_free(s);
return 1;
} else
return 0;
}
#ifndef FLITE_PLUS_HTS_ENGINE
cst_regstate *cst_regex_match_return(const cst_regex *r, const char *str)
{
if (r == NULL)
return 0;
return hs_regexec(r, str);
}
cst_regex *new_cst_regex(const char *str)
{
cst_regex *r;
char *reg_str = regularize(str,1);
r = hs_regcomp(reg_str);
cst_free(reg_str);
return r;
}
void delete_cst_regex(cst_regex *r)
{
if (r)
hs_regdelete(r);
return;
}
/* These define the different escape conventions for the FSF's */
/* regexp code and Henry Spencer's */
static const char *fsf_magic="^$*+?[].\\";
static const char *fsf_magic_backslashed="()|<>";
static const char *spencer_magic="^$*+?[].()|\\\n";
static const char *spencer_magic_backslashed="<>";
/* Adaptation of rjc's mapping of fsf format to henry spencer's format */
/* of escape sequences, as taken from EST_Regex.cc in EST */
static char *regularize(const char *unregex,int match)
{
char *reg = cst_alloc(char, cst_strlen(unregex)*2+3);
char *r=reg;
const char *e;
int magic=0,last_was_bs=0;
const char * in_brackets=NULL;
const char *ex = (unregex?unregex:"");
if (match && *ex != '^')
*(r++) = '^';
for(e=ex; *e ; e++)
{
if (*e == '\\' && !last_was_bs)
{
last_was_bs=1;
continue;
}
magic=strchr((last_was_bs?fsf_magic_backslashed:fsf_magic), *e)!=NULL;
if (in_brackets)
{
*(r++) = *e;
if (*e == ']' && (e-in_brackets)>1)
in_brackets=0;
}
else if (magic)
{
if (strchr(spencer_magic_backslashed, *e))
*(r++) = '\\';
*(r++) = *e;
if (*e == '[')
in_brackets=e;
}
else
{
if (strchr(spencer_magic, *e))
*(r++) = '\\';
*(r++) = *e;
}
last_was_bs=0;
}
if (match && (e==ex || *(e-1) != '$'))
{
if (last_was_bs)
*(r++) = '\\';
*(r++) = '$';
}
*r='\0';
return reg;
}
#endif /* !FLITE_PLUS_HTS_ENGINE */
@@ -0,0 +1,161 @@
/* Autogenerated from make_cst_regexes */
static const unsigned char cst_rx_white_rxprog[] = {
156, 6, 0, 20, 1, 0, 3, 11, 0, 11, 4, 0, 0, 32, 110, 116,
114, 0, 2, 0, 3, 0, 0, 0,
};
static const cst_regex cst_rx_white_rx = {
0, 1, NULL, 0, 24,
(char *)cst_rx_white_rxprog
};
const cst_regex * const cst_rx_white = &cst_rx_white_rx;
static const unsigned char cst_rx_alpha_rxprog[] = {
156, 6, 0, 68, 1, 0, 3, 11, 0, 59, 4, 0, 0, 65, 66, 67,
68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83,
84, 85, 86, 87, 88, 89, 90, 97, 98, 99, 100, 101, 102, 103, 104, 105,
106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121,
122, 0, 2, 0, 3, 0, 0, 0,
};
static const cst_regex cst_rx_alpha_rx = {
0, 1, NULL, 0, 72,
(char *)cst_rx_alpha_rxprog
};
const cst_regex * const cst_rx_alpha = &cst_rx_alpha_rx;
static const unsigned char cst_rx_uppercase_rxprog[] = {
156, 6, 0, 42, 1, 0, 3, 11, 0, 33, 4, 0, 0, 65, 66, 67,
68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83,
84, 85, 86, 87, 88, 89, 90, 0, 2, 0, 3, 0, 0, 0,
};
static const cst_regex cst_rx_uppercase_rx = {
0, 1, NULL, 0, 46,
(char *)cst_rx_uppercase_rxprog
};
const cst_regex * const cst_rx_uppercase = &cst_rx_uppercase_rx;
static const unsigned char cst_rx_lowercase_rxprog[] = {
156, 6, 0, 42, 1, 0, 3, 11, 0, 33, 4, 0, 0, 97, 98, 99,
100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115,
116, 117, 118, 119, 120, 121, 122, 0, 2, 0, 3, 0, 0, 0,
};
static const cst_regex cst_rx_lowercase_rx = {
0, 1, NULL, 0, 46,
(char *)cst_rx_lowercase_rxprog
};
const cst_regex * const cst_rx_lowercase = &cst_rx_lowercase_rx;
static const unsigned char cst_rx_alphanum_rxprog[] = {
156, 6, 0, 78, 1, 0, 3, 11, 0, 69, 4, 0, 0, 48, 49, 50,
51, 52, 53, 54, 55, 56, 57, 65, 66, 67, 68, 69, 70, 71, 72, 73,
74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89,
90, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111,
112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 0, 2, 0, 3, 0,
0, 0,
};
static const cst_regex cst_rx_alphanum_rx = {
0, 1, NULL, 0, 82,
(char *)cst_rx_alphanum_rxprog
};
const cst_regex * const cst_rx_alphanum = &cst_rx_alphanum_rx;
static const unsigned char cst_rx_identifier_rxprog[] = {
156, 6, 0, 136, 1, 0, 3, 4, 0, 57, 65, 66, 67, 68, 69, 70,
71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86,
87, 88, 89, 90, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108,
109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 95, 0,
11, 0, 70, 4, 0, 0, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57,
65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,
81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 97, 98, 99, 100, 101, 102,
103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118,
119, 120, 121, 122, 95, 0, 2, 0, 3, 0, 0, 0,
};
static const cst_regex cst_rx_identifier_rx = {
0, 1, NULL, 0, 140,
(char *)cst_rx_identifier_rxprog
};
const cst_regex * const cst_rx_identifier = &cst_rx_identifier_rx;
static const unsigned char cst_rx_int_rxprog[] = {
156, 6, 0, 40, 1, 0, 3, 6, 0, 8, 8, 0, 8, 45, 0, 6,
0, 3, 9, 0, 3, 11, 0, 17, 4, 0, 0, 48, 49, 50, 51, 52,
53, 54, 55, 56, 57, 0, 2, 0, 3, 0, 0, 0,
};
static const cst_regex cst_rx_int_rx = {
0, 1, NULL, 0, 44,
(char *)cst_rx_int_rxprog
};
const cst_regex * const cst_rx_int = &cst_rx_int_rx;
static const unsigned char cst_rx_double_rxprog[] = {
156, 6, 0, 199, 1, 0, 3, 6, 0, 8, 8, 0, 8, 45, 0, 6,
0, 3, 9, 0, 3, 21, 0, 3, 6, 0, 51, 22, 0, 3, 6, 0,
42, 11, 0, 17, 4, 0, 0, 48, 49, 50, 51, 52, 53, 54, 55, 56,
57, 0, 8, 0, 5, 46, 0, 10, 0, 17, 4, 0, 0, 48, 49, 50,
51, 52, 53, 54, 55, 56, 57, 0, 32, 0, 66, 6, 0, 29, 23, 0,
3, 6, 0, 20, 11, 0, 17, 4, 0, 0, 48, 49, 50, 51, 52, 53,
54, 55, 56, 57, 0, 33, 0, 37, 6, 0, 34, 24, 0, 3, 6, 0,
25, 8, 0, 5, 46, 0, 11, 0, 17, 4, 0, 0, 48, 49, 50, 51,
52, 53, 54, 55, 56, 57, 0, 34, 0, 3, 31, 0, 3, 6, 0, 50,
25, 0, 3, 6, 0, 41, 4, 0, 6, 101, 69, 0, 6, 0, 9, 4,
0, 9, 45, 43, 0, 6, 0, 3, 9, 0, 3, 11, 0, 17, 4, 0,
0, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 0, 35, 0, 6, 6,
0, 3, 9, 0, 3, 2, 0, 3, 0, 0, 0,
};
static const cst_regex cst_rx_double_rx = {
0, 1, NULL, 0, 203,
(char *)cst_rx_double_rxprog
};
const cst_regex * const cst_rx_double = &cst_rx_double_rx;
static const unsigned char cst_rx_commaint_rxprog[] = {
156, 6, 0, 224, 1, 0, 3, 4, 0, 14, 48, 49, 50, 51, 52, 53,
54, 55, 56, 57, 0, 6, 0, 17, 4, 0, 17, 48, 49, 50, 51, 52,
53, 54, 55, 56, 57, 0, 6, 0, 3, 9, 0, 3, 6, 0, 17, 4,
0, 17, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 0, 6, 0, 3,
9, 0, 3, 8, 0, 5, 44, 0, 6, 0, 62, 21, 0, 3, 6, 0,
50, 4, 0, 14, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 0, 4,
0, 14, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 0, 4, 0, 14,
48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 0, 8, 0, 5, 44, 0,
31, 0, 3, 7, 0, 59, 6, 0, 3, 9, 0, 3, 4, 0, 14, 48,
49, 50, 51, 52, 53, 54, 55, 56, 57, 0, 4, 0, 14, 48, 49, 50,
51, 52, 53, 54, 55, 56, 57, 0, 4, 0, 14, 48, 49, 50, 51, 52,
53, 54, 55, 56, 57, 0, 6, 0, 34, 22, 0, 3, 6, 0, 25, 8,
0, 5, 46, 0, 11, 0, 17, 4, 0, 0, 48, 49, 50, 51, 52, 53,
54, 55, 56, 57, 0, 32, 0, 6, 6, 0, 3, 9, 0, 3, 2, 0,
3, 0, 0, 0,
};
static const cst_regex cst_rx_commaint_rx = {
0, 1, NULL, 0, 228,
(char *)cst_rx_commaint_rxprog
};
const cst_regex * const cst_rx_commaint = &cst_rx_commaint_rx;
static const unsigned char cst_rx_digits_rxprog[] = {
156, 6, 0, 40, 1, 0, 3, 4, 0, 14, 48, 49, 50, 51, 52, 53,
54, 55, 56, 57, 0, 10, 0, 17, 4, 0, 0, 48, 49, 50, 51, 52,
53, 54, 55, 56, 57, 0, 2, 0, 3, 0, 0, 0,
};
static const cst_regex cst_rx_digits_rx = {
0, 1, NULL, 0, 44,
(char *)cst_rx_digits_rxprog
};
const cst_regex * const cst_rx_digits = &cst_rx_digits_rx;
static const unsigned char cst_rx_dotted_abbrev_rxprog[] = {
156, 6, 0, 147, 1, 0, 3, 6, 0, 76, 21, 0, 3, 6, 0, 64,
4, 0, 56, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77,
78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 97, 98, 99,
100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115,
116, 117, 118, 119, 120, 121, 122, 0, 8, 0, 5, 46, 0, 31, 0, 3,
7, 0, 73, 6, 0, 3, 9, 0, 3, 4, 0, 56, 65, 66, 67, 68,
69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
85, 86, 87, 88, 89, 90, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106,
107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122,
0, 2, 0, 3, 0, 0, 0,
};
static const cst_regex cst_rx_dotted_abbrev_rx = {
0, 1, NULL, 0, 151,
(char *)cst_rx_dotted_abbrev_rxprog
};
const cst_regex * const cst_rx_dotted_abbrev = &cst_rx_dotted_abbrev_rx;
File diff suppressed because it is too large Load Diff
+200
View File
@@ -0,0 +1,200 @@
/*************************************************************************/
/* */
/* 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 */
/* */
/*************************************************************************/
/* ----------------------------------------------------------------- */
/* 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. */
/* ----------------------------------------------------------------- */
#include "cst_regex.h"
#include "cst_cart.h"
CST_VAL_REGISTER_TYPE_NODEL(cart,cst_cart)
/* Make this 1 if you want to debug som cart calls */
#define CART_DEBUG 0
#define cst_cart_node_n(P,TREE) ((TREE)->rule_table[P])
#ifndef FLITE_PLUS_HTS_ENGINE
void delete_cart(cst_cart *cart)
{
cst_errmsg("delete_cart function missing\n");
return;
}
#endif /* !FLITE_PLUS_HTS_ENGINE */
#define cst_cart_node_val(n,tree) (cst_cart_node_n(n,tree).val)
#define cst_cart_node_op(n,tree) (cst_cart_node_n(n,tree).op)
#define cst_cart_node_feat(n,tree) (tree->feat_table[cst_cart_node_n(n,tree).feat])
#define cst_cart_node_yes(n,tree) (n+1)
#define cst_cart_node_no(n,tree) (cst_cart_node_n(n,tree).no_node)
#ifndef FLITE_PLUS_HTS_ENGINE
#if CART_DEBUG
static void cart_print_node(int n, const cst_cart *tree)
{
printf("%s ",cst_cart_node_feat(n,tree));
if (cst_cart_node_op(n,tree) == CST_CART_OP_IS)
printf("IS ");
else if (cst_cart_node_op(n,tree) == CST_CART_OP_LESS)
printf("< ");
else if (cst_cart_node_op(n,tree) == CST_CART_OP_GREATER)
printf("> ");
else if (cst_cart_node_op(n,tree) == CST_CART_OP_IN)
printf("IN ");
else if (cst_cart_node_op(n,tree) == CST_CART_OP_MATCHES)
printf("MATCHES ");
else
printf("*%d* ",cst_cart_node_op(n,tree));
val_print(stdout,cst_cart_node_val(n,tree));
printf("\n");
}
#endif
#endif /* !FLITE_PLUS_HTS_ENGINE */
const cst_val *cart_interpret(cst_item *item, const cst_cart *tree)
{
/* Tree interpretation */
const cst_val *v=0;
const cst_val *tree_val;
const char *tree_feat = "";
cst_features *fcache;
int r=0;
int node=0;
fcache = new_features_local(item_utt(item)->ctx);
while (cst_cart_node_op(node,tree) != CST_CART_OP_LEAF)
{
#if CART_DEBUG
cart_print_node(node,tree);
#endif
tree_feat = cst_cart_node_feat(node,tree);
v = get_param_val(fcache,tree_feat,0);
if (v == 0)
{
v = ffeature(item,tree_feat);
feat_set(fcache,tree_feat,v);
}
#if CART_DEBUG
val_print(stdout,v); printf("\n");
#endif
tree_val = cst_cart_node_val(node,tree);
if (cst_cart_node_op(node,tree) == CST_CART_OP_IS)
r = val_equal(v,tree_val);
else if (cst_cart_node_op(node,tree) == CST_CART_OP_LESS)
r = val_less(v,tree_val);
else if (cst_cart_node_op(node,tree) == CST_CART_OP_GREATER)
r = val_greater(v,tree_val);
else if (cst_cart_node_op(node,tree) == CST_CART_OP_IN)
r = val_member(v,tree_val);
else if (cst_cart_node_op(node,tree) == CST_CART_OP_MATCHES)
r = cst_regex_match(cst_regex_table[val_int(tree_val)],
val_string(v));
else
{
cst_errmsg("cart_interpret_question: unknown op type %d\n",
cst_cart_node_op(node,tree));
cst_error();
}
if (r)
{ /* Oh yes it is */
#if CART_DEBUG
printf(" YES\n");
#endif
node = cst_cart_node_yes(node,tree);
}
else
{ /* Oh no it isn't */
#if CART_DEBUG
printf(" NO\n");
#endif
node = cst_cart_node_no(node,tree);
}
}
delete_features(fcache);
return cst_cart_node_val(node,tree);
}
@@ -0,0 +1,803 @@
/*************************************************************************/
/* */
/* 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 */
/*************************************************************************/
/* */
/* Some language independent features */
/* */
/* ----------------------------------------------------------------- */
/* 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. */
/* ----------------------------------------------------------------- */
#include "cst_hrg.h"
#include "cst_phoneset.h"
#include "cst_regex.h"
static const cst_val *word_break(const cst_item *word);
static const cst_val *word_punc(const cst_item *word);
static const cst_val *word_numsyls(const cst_item *word);
static const cst_val *ssyl_in(const cst_item *syl);
static const cst_val *syl_in(const cst_item *syl);
static const cst_val *syl_out(const cst_item *syl);
static const cst_val *syl_break(const cst_item *syl);
static const cst_val *syl_codasize(const cst_item *syl);
static const cst_val *syl_onsetsize(const cst_item *syl);
#ifdef FLITE_PLUS_HTS_ENGINE
const cst_val *accented(const cst_item *p);
#else
static const cst_val *accented(const cst_item *p);
#endif /* FLITE_PLUS_HTS_ENGINE */
DEF_STATIC_CONST_VAL_STRING(val_string_onset,"onset");
DEF_STATIC_CONST_VAL_STRING(val_string_coda,"coda");
DEF_STATIC_CONST_VAL_STRING(val_string_initial,"initial");
DEF_STATIC_CONST_VAL_STRING(val_string_single,"single");
DEF_STATIC_CONST_VAL_STRING(val_string_final,"final");
DEF_STATIC_CONST_VAL_STRING(val_string_mid,"mid");
DEF_STATIC_CONST_VAL_STRING(val_string_empty,"");
const cst_val *ph_vc(const cst_item *p)
{
return phone_feature(item_phoneset(p),item_name(p),"vc");
}
const cst_val *ph_vlng(const cst_item *p)
{
return phone_feature(item_phoneset(p),item_name(p),"vlng");
}
const cst_val *ph_vheight(const cst_item *p)
{
return phone_feature(item_phoneset(p),item_name(p),"vheight");
}
const cst_val *ph_vrnd(const cst_item *p)
{
return phone_feature(item_phoneset(p),item_name(p),"vrnd");
}
const cst_val *ph_vfront(const cst_item *p)
{
return phone_feature(item_phoneset(p),item_name(p),"vfront");
}
const cst_val *ph_ctype(const cst_item *p)
{
return phone_feature(item_phoneset(p),item_name(p),"ctype");
}
const cst_val *ph_cplace(const cst_item *p)
{
return phone_feature(item_phoneset(p),item_name(p),"cplace");
}
const cst_val *ph_cvox(const cst_item *p)
{
return phone_feature(item_phoneset(p),item_name(p),"cvox");
}
const cst_val *cg_duration(const cst_item *p)
{
/* Note this constructs float vals, these will be freed when the */
/* cart cache is freed, so this should only be used in carts */
if (!p)
return float_val(0.0);
else if (!item_prev(p))
return item_feat(p,"end");
else
return float_val(item_feat_float(p,"end")
- item_feat_float(item_prev(p),"end"));
}
DEF_STATIC_CONST_VAL_STRING(val_string_pos_b,"b");
DEF_STATIC_CONST_VAL_STRING(val_string_pos_m,"m");
DEF_STATIC_CONST_VAL_STRING(val_string_pos_e,"e");
const cst_val *cg_state_pos(const cst_item *p)
{
const char *name;
name = item_feat_string(p,"name");
if (!cst_streq(name,ffeature_string(p,"p.name")))
return (cst_val *)&val_string_pos_b;
if (cst_streq(name,ffeature_string(p,"n.name")))
return (cst_val *)&val_string_pos_m;
else
return (cst_val *)&val_string_pos_e;
}
const cst_val *cg_state_place(const cst_item *p)
{
float start, end;
int this;
start = (float)ffeature_int(p,"R:mcep_link.parent.daughter1.frame_number");
end = (float)ffeature_int(p,"R:mcep_link.parent.daughtern.frame_number");
this = item_feat_int(p,"frame_number");
if ((end-start) == 0.0)
return float_val(0.0);
else
return float_val((this-start)/(end-start));
}
const cst_val *cg_state_index(const cst_item *p)
{
float start;
int this;
start = (float)ffeature_int(p,"R:mcep_link.parent.daughter1.frame_number");
this = item_feat_int(p,"frame_number");
return float_val(this-start);
}
const cst_val *cg_state_rindex(const cst_item *p)
{
float end;
int this;
end = (float)ffeature_int(p,"R:mcep_link.parent.daughtern.frame_number");
this = item_feat_int(p,"frame_number");
return float_val(end-this);
}
const cst_val *cg_phone_place(const cst_item *p)
{
float start, end;
int this;
start = (float)ffeature_int(p,"R:mcep_link.parent.R:segstate.parent.daughter1.R:mcep_link.daughter1.frame_number");
end = (float)ffeature_int(p,"R:mcep_link.parent.R:segstate.parent.daughtern.R:mcep_link.daughtern.frame_number");
this = item_feat_int(p,"frame_number");
if ((end-start) == 0.0)
return float_val(0.0);
else
return float_val((this-start)/(end-start));
}
const cst_val *cg_phone_index(const cst_item *p)
{
float start;
int this;
start = (float)ffeature_int(p,"R:mcep_link.parent.R:segstate.parent.daughter1.R:mcep_link.daughter1.frame_number");
this = item_feat_int(p,"frame_number");
return float_val(this-start);
}
const cst_val *cg_phone_rindex(const cst_item *p)
{
float end;
int this;
end = (float)ffeature_int(p,"R:mcep_link.parent.R:segstate.parent.daughtern.R:mcep_link.daughtern.frame_number");
this = item_feat_int(p,"frame_number");
return float_val(end-this);
}
const cst_val *cg_is_pau(const cst_item *p)
{
if (p && cst_streq("pau",item_feat_string(p,"name")))
return VAL_INT_1;
else
return VAL_INT_0;
}
const cst_val *cg_find_phrase_number(const cst_item *p)
{
const cst_item *v;
int x = 0;
for (v=item_prev(p); v; v=item_prev(v))
x++;
return val_int_n(x);
}
const cst_val *cg_position_in_phrasep(const cst_item *p)
{
float pstart, pend, phrasenumber;
float x;
#define CG_FRAME_SHIFT 0.005
pstart = ffeature_float(p,"R:mcep_link.parent.R:segstate.parent.R:SylStructure.parent.parent.R:Phrase.parent.daughter1.R:SylStructure.daughter1.daughter1.R:Segment.p.end");
pend = ffeature_float(p,"R:mcep_link.parent.R:segstate.parent.R:SylStructure.parent.parent.R:Phrase.parent.daughtern.R:SylStructure.daughtern.daughtern.R:Segment.end");
phrasenumber = ffeature_float(p,"R:mcep_link.parent.R:segstate.parent.R:SylStructure.parent.parent.R:Phrase.parent.lisp_cg_find_phrase_number");
if ((pend - pstart) == 0.0)
return float_val(-1.0);
else
{
x = phrasenumber +
((CG_FRAME_SHIFT*item_feat_float(p,"frame_number"))-pstart) /
(pend - pstart);
return float_val(x);
}
}
#ifdef FLITE_PLUS_HTS_ENGINE
const cst_val *accented(const cst_item *syl)
#else
static const cst_val *accented(const cst_item *syl)
#endif
{
if ((item_feat_present(syl,"accent")) ||
(item_feat_present(syl,"endtone")))
return VAL_STRING_1;
else
return VAL_STRING_0;
}
static const cst_val *seg_coda_ctype(const cst_item *seg, const char *ctype)
{
const cst_item *s;
const cst_phoneset *ps = item_phoneset(seg);
for (s=item_last_daughter(item_parent(item_as(seg,"SylStructure")));
s;
s=item_prev(s))
{
if (cst_streq("+",phone_feature_string(ps,item_feat_string(s,"name"),
"vc")))
return VAL_STRING_0;
if (cst_streq(ctype,phone_feature_string(ps,item_feat_string(s,"name"),
"ctype")))
return VAL_STRING_1;
}
return VAL_STRING_0;
}
static const cst_val *seg_onset_ctype(const cst_item *seg, const char *ctype)
{
const cst_item *s;
const cst_phoneset *ps = item_phoneset(seg);
for (s=item_daughter(item_parent(item_as(seg,"SylStructure")));
s;
s=item_next(s))
{
if (cst_streq("+",phone_feature_string(ps,item_feat_string(s,"name"),
"vc")))
return VAL_STRING_0;
if (cst_streq(ctype,phone_feature_string(ps,item_feat_string(s,"name"),
"ctype")))
return VAL_STRING_1;
}
return VAL_STRING_0;
}
static const cst_val *seg_coda_fric(const cst_item *seg)
{
return seg_coda_ctype(seg,"f");
}
static const cst_val *seg_onset_fric(const cst_item *seg)
{
return seg_onset_ctype(seg,"f");
}
static const cst_val *seg_coda_stop(const cst_item *seg)
{
return seg_coda_ctype(seg,"s");
}
static const cst_val *seg_onset_stop(const cst_item *seg)
{
return seg_onset_ctype(seg,"s");
}
static const cst_val *seg_coda_nasal(const cst_item *seg)
{
return seg_coda_ctype(seg,"n");
}
static const cst_val *seg_onset_nasal(const cst_item *seg)
{
return seg_onset_ctype(seg,"n");
}
static const cst_val *seg_coda_glide(const cst_item *seg)
{
if (seg_coda_ctype(seg,"r") == VAL_STRING_0)
return seg_coda_ctype(seg,"l");
return VAL_STRING_1;
}
static const cst_val *seg_onset_glide(const cst_item *seg)
{
if (seg_onset_ctype(seg,"r") == VAL_STRING_0)
return seg_onset_ctype(seg,"l");
return VAL_STRING_1;
}
static const cst_val *seg_onsetcoda(const cst_item *seg)
{
const cst_item *s;
const cst_phoneset *ps = item_phoneset(seg);
if (!seg) return VAL_STRING_0;
for (s=item_next(item_as(seg,"SylStructure"));
s;
s=item_next(s))
{
if (cst_streq("+",phone_feature_string(ps,item_feat_string(s,"name"),
"vc")))
return (cst_val *)&val_string_onset;
}
return (cst_val *)&val_string_coda;
}
static const cst_val *pos_in_syl(const cst_item *seg)
{
const cst_item *s;
int c;
for (c=-1,s=item_as(seg,"SylStructure");
s;
s=item_prev(s),c++);
return val_string_n(c);
}
static const cst_val *position_type(const cst_item *syl)
{
const cst_item *s = item_as(syl,"SylStructure");
if (s == 0)
return (cst_val *)&val_string_single;
else if (item_next(s) == 0)
{
if (item_prev(s) == 0)
return (cst_val *)&val_string_single;
else
return (cst_val *)&val_string_final;
}
else if (item_prev(s) == 0)
return (cst_val *)&val_string_initial;
else
return (cst_val *)&val_string_mid;
}
static const cst_val *sub_phrases(const cst_item *syl)
{
const cst_item *s;
int c;
for (c=0,s=path_to_item(syl,"R:SylStructure.parent.R:Phrase.parent.p");
s && (c < CST_CONST_INT_MAX);
s=item_prev(s),c++);
return val_string_n(c);
}
static const cst_val *last_accent(const cst_item *syl)
{
const cst_item *s;
int c;
for (c=0,s=item_as(syl,"Syllable");
s && (c < CST_CONST_INT_MAX);
s=item_prev(s),c++)
{
if (val_int(accented(s)))
return val_string_n(c);
}
return val_string_n(c);
}
static const cst_val *next_accent(const cst_item *syl)
{
const cst_item *s;
int c;
s=item_as(syl,"Syllable");
if (s)
s = item_next(s);
else
return val_string_n(0);
for (c=0;
s && (c < CST_CONST_INT_MAX);
s=item_next(s),c++)
{
if (val_int(accented(s)))
return val_string_n(c);
}
return val_string_n(c);
}
static const cst_val *syl_final(const cst_item *seg)
{ /* last segment in a syllable */
const cst_item *s = item_as(seg,"SylStructure");
if (!s || (item_next(s) == NULL))
return VAL_STRING_1;
else
return VAL_STRING_0;
}
static const cst_val *word_punc(const cst_item *word)
{
cst_item *ww;
const cst_val *v;
ww = item_as(word,"Token");
if ((ww != NULL) && (item_next(ww) != 0))
v = (cst_val *) &val_string_empty;
else
v = ffeature(item_parent(ww),"punc");
/* printf("word_punc word %s punc %s\n",
item_feat_string(ww,"name"),
val_string(v)); */
return v;
}
static const cst_val *word_break(const cst_item *word)
{
cst_item *ww,*pp;
const char *pname;
ww = item_as(word,"Phrase");
if ((ww == NULL) || (item_next(ww) != 0))
return VAL_STRING_1;
else
{
pp = item_parent(ww);
pname = val_string(item_feat(pp,"name"));
if (cst_streq("BB",pname))
return VAL_STRING_4;
else if (cst_streq("B",pname))
return VAL_STRING_3;
else
return VAL_STRING_1;
}
}
static const cst_val *word_numsyls(const cst_item *word)
{
cst_item *d;
int c;
for (c=0,d=item_daughter(item_as(word,"SylStructure"));
d;
d=item_next(d),c++);
return val_int_n(c);
}
static const cst_val *ssyl_in(const cst_item *syl)
{
/* Number of stressed syllables since last major break */
const cst_item *ss,*p,*fs;
int c;
ss = item_as(syl,"Syllable");
fs = path_to_item(syl,"R:SylStructure.parent.R:Phrase.parent.daughter.R:SylStructure.daughter");
/* This should actually include the first syllable, but Festival's
doesn't. */
for (c=0, p=item_prev(ss);
p && (!item_equal(p,fs)) && (c < CST_CONST_INT_MAX);
p=item_prev(p))
{
if (cst_streq("1",item_feat_string(p,"stress")))
c++;
}
return val_string_n(c); /* its used randomly as int and float */
}
static const cst_val *ssyl_out(const cst_item *syl)
{
/* Number of stressed syllables until last major break */
const cst_item *ss,*p,*fs;
int c;
ss = item_as(syl,"Syllable");
fs = path_to_item(syl,"R:SylStructure.parent.R:Phrase.parent.daughtern.R:SylStructure.daughtern");
for (c=0, p=item_next(ss);
p && (c < CST_CONST_INT_MAX);
p=item_next(p))
{
if (cst_streq("1",item_feat_string(p,"stress")))
c++;
if (item_equal(p,fs))
break;
}
return val_string_n(c); /* its used randomly as int and float */
}
static const cst_val *syl_in(const cst_item *syl)
{
/* Number of syllables since last major break */
const cst_item *ss,*p,*fs;
int c;
ss = item_as(syl,"Syllable");
fs = path_to_item(syl,"R:SylStructure.parent.R:Phrase.parent.daughter.R:SylStructure.daughter");
for (c=0, p=ss;
p && (c < CST_CONST_INT_MAX);
p=item_prev(p),c++)
if (item_equal(p,fs))
break;
return val_string_n(c);
}
static const cst_val *syl_out(const cst_item *syl)
{
/* Number of syllables until next major break */
cst_item *ss,*p;
const cst_item *fs;
int c;
ss = item_as(syl,"Syllable");
fs = path_to_item(syl,"R:SylStructure.parent.R:Phrase.parent.daughtern.R:SylStructure.daughtern");
for (c=0, p=ss;
p && (c < CST_CONST_INT_MAX);
p=item_next(p),c++)
if (item_equal(p,fs))
break;
return val_string_n(c);
}
static const cst_val *syl_break(const cst_item *syl)
{
/* Break level after this syllable */
cst_item *ss;
ss = item_as(syl,"SylStructure");
if (ss == NULL)
return VAL_STRING_1; /* hmm, no sylstructure */
else if (item_next(ss) != NULL)
return VAL_STRING_0; /* word internal */
else if (item_parent(ss) == NULL) /* no parent */
return VAL_STRING_1;
else
return word_break(item_parent(ss));
}
static const cst_val *cg_break(const cst_item *syl)
{
/* phrase prediction is so different between flite and festival */
/* we go with this more robust technique */
cst_item *ss;
ss = item_as(syl,"SylStructure");
if (ss == NULL)
return VAL_INT_0; /* hmm, no sylstructure */
else if (item_next(ss) != NULL)
return VAL_INT_0; /* word internal */
else if (path_to_item(ss,"R:SylStructure.parent.R:Word.n") == NULL)
return VAL_INT_4; /* utterance final */
else if (path_to_item(ss,"R:SylStructure.parent.R:Phrase.n") == NULL)
return VAL_INT_3; /* phrase final */
else
return VAL_INT_1; /* word final */
}
static const cst_val *syl_codasize(const cst_item *syl)
{
cst_item *d;
int c;
for (c=1,d=item_last_daughter(item_as(syl,"SylStructure"));
d;
d=item_prev(d),c++)
{
if (cst_streq("+",val_string(ph_vc(d))))
break;
}
return val_string_n(c);
}
static const cst_val *syl_onsetsize(const cst_item *syl)
{
cst_item *d;
int c;
for (c=0,d=item_daughter(item_as(syl,"SylStructure"));
d;
d=item_next(d),c++)
{
if (cst_streq("+",val_string(ph_vc(d))))
break;
}
return val_string_n(c);
}
static const cst_val *asyl_in(const cst_item *syl)
{
/* Number of accented syllables since last major break */
const cst_item *ss,*p,*fs;
int c;
ss = item_as(syl,"Syllable");
fs = path_to_item(syl,"R:SylStructure.parent.R:Phrase.parent.daughter.R:SylStructure.daughter");
for (c=0, p=ss;
p && (c < CST_CONST_INT_MAX);
p=item_prev(p))
{
if (val_int(accented(p)) == 1)
c++;
if (item_equal(p,fs))
break;
}
return val_string_n(c);
}
static const cst_val *asyl_out(const cst_item *syl)
{
/* Number of accented syllables until next major break */
cst_item *ss,*p;
const cst_item *fs;
int c;
ss = item_as(syl,"Syllable");
fs = path_to_item(syl,"R:SylStructure.parent.R:Phrase.parent.daughtern.R:SylStructure.daughtern");
for (c=0, p=ss;
p && (c < CST_CONST_INT_MAX);
p=item_next(p))
{
if (val_int(accented(p)) == 1)
c++;
if (item_equal(p,fs))
break;
}
return val_string_n(c);
}
static const cst_val *segment_duration(const cst_item *seg)
{
const cst_item *s = item_as(seg,"Segment");
if (!s)
return VAL_STRING_0;
else if (item_prev(s) == NULL)
return item_feat(s,"end");
else
/* It should be okay to construct this as it will get
dereferenced when the CART interpreter frees its feature
cache. */
return float_val(item_feat_float(s,"end")
- item_feat_float(item_prev(s),"end"));
}
void basic_ff_register(cst_features *ffunctions)
{
ff_register(ffunctions, "ph_vc",ph_vc);
ff_register(ffunctions, "ph_vlng",ph_vlng);
ff_register(ffunctions, "ph_vheight",ph_vheight);
ff_register(ffunctions, "ph_vfront",ph_vfront);
ff_register(ffunctions, "ph_vrnd",ph_vrnd);
ff_register(ffunctions, "ph_ctype",ph_ctype);
ff_register(ffunctions, "ph_cplace",ph_cplace);
ff_register(ffunctions, "ph_cvox",ph_cvox);
ff_register(ffunctions, "lisp_cg_duration", cg_duration);
ff_register(ffunctions, "lisp_cg_state_pos", cg_state_pos);
ff_register(ffunctions, "lisp_cg_state_place", cg_state_place);
ff_register(ffunctions, "lisp_cg_state_index", cg_state_index);
ff_register(ffunctions, "lisp_cg_state_rindex", cg_state_rindex);
ff_register(ffunctions, "lisp_cg_phone_place", cg_phone_place);
ff_register(ffunctions, "lisp_cg_phone_index", cg_phone_index);
ff_register(ffunctions, "lisp_cg_phone_rindex", cg_phone_rindex);
ff_register(ffunctions, "lisp_cg_position_in_phrasep", cg_position_in_phrasep);
ff_register(ffunctions, "lisp_cg_find_phrase_number", cg_find_phrase_number);
ff_register(ffunctions, "lisp_is_pau", cg_is_pau);
ff_register(ffunctions, "word_numsyls",word_numsyls);
ff_register(ffunctions, "word_break",word_break);
ff_register(ffunctions, "word_punc",word_punc);
ff_register(ffunctions, "ssyl_in",ssyl_in);
ff_register(ffunctions, "ssyl_out",ssyl_out);
ff_register(ffunctions, "syl_in",syl_in);
ff_register(ffunctions, "syl_out",syl_out);
ff_register(ffunctions, "syl_break",syl_break);
ff_register(ffunctions, "lisp_cg_break",cg_break);
ff_register(ffunctions, "old_syl_break",syl_break);
ff_register(ffunctions, "syl_onsetsize",syl_onsetsize);
ff_register(ffunctions, "syl_codasize",syl_codasize);
ff_register(ffunctions, "accented",accented);
ff_register(ffunctions, "asyl_in",asyl_in);
ff_register(ffunctions, "asyl_out",asyl_out);
ff_register(ffunctions, "lisp_coda_fric",seg_coda_fric);
ff_register(ffunctions, "lisp_onset_fric",seg_onset_fric);
ff_register(ffunctions, "lisp_coda_stop",seg_coda_stop);
ff_register(ffunctions, "lisp_onset_stop",seg_onset_stop);
ff_register(ffunctions, "lisp_coda_nasal",seg_coda_nasal);
ff_register(ffunctions, "lisp_onset_nasal",seg_onset_nasal);
ff_register(ffunctions, "lisp_coda_glide",seg_coda_glide);
ff_register(ffunctions, "lisp_onset_glide",seg_onset_glide);
ff_register(ffunctions, "seg_onsetcoda",seg_onsetcoda);
ff_register(ffunctions, "pos_in_syl",pos_in_syl);
ff_register(ffunctions, "position_type",position_type);
ff_register(ffunctions, "sub_phrases",sub_phrases);
ff_register(ffunctions, "last_accent",last_accent);
ff_register(ffunctions, "next_accent",next_accent);
ff_register(ffunctions, "syl_final",syl_final);
ff_register(ffunctions, "segment_duration",segment_duration);
}
+153
View File
@@ -0,0 +1,153 @@
/*************************************************************************/
/* */
/* 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 definition */
/* */
/*************************************************************************/
/* ----------------------------------------------------------------- */
/* 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. */
/* ----------------------------------------------------------------- */
#include "cst_val.h"
#include "cst_utterance.h"
#include "cst_item.h"
#include "cst_phoneset.h"
CST_VAL_REGISTER_TYPE_NODEL(phoneset,cst_phoneset)
#ifndef FLITE_PLUS_HTS_ENGINE
cst_phoneset *new_phoneset()
{
/* These aren't going to be supported dynamically */
cst_phoneset *v = cst_alloc(struct cst_phoneset_struct,1);
return v;
}
void delete_phoneset(cst_phoneset *v)
{
if (v)
{
cst_free(v);
}
}
#endif /* !FLITE_PLUS_HTS_ENGINE */
int phone_id(const cst_phoneset *ps,const char* phonename)
{
int i;
for (i=0; i< ps->num_phones; i++)
if (cst_streq(ps->phonenames[i],phonename))
return i;
/* Wonder if I should print an error here or not */
return 0;
}
int phone_feat_id(const cst_phoneset *ps,const char* featname)
{
int i;
for (i=0; ps->featnames[i]; i++)
if (cst_streq(ps->featnames[i],featname))
return i;
/* Wonder if I should print an error here or not */
return 0;
}
const cst_val *phone_feature(const cst_phoneset *ps,
const char* phonename,
const char *featname)
{
return ps->featvals[ps->fvtable[phone_id(ps,phonename)]
[phone_feat_id(ps,featname)]];
}
const char *phone_feature_string(const cst_phoneset *ps,
const char* phonename,
const char *featname)
{
return val_string(phone_feature(ps,phonename,featname));
}
const cst_phoneset *item_phoneset(const cst_item *p)
{
return val_phoneset(feat_val(item_utt(p)->features,"phoneset"));
}
+696
View File
@@ -0,0 +1,696 @@
/*************************************************************************/
/* */
/* 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 synthesis control */
/* */
/*************************************************************************/
/* ----------------------------------------------------------------- */
/* 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. */
/* ----------------------------------------------------------------- */
#include "cst_hrg.h"
#include "cst_cart.h"
#include "cst_tokenstream.h"
#include "cst_utt_utils.h"
#include "cst_lexicon.h"
#ifndef FLITE_PLUS_HTS_ENGINE
#include "cst_units.h"
#endif /* !FLITE_PLUS_HTS_ENIGINE */
#include "cst_synth.h"
#include "cst_phoneset.h"
CST_VAL_REGISTER_FUNCPTR(breakfunc,cst_breakfunc)
#ifndef SYNTH_MODULES_DEBUG
#define SYNTH_MODULES_DEBUG 0
#endif
#if SYNTH_MODULES_DEBUG > 0
#define DPRINTF(l,x) if (SYNTH_MODULES_DEBUG > l) cst_dbgmsg x
#else
#define DPRINTF(l,x)
#endif
static cst_utterance *tokentosegs(cst_utterance *u);
static const cst_synth_module synth_method_text[] = {
{ "tokenizer_func", default_tokenization },
{ "textanalysis_func", default_textanalysis },
{ "pos_tagger_func", default_pos_tagger },
{ "phrasing_func", default_phrasing },
{ "lexical_insertion_func", default_lexical_insertion },
{ "pause_insertion_func", default_pause_insertion },
{ "intonation_func", cart_intonation },
{ "postlex_func", NULL },
#ifndef FLITE_PLUS_HTS_ENGINE
{ "duration_model_func", cart_duration },
{ "f0_model_func", NULL },
{ "wave_synth_func", NULL },
{ "post_synth_hook_func", NULL },
#endif /* !FLITE_PLUS_HTS_ENIGINE */
{ NULL, NULL }
};
#ifndef FLITE_PLUS_HTS_ENGINE
static const cst_synth_module synth_method_text2segs[] = {
{ "tokenizer_func", default_tokenization },
{ "textanalysis_func", default_textanalysis },
{ "pos_tagger_func", default_pos_tagger },
{ "phrasing_func", default_phrasing },
{ "lexical_insertion_func", default_lexical_insertion },
{ "pause_insertion_func", default_pause_insertion },
{ NULL, NULL }
};
static const cst_synth_module synth_method_tokens[] = {
{ "textanalysis_func", default_textanalysis },
{ "pos_tagger_func", default_pos_tagger },
{ "phrasing_func", default_phrasing },
{ "lexical_insertion_func", default_lexical_insertion },
{ "pause_insertion_func", default_pause_insertion },
{ "intonation_func", cart_intonation },
{ "postlex_func", NULL },
{ "duration_model_func", cart_duration },
{ "f0_model_func", NULL },
{ "wave_synth_func", NULL },
{ "post_synth_hook_func", NULL },
{ NULL, NULL }
};
static const cst_synth_module synth_method_phones[] = {
{ "tokenizer_func", default_tokenization },
{ "textanalysis_func", tokentosegs },
{ "pos_tagger_func", default_pos_tagger },
{ "intonation_func", NULL },
{ "duration_model_func", cart_duration },
{ "f0_model_func", flat_prosody },
{ "wave_synth_func", NULL },
{ "post_synth_hook_func", NULL },
{ NULL, NULL }
};
#endif /* !FLITE_PLUS_HTS_ENGINE */
cst_utterance *apply_synth_module(cst_utterance *u,
const cst_synth_module *mod)
{
const cst_val *v;
v = feat_val(u->features, mod->hookname);
if (v)
return (*val_uttfunc(v))(u);
if (mod->defhook)
return (*mod->defhook)(u);
return u;
}
cst_utterance *apply_synth_method(cst_utterance *u,
const cst_synth_module meth[])
{
while (meth->hookname)
{
if ((u = apply_synth_module(u, meth)) == NULL)
return NULL;
++meth;
}
return u;
}
cst_utterance *utt_init(cst_utterance *u, cst_voice *vox)
{
feat_copy_into(vox->features,u->features);
feat_copy_into(vox->ffunctions,u->ffunctions);
if (vox->utt_init)
vox->utt_init(u, vox);
return u;
}
cst_utterance *utt_synth(cst_utterance *u)
{
return apply_synth_method(u, synth_method_text);
}
#ifndef FLITE_PLUS_HTS_ENGINE
cst_utterance *utt_synth_tokens(cst_utterance *u)
{
return apply_synth_method(u, synth_method_tokens);
}
cst_utterance *utt_synth_text2segs(cst_utterance *u)
{
return apply_synth_method(u, synth_method_text2segs);
}
cst_utterance *utt_synth_phones(cst_utterance *u)
{
return apply_synth_method(u, synth_method_phones);
}
#endif /* !FLITE_PLUS_HTS_ENGINE */
cst_utterance *default_tokenization(cst_utterance *u)
{
const char *text,*token;
cst_tokenstream *fd;
cst_item *t;
cst_relation *r;
text = utt_input_text(u);
r = utt_relation_create(u,"Token");
fd = ts_open_string(text,
get_param_string(u->features,"text_whitespace",NULL),
get_param_string(u->features,"text_singlecharsymbols",NULL),
get_param_string(u->features,"text_prepunctuation",NULL),
get_param_string(u->features,"text_postpunctuation",NULL));
while(!ts_eof(fd))
{
token = ts_get(fd);
if (cst_strlen(token) > 0)
{
t = relation_append(r,NULL);
item_set_string(t,"name",token);
item_set_string(t,"whitespace",fd->whitespace);
item_set_string(t,"prepunctuation",fd->prepunctuation);
item_set_string(t,"punc",fd->postpunctuation);
item_set_int(t,"file_pos",fd->file_pos);
item_set_int(t,"line_number",fd->line_number);
}
}
ts_close(fd);
return u;
}
cst_val *default_tokentowords(cst_item *i)
{
return cons_val(string_val(item_feat_string(i,"name")), NULL);
}
cst_utterance *default_textanalysis(cst_utterance *u)
{
cst_item *t,*word;
cst_relation *word_rel;
cst_val *words;
const cst_val *w;
const cst_val *ttwv;
word_rel = utt_relation_create(u,"Word");
ttwv = feat_val(u->features, "tokentowords_func");
for (t=relation_head(utt_relation(u,"Token")); t; t=item_next(t))
{
if (ttwv)
words = (cst_val *)(*val_itemfunc(ttwv))(t);
else
words = default_tokentowords(t);
for (w=words; w; w=val_cdr(w))
{
word = item_add_daughter(t,NULL);
if (cst_val_consp(val_car(w)))
{ /* Has extra features */
item_set_string(word,"name",val_string(val_car(val_car(w))));
feat_copy_into(val_features(val_cdr(val_car(w))),
item_feats(word));
}
else
item_set_string(word,"name",val_string(val_car(w)));
relation_append(word_rel,word);
}
delete_val(words);
}
return u;
}
cst_utterance *default_phrasing(cst_utterance *u)
{
cst_relation *r;
cst_item *w, *p, *lp=NULL;
const cst_val *v;
cst_cart *phrasing_cart;
r = utt_relation_create(u,"Phrase");
phrasing_cart = val_cart(feat_val(u->features,"phrasing_cart"));
for (p=NULL,w=relation_head(utt_relation(u,"Word")); w; w=item_next(w))
{
if (p == NULL)
{
p = relation_append(r,NULL);
lp = p;
#ifdef FLITE_PLUS_HTS_ENGINE
item_set_string(p,"name","BB");
#else
item_set_string(p,"name","B");
#endif /* FLITE_PLUS_HTS_ENGINE */
}
item_add_daughter(p,w);
v = cart_interpret(w,phrasing_cart);
if (cst_streq(val_string(v),"BB"))
p = NULL;
}
if (lp && item_prev(lp)) /* follow festival */
item_set_string(lp,"name","BB");
return u;
}
cst_utterance *default_pause_insertion(cst_utterance *u)
{
/* Add initial silences and silence at each phrase break */
const char *silence;
const cst_item *w;
cst_item *p, *s;
silence = val_string(feat_val(u->features,"silence"));
/* Insert initial silence */
s = relation_head(utt_relation(u,"Segment"));
if (s == NULL)
s = relation_append(utt_relation(u,"Segment"),NULL);
else
s = item_prepend(s,NULL);
item_set_string(s,"name",silence);
for (p=relation_head(utt_relation(u,"Phrase")); p; p=item_next(p))
{
for (w = item_last_daughter(p); w; w=item_prev(w))
{
s = path_to_item(w,"R:SylStructure.daughtern.daughtern.R:Segment");
if (s)
{
s = item_append(s,NULL);
item_set_string(s,"name",silence);
break;
}
}
}
return u;
}
cst_utterance *cart_intonation(cst_utterance *u)
{
cst_cart *accents, *tones;
cst_item *s;
const cst_val *v;
if (feat_present(u->features,"no_intonation_accent_model"))
return u; /* not all languages have intonation models */
accents = val_cart(feat_val(u->features,"int_cart_accents"));
tones = val_cart(feat_val(u->features,"int_cart_tones"));
for (s=relation_head(utt_relation(u,"Syllable")); s; s=item_next(s))
{
v = cart_interpret(s,accents);
if (!cst_streq("NONE",val_string(v)))
item_set_string(s,"accent",val_string(v));
v = cart_interpret(s,tones);
if (!cst_streq("NONE",val_string(v)))
item_set_string(s,"endtone",val_string(v));
DPRINTF(0,("word %s gpos %s stress %s ssyl_in %s ssyl_out %s accent %s endtone %s\n",
ffeature_string(s,"R:SylStructure.parent.name"),
ffeature_string(s,"R:SylStructure.parent.gpos"),
ffeature_string(s,"stress"),
ffeature_string(s,"ssyl_in"),
ffeature_string(s,"ssyl_out"),
ffeature_string(s,"accent"),
ffeature_string(s,"endtone")));
}
return u;
}
CST_VAL_REGISTER_TYPE_NODEL(dur_stats,dur_stats)
#ifndef FLITE_PLUS_HTS_ENGINE
const dur_stat *phone_dur_stat(const dur_stats *ds,const char *ph)
{
int i;
for (i=0; ds[i]; i++)
if (cst_streq(ph,ds[i]->phone))
return ds[i];
return ds[0];
}
cst_utterance *cart_duration(cst_utterance *u)
{
cst_cart *dur_tree;
cst_item *s;
float zdur, dur_stretch, local_dur_stretch, dur;
float end;
dur_stats *ds;
const dur_stat *dur_stat;
end = 0;
if (feat_present(u->features,"no_segment_duration_model"))
return u; /* not all methods need segment durations */
dur_tree = val_cart(feat_val(u->features,"dur_cart"));
dur_stretch = get_param_float(u->features,"duration_stretch", 1.0);
ds = val_dur_stats(feat_val(u->features,"dur_stats"));
for (s=relation_head(utt_relation(u,"Segment")); s; s=item_next(s))
{
zdur = val_float(cart_interpret(s,dur_tree));
dur_stat = phone_dur_stat(ds,item_name(s));
local_dur_stretch = ffeature_float(s, "R:SylStructure.parent.parent."
"R:Token.parent.local_duration_stretch");
if (local_dur_stretch)
local_dur_stretch *= dur_stretch;
else
local_dur_stretch = dur_stretch;
dur = local_dur_stretch * ((zdur*dur_stat->stddev)+dur_stat->mean);
DPRINTF(0,("phone %s accent %s stress %s pdur %f stretch %f mean %f std %f dur %f\n",
item_name(s),
ffeature_string(s,"R:SylStructure.parent.accented"),
ffeature_string(s,"R:SylStructure.parent.stress"),
zdur, local_dur_stretch, dur_stat->mean,
dur_stat->stddev, dur));
end += dur;
item_set_float(s,"end",end);
}
return u;
}
#endif /* !FLITE_PLUS_HTS_ENIGINE */
cst_utterance *default_pos_tagger(cst_utterance *u)
{
cst_item *word;
const cst_val *p;
const cst_cart *tagger;
p = get_param_val(u->features,"pos_tagger_cart",NULL);
if (p == NULL)
return u;
tagger = val_cart(p);
for (word=relation_head(utt_relation(u,"Word"));
word; word=item_next(word))
{
p = cart_interpret(word,tagger);
item_set_string(word,"pos",val_string(p));
}
return u;
}
cst_utterance *default_lexical_insertion(cst_utterance *u)
{
cst_item *word;
cst_relation *sylstructure,*seg,*syl;
cst_lexicon *lex;
const cst_val *lex_addenda = NULL;
const cst_val *p, *wp = NULL;
char *phone_name;
char *stress = "0";
const char *pos;
cst_val *phones;
cst_item *ssword, *sssyl, *segitem, *sylitem, *seg_in_syl;
lex = val_lexicon(feat_val(u->features,"lexicon"));
if (lex->lex_addenda)
lex_addenda = lex->lex_addenda;
syl = utt_relation_create(u,"Syllable");
sylstructure = utt_relation_create(u,"SylStructure");
seg = utt_relation_create(u,"Segment");
for (word=relation_head(utt_relation(u,"Word"));
word; word=item_next(word))
{
ssword = relation_append(sylstructure,word);
pos = ffeature_string(word,"pos");
phones = NULL;
wp = NULL;
/* printf("awb_debug word %s pos %s gpos %s\n",
item_feat_string(word,"name"),
pos,
ffeature_string(word,"gpos")); */
/* FIXME: need to make sure that textanalysis won't split
tokens with explicit pronunciation (or that it will
propagate such to words, then we can remove the path here) */
if (item_feat_present(item_parent(item_as(word, "Token")), "phones"))
phones = (cst_val *) item_feat(item_parent(item_as(word, "Token")), "phones");
else
{
wp = val_assoc_string(item_feat_string(word, "name"),lex_addenda);
if (wp)
phones = (cst_val *)val_cdr(val_cdr(wp));
else
phones = lex_lookup(lex,item_feat_string(word,"name"),pos);
}
for (sssyl=NULL,sylitem=NULL,p=phones; p; p=val_cdr(p))
{
if (sylitem == NULL)
{
sylitem = relation_append(syl,NULL);
sssyl = item_add_daughter(ssword,sylitem);
stress = "0";
}
segitem = relation_append(seg,NULL);
phone_name = cst_strdup(val_string(val_car(p)));
if (phone_name[cst_strlen(phone_name)-1] == '1')
{
stress = "1";
phone_name[cst_strlen(phone_name)-1] = '\0';
}
else if (phone_name[cst_strlen(phone_name)-1] == '0')
{
stress = "0";
phone_name[cst_strlen(phone_name)-1] = '\0';
}
item_set_string(segitem,"name",phone_name);
seg_in_syl = item_add_daughter(sssyl,segitem);
#if 0
printf("awb_debug ph %s\n",phone_name);
#endif
if ((lex->syl_boundary)(seg_in_syl,val_cdr(p)))
{
#if 0
printf("awb_debug SYL\n");
#endif
sylitem = NULL;
if (sssyl)
item_set_string(sssyl,"stress",stress);
}
cst_free(phone_name);
}
if (!item_feat_present(item_parent(item_as(word, "Token")), "phones")
&& ! wp)
delete_val(phones);
}
return u;
}
#ifndef FLITE_PLUS_HTS_ENGINE
/* Dummy F0 modelling for phones, copied directly from us_f0_model.c */
cst_utterance *flat_prosody(cst_utterance *u)
{
/* F0 target model */
cst_item *s,*t;
cst_relation *targ_rel;
float mean, stddev;
targ_rel = utt_relation_create(u,"Target");
mean = get_param_float(u->features,"target_f0_mean", 100.0);
mean *= get_param_float(u->features,"f0_shift", 1.0);
stddev = get_param_float(u->features,"target_f0_stddev", 12.0);
s=relation_head(utt_relation(u,"Segment"));
t = relation_append(targ_rel,NULL);
item_set_float(t,"pos",0.0);
item_set_float(t,"f0",mean+stddev);
s=relation_tail(utt_relation(u,"Segment"));
t = relation_append(targ_rel,NULL);
item_set_float(t,"pos",item_feat_float(s,"end"));
item_set_float(t,"f0",mean-stddev);
return u;
}
static cst_utterance *tokentosegs(cst_utterance *u)
{
cst_item *t;
cst_relation *seg, *syl, *sylstructure, *word;
cst_item *sylitem, *sylstructureitem, *worditem, *sssyl;
cst_phoneset *ps;
ps = val_phoneset(utt_feat_val(u, "phoneset"));
/* Just copy tokens into the Segment relation */
seg = utt_relation_create(u, "Segment");
syl = utt_relation_create(u, "Syllable");
word = utt_relation_create(u, "Word");
sylstructure = utt_relation_create(u, "SylStructure");
sssyl = sylitem = worditem = sylstructureitem = 0;
for (t = relation_head(utt_relation(u, "Token")); t; t = item_next(t))
{
cst_item *segitem = relation_append(seg, NULL);
char const *pname = item_feat_string(t, "name");
char *name = cst_strdup(pname);
if (worditem == 0)
{
worditem = relation_append(word,NULL);
item_set_string(worditem, "name", "phonestring");
sylstructureitem = relation_append(sylstructure,worditem);
}
if (sylitem == 0)
{
sylitem = relation_append(syl,NULL);
sssyl = item_add_daughter(sylstructureitem,sylitem);
}
if (name[cst_strlen(name)-1] == '1')
{
item_set_string(sssyl,"stress","1");
name[cst_strlen(name)-1] = '\0';
}
else if (name[cst_strlen(name)-1] == '0')
{
item_set_string(sssyl,"stress","0");
name[cst_strlen(name)-1] = '\0';
}
if (cst_streq(name,"-"))
{
sylitem = 0; /* syllable break */
}
else if (phone_id(ps, name) == -1)
{
cst_errmsg("Phone `%s' not in phoneset\n", pname);
cst_error();
}
else
{
item_add_daughter(sssyl,segitem);
item_set_string(segitem, "name", name);
}
cst_free(name);
}
return u;
}
#endif /* !FLITE_PLUS_HTS_ENIGINE */
int default_utt_break(cst_tokenstream *ts,
const char *token,
cst_relation *tokens)
{
/* This is the default utt break functions, languages may override this */
/* This will be ok for some latin based languages */
const char *postpunct = item_feat_string(relation_tail(tokens), "punc");
const char *ltoken = item_name(relation_tail(tokens));
if (cst_strchr(ts->whitespace,'\n') != cst_strrchr(ts->whitespace,'\n'))
/* contains two new lines */
return TRUE;
else if (strchr(postpunct,':') ||
strchr(postpunct,'?') ||
strchr(postpunct,'!'))
return TRUE;
else if (strchr(postpunct,'.') &&
(cst_strlen(ts->whitespace) > 1) &&
strchr("ABCDEFGHIJKLMNOPQRSTUVWXYZ",token[0]))
return TRUE;
else if (strchr(postpunct,'.') &&
/* next word starts with a capital */
strchr("ABCDEFGHIJKLMNOPQRSTUVWXYZ",token[0]) &&
/* last word isn't an abbreviation */
!(strchr("ABCDEFGHIJKLMNOPQRSTUVWXYZ",ltoken[cst_strlen(ltoken)-1])||
((cst_strlen(ltoken) < 4) &&
strchr("ABCDEFGHIJKLMNOPQRSTUVWXYZ",ltoken[0]))))
return TRUE;
else
return FALSE;
}
@@ -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: September 2000 */
/*************************************************************************/
/* */
/* Various basic utt utilities */
/* */
/*************************************************************************/
/* ----------------------------------------------------------------- */
/* 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. */
/* ----------------------------------------------------------------- */
#include "cst_synth.h"
#include "cst_utt_utils.h"
#ifndef FLITE_PLUS_HTS_ENGINE
cst_wave *utt_wave(cst_utterance *u)
{
if (u)
return val_wave(feat_val(u->features,"wave"));
else
return 0;
}
int utt_set_wave(cst_utterance *u, cst_wave *w)
{
feat_set(u->features,"wave",wave_val(w));
return 0;
}
#endif /* !FLITE_PLUS_HTS_ENGINE */
const char *utt_input_text(cst_utterance *u)
{
return val_string(feat_val(u->features,"input_text"));
}
int utt_set_input_text(cst_utterance *u,const char *text)
{
feat_set_string(u->features,"input_text",text);
return 0;
}
+66
View File
@@ -0,0 +1,66 @@
/*************************************************************************/
/* */
/* 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 definition */
/* */
/*************************************************************************/
#include "cst_alloc.h"
#include "cst_voice.h"
CST_VAL_REGISTER_TYPE(voice,cst_voice)
cst_voice *new_voice()
{
cst_voice *v = cst_alloc(struct cst_voice_struct,1);
v->features = new_features();
v->ffunctions = new_features();
return v;
}
void delete_voice(cst_voice *v)
{
if (v)
{
delete_features(v->features);
delete_features(v->ffunctions);
/* do not delete any dbs in the voice */
/* they are probably const and not deletable -- at least */
/* that is true at present */
cst_free(v);
}
}
+415
View File
@@ -0,0 +1,415 @@
/*************************************************************************/
/* */
/* Language Technologies Institute */
/* Carnegie Mellon University */
/* Copyright (c) 2000-2008 */
/* 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 */
/*************************************************************************/
/* */
/* Basic user level functions */
/* */
/*************************************************************************/
/* ----------------------------------------------------------------- */
/* 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. */
/* ----------------------------------------------------------------- */
#include "cst_tokenstream.h"
#include "flite.h"
/* This is a global, which isn't ideal, this may change */
/* It is set when flite_set_voice_list() is called which happens in */
/* flite_main() */
cst_val *flite_voice_list = 0;
#ifndef FLITE_PLUS_HTS_ENGINE
int flite_init()
{
cst_regex_init();
return 0;
}
cst_voice *flite_voice_select(const char *name)
{
const cst_val *v;
cst_voice *voice;
if (flite_voice_list == NULL)
return NULL; /* oops, not good */
if (name == NULL)
return val_voice(val_car(flite_voice_list));
for (v=flite_voice_list; v; v=val_cdr(v))
{
voice = val_voice(val_car(v));
if (cst_streq(name,voice->name))
return voice;
}
return flite_voice_select(NULL);
}
int flite_voice_add_lex_addenda(cst_voice *v, const cst_string *lexfile)
{
/* Add addenda in lexfile to current voice */
cst_lexicon *lex;
const cst_val *lex_addenda = NULL;
cst_val *new_addenda;
lex = val_lexicon(feat_val(v->features,"lexicon"));
if (feat_present(v->features, "lex_addenda"))
lex_addenda = feat_val(v->features, "lex_addenda");
new_addenda = cst_lex_load_addenda(lex,lexfile);
#if 0
printf("\naddenda: ");
val_print(stdout,new_addenda);
printf("\n");
#endif
new_addenda = val_append(new_addenda,(cst_val *)lex_addenda);
if (lex->lex_addenda)
delete_val(lex->lex_addenda);
lex->lex_addenda = new_addenda;
return 0;
}
#endif /* !FLITE_PLUS_HTS_ENGINE */
cst_utterance *flite_do_synth(cst_utterance *u,
cst_voice *voice,
cst_uttfunc synth)
{
utt_init(u, voice);
if ((*synth)(u) == NULL)
{
delete_utterance(u);
return NULL;
}
else
return u;
}
cst_utterance *flite_synth_text(const char *text, cst_voice *voice)
{
cst_utterance *u;
u = new_utterance();
utt_set_input_text(u,text);
return flite_do_synth(u, voice, utt_synth);
}
#ifndef FLITE_PLUS_HTS_ENGINE
cst_utterance *flite_synth_phones(const char *text, cst_voice *voice)
{
cst_utterance *u;
u = new_utterance();
utt_set_input_text(u,text);
return flite_do_synth(u, voice, utt_synth_phones);
}
cst_wave *flite_text_to_wave(const char *text, cst_voice *voice)
{
cst_utterance *u;
cst_wave *w;
if ((u = flite_synth_text(text,voice)) == NULL)
return NULL;
w = copy_wave(utt_wave(u));
delete_utterance(u);
return w;
}
float flite_file_to_speech(const char *filename,
cst_voice *voice,
const char *outtype)
{
cst_utterance *utt;
cst_tokenstream *ts;
const char *token;
cst_item *t;
cst_relation *tokrel;
float durs = 0;
int num_tokens;
cst_wave *w;
cst_breakfunc breakfunc = default_utt_break;
cst_uttfunc utt_user_callback = 0;
int fp;
if ((ts = ts_open(filename,
get_param_string(voice->features,"text_whitespace",NULL),
get_param_string(voice->features,"text_singlecharsymbols",NULL),
get_param_string(voice->features,"text_prepunctuation",NULL),
get_param_string(voice->features,"text_postpunctuation",NULL)))
== NULL)
{
cst_errmsg("failed to open file \"%s\" for reading\n",
filename);
return 1;
}
fp = get_param_int(voice->features,"file_start_position",0);
if (fp > 0)
ts_set_stream_pos(ts,fp);
if (feat_present(voice->features,"utt_break"))
breakfunc = val_breakfunc(feat_val(voice->features,"utt_break"));
if (feat_present(voice->features,"utt_user_callback"))
utt_user_callback = val_uttfunc(feat_val(voice->features,"utt_user_callback"));
/* If its a file to write to, create and save an empty wave file */
/* as we are going to incrementally append to it */
if (!cst_streq(outtype,"play") &&
!cst_streq(outtype,"none") &&
!cst_streq(outtype,"stream"))
{
w = new_wave();
cst_wave_resize(w,0,1);
cst_wave_set_sample_rate(w,16000);
cst_wave_save_riff(w,outtype); /* an empty wave */
delete_wave(w);
}
num_tokens = 0;
utt = new_utterance();
tokrel = utt_relation_create(utt, "Token");
while (!ts_eof(ts) || num_tokens > 0)
{
token = ts_get(ts);
if ((cst_strlen(token) == 0) ||
(num_tokens > 500) || /* need an upper bound */
(relation_head(tokrel) &&
breakfunc(ts,token,tokrel)))
{
/* An end of utt, so synthesize it */
if (utt_user_callback)
utt = (utt_user_callback)(utt);
if (utt)
{
utt = flite_do_synth(utt,voice,utt_synth_tokens);
durs += flite_process_output(utt,outtype,TRUE);
delete_utterance(utt); utt = NULL;
}
else
break;
if (ts_eof(ts)) break;
utt = new_utterance();
tokrel = utt_relation_create(utt, "Token");
num_tokens = 0;
}
num_tokens++;
t = relation_append(tokrel, NULL);
item_set_string(t,"name",token);
item_set_string(t,"whitespace",ts->whitespace);
item_set_string(t,"prepunctuation",ts->prepunctuation);
item_set_string(t,"punc",ts->postpunctuation);
/* Mark it at the beginning of the token */
item_set_int(t,"file_pos",
ts->file_pos-(1+ /* as we are already on the next char */
cst_strlen(token)+
cst_strlen(ts->prepunctuation)+
cst_strlen(ts->postpunctuation)));
item_set_int(t,"line_number",ts->line_number);
}
delete_utterance(utt);
ts_close(ts);
return durs;
}
float flite_text_to_speech(const char *text,
cst_voice *voice,
const char *outtype)
{
cst_utterance *u;
float dur;
u = flite_synth_text(text,voice);
dur = flite_process_output(u,outtype,FALSE);
delete_utterance(u);
return dur;
}
float flite_phones_to_speech(const char *text,
cst_voice *voice,
const char *outtype)
{
cst_utterance *u;
float dur;
u = flite_synth_phones(text,voice);
dur = flite_process_output(u,outtype,FALSE);
delete_utterance(u);
return dur;
}
float flite_process_output(cst_utterance *u, const char *outtype,
int append)
{
/* Play or save (append) output to output file */
cst_wave *w;
float dur;
if (!u) return 0.0;
w = utt_wave(u);
dur = (float)w->num_samples/(float)w->sample_rate;
if (cst_streq(outtype,"play"))
play_wave(w);
else if (cst_streq(outtype,"stream"))
{
/* It's already been played so do nothing */
}
else if (!cst_streq(outtype,"none"))
{
if (append)
cst_wave_append_riff(w,outtype);
else
cst_wave_save_riff(w,outtype);
}
return dur;
}
#endif /* !FLITE_PLUS_HTS_ENGINE */
int flite_get_param_int(const cst_features *f, const char *name,int def)
{
return get_param_int(f,name,def);
}
float flite_get_param_float(const cst_features *f, const char *name, float def)
{
return get_param_float(f,name,def);
}
const char *flite_get_param_string(const cst_features *f, const char *name, const char *def)
{
return get_param_string(f,name,def);
}
const cst_val *flite_get_param_val(const cst_features *f, const char *name, cst_val *def)
{
return get_param_val(f,name,def);
}
void flite_feat_set_int(cst_features *f, const char *name, int v)
{
feat_set_int(f,name,v);
}
void flite_feat_set_float(cst_features *f, const char *name, float v)
{
feat_set_float(f,name,v);
}
void flite_feat_set_string(cst_features *f, const char *name, const char *v)
{
feat_set_string(f,name,v);
}
void flite_feat_set(cst_features *f, const char *name,const cst_val *v)
{
feat_set(f,name,v);
}
int flite_feat_remove(cst_features *f, const char *name)
{
return feat_remove(f,name);
}
const char *flite_ffeature_string(const cst_item *item,const char *featpath)
{
return ffeature_string(item,featpath);
}
int flite_ffeature_int(const cst_item *item,const char *featpath)
{
return ffeature_int(item,featpath);
}
float flite_ffeature_float(const cst_item *item,const char *featpath)
{
return ffeature_float(item,featpath);
}
const cst_val *flite_ffeature(const cst_item *item,const char *featpath)
{
return ffeature(item,featpath);
}
cst_item* flite_path_to_item(const cst_item *item,const char *featpath)
{
return path_to_item(item,featpath);
}
+260
View File
@@ -0,0 +1,260 @@
/*************************************************************************/
/* */
/* 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 */
/* */
/*************************************************************************/
#include "cst_file.h"
#include "cst_alloc.h"
#include "cst_error.h"
#ifdef UNDER_CE
#include <windows.h>
#endif /* UNDER_CE */
/* define this if you want to trace memory usage */
/* #define CST_DEBUG_MALLOC */
/* #define CST_DEBUG_MALLOC_TRACE */
#ifdef CST_DEBUG_MALLOC
int cst_allocated = 0;
int cst_freed = 0;
int cst_alloc_max = 0;
int cst_alloc_imax = 0;
int cst_alloc_num_calls = 0;
int cst_alloc_out = 0;
#ifdef CST_DEBUG_MALLOC_TRACE
/* This is a crude memory tracer to find leaks */
int cst_alloc_ckpt = -1;
/* You have to know how big this should be to use it, its for debuging only */
#define NUM_CHUNKS 10000000
void *cst_alloc_cunks[NUM_CHUNKS];
#endif
#endif
void *cst_safe_alloc(int size)
{
/* returns pointer to memory all set 0 */
void *p = NULL;
if (size < 0)
{
cst_errmsg("alloc: asked for negative size %d\n", size);
cst_error();
}
else if (size == 0) /* some mallocs return NULL for this */
size++;
#ifdef CST_DEBUG_MALLOC
if (size > cst_alloc_imax)
{
cst_alloc_imax = size;
}
cst_allocated += size;
cst_alloc_out += size;
size += 2 * sizeof(int);
#endif
#ifdef UNDER_CE
p = (void *)LocalAlloc(LPTR, size);
#else
p = (void *)calloc(size,1);
#endif
#ifdef CST_DEBUG_MALLOC
#ifdef CST_DEBUG_MALLOC_TRACE
if (cst_alloc_num_calls == cst_alloc_ckpt)
cst_dbgmsg("cst_malloc: %d\n", cst_alloc_ckpt);
cst_alloc_cunks[cst_alloc_num_calls] = p;
#endif
cst_alloc_num_calls++;
*(int *)p = 1314;
p = (int *)p + 1;
*(int *)p = size - (2 * sizeof(int));
if ((cst_allocated - cst_freed) > cst_alloc_max)
cst_alloc_max = cst_allocated - cst_freed;
p = (int *)p + 1;
#endif
if (p == NULL)
{
cst_errmsg("alloc: can't alloc %d bytes\n", size);
cst_error();
}
return p;
}
void *cst_safe_calloc(int size)
{
return cst_safe_alloc(size);
}
void *cst_safe_realloc(void *p,int size)
{
void *np=0;
#ifdef CST_DEBUG_MALLOC
cst_free(p);
return cst_safe_alloc(size);
#endif
if (size == 0)
size++; /* as some mallocs do strange things with 0 */
if (p == NULL)
np = cst_safe_alloc(size);
else
#ifdef UNDER_CE
np = LocalReAlloc((HLOCAL)p, size, LMEM_MOVEABLE|LMEM_ZEROINIT);
#else
np = realloc(p,size);
#endif
if (np == NULL)
{
cst_errmsg("CST_REALLOC failed for %d bytes\n",size);
cst_error();
}
return np;
}
void cst_free(void *p)
{
if (p != NULL)
{
#ifdef CST_DEBUG_MALLOC
if (*((int *)p - 2) != 1314)
{
cst_dbgmsg("CST_MALLOC_DEBUG freeing non-malloc memory\n");
return;
}
if (*((int *)p - 1) <= 0)
{
cst_dbgmsg("CST_MALLOC_DEBUG re-freeing memory\n");
return;
}
cst_freed += *((int *)p - 1);
cst_alloc_out -= *((int *)p - 1);
*((int *)p - 1) = 0; /* mark it as freed */
p = (int *)p - 2;
#endif
#ifndef CST_DEBUG_MALLOC_TRACE
#ifdef UNDER_CE
if (LocalFree(p) != NULL)
{
cst_errmsg("LocalFree(%p) failed with code %x\n",
p, GetLastError());
cst_error();
}
#else
free(p);
#endif
#endif
}
}
#ifdef CST_DEBUG_MALLOC_TRACE
void cst_find_unfreed()
{
int i, t;
for (i = 0, t = 0;
i < NUM_CHUNKS
&& i < cst_alloc_num_calls
&& cst_alloc_cunks[i];
i++)
{
if (((int *)cst_alloc_cunks[i])[1] != 0)
{
cst_dbgmsg("unfreed at %d\n", i);
t++;
}
}
cst_dbgmsg("total unfreed %d\n", t);
}
void cst_alloc_debug_summary()
{
cst_find_unfreed();
printf("allocated %d freed %d max %d imax %d calls %d out %d\n",
cst_allocated, cst_freed, cst_alloc_max,
cst_alloc_imax, cst_alloc_num_calls, cst_alloc_out);
}
#endif
#ifdef UNDER_CE
cst_alloc_context new_alloc_context(int size)
{
HANDLE h;
h = HeapCreate(0, size, 0);
return (cst_alloc_context) h;
}
void delete_alloc_context(cst_alloc_context ctx)
{
HANDLE h;
h = (HANDLE)ctx;
HeapDestroy(h);
}
void *cst_local_alloc(cst_alloc_context ctx, int size)
{
HANDLE h;
h = (HANDLE)ctx;
if (h)
return HeapAlloc(h, HEAP_ZERO_MEMORY, size);
else
return LocalAlloc(LPTR, size);
}
void cst_local_free(cst_alloc_context ctx, void *p)
{
HANDLE h;
h = (HANDLE)ctx;
if (h)
HeapFree(h, 0, p);
else
LocalFree(p);
}
#endif
+108
View File
@@ -0,0 +1,108 @@
/*************************************************************************/
/* */
/* 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 mechanism */
/* */
/*************************************************************************/
#include <stdlib.h>
#include <stdarg.h>
#include "cst_file.h"
#include "cst_error.h"
#ifdef UNDER_CE
#include <winbase.h>
#include <stdlib.h>
#include "cst_alloc.h"
int cst_errmsg(const char *fmt, ...)
{
#ifdef DEBUG
wchar_t wmsg[256];
wchar_t *wfmt;
size_t len;
va_list args;
len = mbstowcs(NULL,fmt,0) + 1;
wfmt = cst_alloc(wchar_t,len);
mbstowcs(wfmt,fmt,len);
va_start(args,fmt);
_vsnwprintf(wmsg,256,wfmt,args);
va_end(args);
wmsg[255]=L'\0';
cst_free(wfmt);
MessageBoxW(0,wmsg,L"Error",0);
#endif
return 0;
}
jmp_buf *cst_errjmp = 0;
#elif defined(__palmos__)
#ifdef __ARM_ARCH_4T__
/* We only support throwing errors in ARM land */
jmp_buf *cst_errjmp = 0;
#endif
char cst_error_msg[600];
int cst_errmsg(const char *fmt, ...)
{
va_list args;
int count;
va_start(args,fmt);
count = cst_vsprintf(cst_error_msg,fmt,args);
va_end(args);
return 0;
}
#else
jmp_buf *cst_errjmp = 0;
int cst_errmsg(const char *fmt, ...)
{
va_list args;
int rv;
va_start(args, fmt);
rv = vfprintf(stderr, fmt, args);
va_end(args);
return rv;
}
#endif
+319
View File
@@ -0,0 +1,319 @@
/*************************************************************************/
/* */
/* 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 support */
/* */
/*************************************************************************/
/* ----------------------------------------------------------------- */
/* 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. */
/* ----------------------------------------------------------------- */
#include "cst_error.h"
#include "cst_features.h"
CST_VAL_REGISTER_TYPE(features,cst_features)
static cst_featvalpair *feat_find_featpair(const cst_features *f,
const char *name)
{
cst_featvalpair *n;
if (f == NULL)
return NULL;
else
{
for (n=f->head; n; n=n->next)
if (cst_streq(name,n->name))
return n;
return NULL;
}
}
cst_features *new_features(void)
{
cst_features *f;
f = cst_alloc(cst_features,1);
f->head = NULL;
f->ctx = NULL;
return f;
}
cst_features *new_features_local(cst_alloc_context ctx)
{
cst_features *f;
f = (cst_features *)cst_local_alloc(ctx, sizeof(*f));
f->head = NULL;
f->ctx = ctx;
return f;
}
void delete_features(cst_features *f)
{
cst_featvalpair *n, *np;
if (f)
{
for (n=f->head; n; n=np)
{
np = n->next;
delete_val(n->val);
cst_local_free(f->ctx,n);
}
cst_local_free(f->ctx,f);
}
}
int feat_present(const cst_features *f, const char *name)
{
return (feat_find_featpair(f,name) != NULL);
}
int feat_length(const cst_features *f)
{
int i=0;
cst_featvalpair *p;
if (f)
for (i=0,p=f->head; p; p=p->next)
i++;
return i;
}
int feat_remove(cst_features *f, const char *name)
{
cst_featvalpair *n,*p,*np;
if (f == NULL)
return FALSE; /* didn't remove it */
else
{
for (p=NULL,n=f->head; n; p=n,n=np)
{
np = n->next;
if (cst_streq(name,n->name))
{
if (p == 0)
f->head = np;
else
p->next = np;
delete_val(n->val);
cst_local_free(f->ctx,n);
return TRUE;
}
}
return FALSE;
}
}
int feat_int(const cst_features *f, const char *name)
{
return val_int(feat_val(f,name));
}
float feat_float(const cst_features *f, const char *name)
{
return val_float(feat_val(f,name));
}
const char *feat_string(const cst_features *f, const char *name)
{
return val_string(feat_val(f,name));
}
const cst_val *feat_val(const cst_features *f, const char *name)
{
cst_featvalpair *n;
n = feat_find_featpair(f,name);
if (n == NULL)
return NULL;
else
return n->val;
}
int get_param_int(const cst_features *f, const char *name,int def)
{
const cst_val *v;
v = feat_val(f,name);
if (v != NULL)
return val_int(v);
else
return def;
}
float get_param_float(const cst_features *f, const char *name, float def)
{
const cst_val *v;
v = feat_val(f,name);
if (v != NULL)
return val_float(v);
else
return def;
}
const char *get_param_string(const cst_features *f, const char *name, const char *def)
{
const cst_val *v;
v = feat_val(f,name);
if (v != NULL)
return val_string(v);
else
return def;
}
const cst_val *get_param_val(const cst_features *f, const char *name, cst_val *def)
{
const cst_val *v;
v = feat_val(f,name);
if (v != NULL)
return v;
else
return def;
}
void feat_set_int(cst_features *f, const char *name, int v)
{
feat_set(f,name,int_val(v));
}
void feat_set_float(cst_features *f, const char *name, float v)
{
feat_set(f,name,float_val(v));
}
void feat_set_string(cst_features *f, const char *name, const char *v)
{
feat_set(f,name,string_val(v));
}
void feat_set(cst_features *f, const char* name, const cst_val *val)
{
cst_featvalpair *n;
n = feat_find_featpair(f,name);
if (val == NULL)
{
cst_errmsg("cst_val: trying to set a NULL val for feature \"%s\"\n",
name);
}
else if (n == NULL)
{ /* first reference to this feature so create new fpair */
cst_featvalpair *p;
p = (cst_featvalpair *)cst_local_alloc(f->ctx, sizeof(*p));
p->next = f->head;
p->name = name;
p->val = val_inc_refcount(val);
f->head = p;
}
else
{
delete_val(n->val);
n->val = val_inc_refcount(val);
}
}
int feat_copy_into(const cst_features *from,cst_features *to)
{
/* Copy all features in from into to */
cst_featvalpair *p;
int i;
for (i=0,p=from->head; p; p=p->next,i++)
feat_set(to,p->name,p->val);
return i;
}
#ifndef FLITE_PLUS_HTS_ENGINE
int feat_print(cst_file fd,const cst_features *f)
{
cst_featvalpair *p;
for (p=f->head; p; p=p->next)
{
cst_fprintf(fd, "%s ",p->name);
val_print(fd,p->val);
cst_fprintf(fd,"\n");
}
return 0;
}
#endif /* !FLITE_PLUS_HTS_ENGINE */
+160
View File
@@ -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: December 1999 */
/*************************************************************************/
/* */
/* String manipulation functions */
/* */
/*************************************************************************/
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include "cst_alloc.h"
#include "cst_string.h"
#ifdef UNDER_CE /* WinCE does not fully implement ANSI C */
cst_string *cst_strrchr(const cst_string *str, int c)
{
cst_string *p = (const cst_string *)str + cst_strlen(str);
while (p >= str) {
if (*p == c)
return p;
--p;
}
return NULL;
}
double cst_atof(const char *str)
{
/* double f = 0.0; */
/* sscanf(str, "%f", &f); */
return atof(str);
}
#else /* Sane operating system */
cst_string *cst_strrchr(const cst_string *str, int c)
{
return (cst_string *)strrchr((const char *)str, c);
}
double cst_atof(const char *str)
{
return atof(str);
}
#endif /* WinCE */
cst_string *cst_strdup(const cst_string *str)
{
cst_string *nstr = NULL;
if (str)
{
nstr = cst_alloc(cst_string,cst_strlen((const char *)str)+1);
memmove(nstr,str,cst_strlen((const char *)str)+1);
}
return nstr;
}
cst_string *cst_strchr(const cst_string *s, int c)
{
return (cst_string *)strchr((const char *)s,c);
}
char *cst_substr(const char *str,int start, int length)
{
char *nstr = NULL;
if (str)
{
nstr = cst_alloc(char,length+1);
strncpy(nstr,str+start,length);
nstr[length] = '\0';
}
return nstr;
}
char *cst_string_before(const char *s,const char *c)
{
char *p;
char *q;
p = (char *)cst_strstr(s,c);
if (p == NULL)
return NULL;
q = (char *)cst_strdup((cst_string *)s);
q[cst_strlen(s)-cst_strlen(p)] = '\0';
return q;
}
cst_string *cst_downcase(const cst_string *str)
{
cst_string *dc;
int i;
dc = cst_strdup(str);
for (i=0; str[i] != '\0'; i++)
{
if (isupper((int)str[i]))
dc[i] = tolower((int)str[i]);
}
return dc;
}
cst_string *cst_upcase(const cst_string *str)
{
cst_string *uc;
int i;
uc = cst_strdup(str);
for (i=0; str[i] != '\0'; i++)
{
if (islower((int)str[i]))
uc[i] = toupper((int)str[i]);
}
return uc;
}
int cst_member_string(const char *str, const char * const *slist)
{
const char * const *p;
for (p = slist; *p; ++p)
if (cst_streq(*p, str))
break;
return *p != NULL;
}
@@ -0,0 +1,508 @@
/*************************************************************************/
/* */
/* 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 */
/* */
/*************************************************************************/
/* ----------------------------------------------------------------- */
/* 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. */
/* ----------------------------------------------------------------- */
#include "cst_tokenstream.h"
const cst_string * const cst_ts_default_whitespacesymbols = " \t\n\r";
const cst_string * const cst_ts_default_singlecharsymbols = "(){}[]";
const cst_string * const cst_ts_default_prepunctuationsymbols = "\"'`({[";
const cst_string * const cst_ts_default_postpunctuationsymbols = "\"'`.,:;!?(){}[]";
#define TS_BUFFER_SIZE 256
#define TS_EOF -1
static cst_string ts_getc(cst_tokenstream *ts);
static void set_charclass_table(cst_tokenstream *ts)
{
int i;
memset(ts->charclass,0,256); /* zero everything */
for (i=0; ts->p_whitespacesymbols[i]; i++)
ts->charclass[(unsigned char)ts->p_whitespacesymbols[i]] |= TS_CHARCLASS_WHITESPACE;
for (i=0; ts->p_singlecharsymbols[i]; i++)
ts->charclass[(unsigned char)ts->p_singlecharsymbols[i]] |= TS_CHARCLASS_SINGLECHAR;
for (i=0; ts->p_prepunctuationsymbols[i]; i++)
ts->charclass[(unsigned char)ts->p_prepunctuationsymbols[i]] |= TS_CHARCLASS_PREPUNCT;
for (i=0; ts->p_postpunctuationsymbols[i]; i++)
ts->charclass[(unsigned char)ts->p_postpunctuationsymbols[i]]|=TS_CHARCLASS_POSTPUNCT;
return;
}
void set_charclasses(cst_tokenstream *ts,
const cst_string *whitespace,
const cst_string *singlecharsymbols,
const cst_string *prepunctuation,
const cst_string *postpunctuation)
{
ts->p_whitespacesymbols =
(whitespace ? whitespace : cst_ts_default_whitespacesymbols);
ts->p_singlecharsymbols =
(singlecharsymbols ? singlecharsymbols : cst_ts_default_singlecharsymbols);
ts->p_prepunctuationsymbols =
(prepunctuation ? prepunctuation : cst_ts_default_prepunctuationsymbols);
ts->p_postpunctuationsymbols =
(postpunctuation ? postpunctuation : cst_ts_default_postpunctuationsymbols);
set_charclass_table(ts);
return;
}
static void extend_buffer(cst_string **buffer,int *buffer_max)
{
int new_max;
cst_string *new_buffer;
new_max = (*buffer_max)+(*buffer_max)/5;
new_buffer = cst_alloc(cst_string,new_max);
memmove(new_buffer,*buffer,*buffer_max);
cst_free(*buffer);
*buffer = new_buffer;
*buffer_max = new_max;
}
static cst_tokenstream *new_tokenstream(const cst_string *whitespace,
const cst_string *singlechars,
const cst_string *prepunct,
const cst_string *postpunct)
{ /* Constructor function */
cst_tokenstream *ts = cst_alloc(cst_tokenstream,1);
ts->fd = NULL;
ts->file_pos = 0;
ts->line_number = 0;
ts->string_buffer = NULL;
ts->token_pos = 0;
ts->whitespace = cst_alloc(cst_string,TS_BUFFER_SIZE);
ts->ws_max = TS_BUFFER_SIZE;
if (prepunct && prepunct[0])
{
ts->prepunctuation = cst_alloc(cst_string,TS_BUFFER_SIZE);
ts->prep_max = TS_BUFFER_SIZE;
}
ts->token = cst_alloc(cst_string,TS_BUFFER_SIZE);
ts->token_max = TS_BUFFER_SIZE;
if (postpunct && postpunct[0])
{
ts->postpunctuation = cst_alloc(cst_string,TS_BUFFER_SIZE);
ts->postp_max = TS_BUFFER_SIZE;
}
set_charclasses(ts,whitespace,singlechars,prepunct,postpunct);
ts->current_char = 0;
return ts;
}
void delete_tokenstream(cst_tokenstream *ts)
{
cst_free(ts->whitespace);
cst_free(ts->token);
if (ts->prepunctuation) cst_free(ts->prepunctuation);
if (ts->postpunctuation) cst_free(ts->postpunctuation);
cst_free(ts);
}
#ifndef FLITE_PLUS_HTS_ENGINE
cst_tokenstream *ts_open(const char *filename,
const cst_string *whitespace,
const cst_string *singlechars,
const cst_string *prepunct,
const cst_string *postpunct)
{
cst_tokenstream *ts = new_tokenstream(whitespace,
singlechars,
prepunct,
postpunct);
#ifndef UNDER_CE
if (cst_streq("-",filename))
ts->fd = stdin;
else
#endif
ts->fd = cst_fopen(filename,CST_OPEN_READ|CST_OPEN_BINARY);
ts_getc(ts);
if (ts->fd == NULL)
{
delete_tokenstream(ts);
return NULL;
}
else
return ts;
}
#endif /* !FLITE_PLUS_HTS_ENGINE*/
cst_tokenstream *ts_open_string(const cst_string *string,
const cst_string *whitespace,
const cst_string *singlechars,
const cst_string *prepunct,
const cst_string *postpunct)
{
cst_tokenstream *ts = new_tokenstream(whitespace,
singlechars,
prepunct,
postpunct);
ts->string_buffer = cst_strdup(string);
ts_getc(ts);
return ts;
}
void ts_close(cst_tokenstream *ts)
{
if (ts->fd != NULL)
{
#ifndef FLITE_PLUS_HTS_ENGINE
#ifndef UNDER_CE
if (ts->fd != stdin)
#endif
cst_fclose(ts->fd);
#endif /* !FLITE_PLUS_HTS_ENGINE */
ts->fd = NULL; /* just in case close gets called twice */
}
if (ts->string_buffer != NULL)
{
cst_free(ts->string_buffer);
ts->string_buffer = NULL;
}
delete_tokenstream(ts);
}
static void get_token_sub_part(cst_tokenstream *ts,
int charclass,
cst_string **buffer,
int *buffer_max)
{
int p;
for (p=0; ((ts->current_char != TS_EOF) &&
(ts_charclass(ts->current_char,charclass,ts)) &&
(!ts_charclass(ts->current_char,
TS_CHARCLASS_SINGLECHAR,ts))); p++)
{
if (p >= *buffer_max) extend_buffer(buffer,buffer_max);
(*buffer)[p] = ts->current_char;
ts_getc(ts);
}
(*buffer)[p] = '\0';
}
/* Can't afford dynamically generate this char class so have separater func */
static void get_token_sub_part_2(cst_tokenstream *ts,
int endclass1,
cst_string **buffer,
int *buffer_max)
{
int p;
for (p=0; ((ts->current_char != TS_EOF) &&
(!ts_charclass(ts->current_char,endclass1,ts)) &&
(!ts_charclass(ts->current_char,
TS_CHARCLASS_SINGLECHAR,ts)));
p++)
{
if (p >= *buffer_max) extend_buffer(buffer,buffer_max);
(*buffer)[p] = ts->current_char;
ts_getc(ts);
}
(*buffer)[p] = '\0';
}
static void get_token_postpunctuation(cst_tokenstream *ts)
{
int p,t;
t = cst_strlen(ts->token);
for (p=t;
(p > 0) &&
((ts->token[p] == '\0') ||
(ts_charclass(ts->token[p],TS_CHARCLASS_POSTPUNCT,ts)));
p--);
if (t != p)
{
if (t-p >= ts->postp_max)
extend_buffer(&ts->postpunctuation,&ts->postp_max);
/* Copy postpunctuation from token */
memmove(ts->postpunctuation,&ts->token[p+1],(t-p));
/* truncate token at postpunctuation */
ts->token[p+1] = '\0';
}
}
int ts_eof(cst_tokenstream *ts)
{
if (ts->current_char == TS_EOF)
return TRUE;
else
return FALSE;
}
int ts_set_stream_pos(cst_tokenstream *ts, int pos)
{
/* Note this doesn't preserve line_pos */
int new_pos, l;
if (ts->fd)
#ifdef FLITE_PLUS_HTS_ENGINE
new_pos = pos < 0 ? 0 : pos;
#else
new_pos = (int)cst_fseek(ts->fd, (long)pos, CST_SEEK_ABSOLUTE);
#endif
else if (ts->string_buffer)
{
l = cst_strlen(ts->string_buffer);
if (pos > l)
new_pos = l;
else if (pos < 0)
new_pos = 0;
else
new_pos = pos;
}
else
new_pos = pos; /* not sure it can get here */
ts->file_pos = new_pos;
ts->current_char = ' '; /* To be safe */
return ts->file_pos;
}
int ts_get_stream_pos(cst_tokenstream *ts)
{
return ts->file_pos;
}
static cst_string ts_getc(cst_tokenstream *ts)
{
if (ts->fd)
{
#ifndef FLITE_PLUS_HTS_ENGINE
ts->current_char = cst_fgetc(ts->fd);
#endif /* !FLITE_PLUS_HTS_ENGINE */
}
else if (ts->string_buffer)
{
if (ts->string_buffer[ts->file_pos] == '\0')
ts->current_char = TS_EOF;
else
ts->current_char = ts->string_buffer[ts->file_pos];
}
if (ts->current_char != TS_EOF)
ts->file_pos++;
if (ts->current_char == '\n')
ts->line_number++;
return ts->current_char;
}
const cst_string *ts_get_quoted_token(cst_tokenstream *ts,
char quote,
char escape)
{
/* for reading the next quoted token that starts with quote and
ends with quote, quote may appear only if preceded by escape */
int p;
/* Hmm can't change quotes within a ts */
ts->charclass[(unsigned int)quote] |= TS_CHARCLASS_QUOTE;
ts->charclass[(unsigned int)escape] |= TS_CHARCLASS_QUOTE;
/* skipping whitespace */
get_token_sub_part(ts,TS_CHARCLASS_WHITESPACE,
&ts->whitespace,
&ts->ws_max);
ts->token_pos = ts->file_pos - 1;
if (ts->current_char == quote)
{ /* go until quote */
ts_getc(ts);
for (p=0; ((ts->current_char != TS_EOF) &&
(ts->current_char != quote));
p++)
{
if (p >= ts->token_max)
extend_buffer(&ts->token,&ts->token_max);
ts->token[p] = ts->current_char;
ts_getc(ts);
if (ts->current_char == escape)
{
ts_get(ts);
if (p >= ts->token_max)
extend_buffer(&ts->token,&ts->token_max);
ts->token[p] = ts->current_char;
ts_get(ts);
}
}
ts->token[p] = '\0';
ts_getc(ts);
}
else /* its not quotes, like to be careful dont you */
{ /* treat is as standard token */
/* Get prepunctuation */
get_token_sub_part(ts,TS_CHARCLASS_PREPUNCT,
&ts->prepunctuation,
&ts->prep_max);
/* Get the symbol itself */
if (!ts_charclass(ts->current_char,TS_CHARCLASS_SINGLECHAR,ts))
{
if (2 >= ts->token_max) extend_buffer(&ts->token,&ts->token_max);
ts->token[0] = ts->current_char;
ts->token[1] = '\0';
ts_getc(ts);
}
else
get_token_sub_part_2(ts,
TS_CHARCLASS_WHITESPACE, /* end class1 */
&ts->token,
&ts->token_max);
/* This'll have token *plus* post punctuation in ts->token */
/* Get postpunctuation */
get_token_postpunctuation(ts);
}
return ts->token;
}
const cst_string *ts_get(cst_tokenstream *ts)
{
/* Get next token */
/* Skip whitespace */
get_token_sub_part(ts,
TS_CHARCLASS_WHITESPACE,
&ts->whitespace,
&ts->ws_max);
/* quoted strings currently ignored */
ts->token_pos = ts->file_pos - 1;
/* Get prepunctuation */
if (ts->current_char != TS_EOF &&
ts_charclass(ts->current_char,TS_CHARCLASS_PREPUNCT,ts))
get_token_sub_part(ts,
TS_CHARCLASS_PREPUNCT,
&ts->prepunctuation,
&ts->prep_max);
else if (ts->prepunctuation)
ts->prepunctuation[0] = '\0';
/* Get the symbol itself */
if (ts->current_char != TS_EOF &&
ts_charclass(ts->current_char,TS_CHARCLASS_SINGLECHAR,ts))
{
if (2 >= ts->token_max) extend_buffer(&ts->token,&ts->token_max);
ts->token[0] = ts->current_char;
ts->token[1] = '\0';
ts_getc(ts);
}
else
get_token_sub_part_2(ts,
TS_CHARCLASS_WHITESPACE, /* end class1 */
&ts->token,
&ts->token_max);
/* This'll have token *plus* post punctuation in ts->token */
/* Get postpunctuation */
if (ts->p_postpunctuationsymbols[0])
get_token_postpunctuation(ts);
return ts->token;
}
int ts_read(void *buff, int size, int num, cst_tokenstream *ts)
{
/* people should complain about the speed here */
/* people will complain about EOF as end of file */
int i,j,p;
cst_string *cbuff;
cbuff = (cst_string *)buff;
for (p=i=0; i < num; i++)
for (j=0; j < size; j++,p++)
cbuff[p] = ts_getc(ts);
return i;
}
+594
View File
@@ -0,0 +1,594 @@
/*************************************************************************/
/* */
/* 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 */
/*************************************************************************/
/* */
/* Typed values */
/* */
/*************************************************************************/
/* ----------------------------------------------------------------- */
/* 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. */
/* ----------------------------------------------------------------- */
#include "cst_math.h"
#include "cst_file.h"
#include "cst_val.h"
#include "cst_string.h"
static cst_val *new_val()
{
return cst_alloc(struct cst_val_struct,1);
}
cst_val *int_val(int i)
{
cst_val *v = new_val();
CST_VAL_TYPE(v) = CST_VAL_TYPE_INT;
CST_VAL_INT(v) = i;
return v;
}
cst_val *float_val(float f)
{
cst_val *v = new_val();
CST_VAL_TYPE(v) = CST_VAL_TYPE_FLOAT;
CST_VAL_FLOAT(v) = f;
return v;
}
cst_val *string_val(const char *s)
{
cst_val *v = new_val();
CST_VAL_TYPE(v) = CST_VAL_TYPE_STRING;
/* would be nice to note if this is a deletable string or not */
CST_VAL_STRING_LVAL(v) = cst_strdup(s);
return v;
}
cst_val *cons_val(const cst_val *a, const cst_val *b)
{
cst_val *v = new_val();
CST_VAL_CAR(v)=((!a || cst_val_consp(a)) ?
(cst_val *)(void *)a:val_inc_refcount(a));
CST_VAL_CDR(v)=((!b || cst_val_consp(b)) ?
(cst_val *)(void *)b:val_inc_refcount(b));
return v;
}
cst_val *val_new_typed(int type,void *vv)
{
cst_val *v = new_val();
CST_VAL_TYPE(v) = type;
CST_VAL_VOID(v) = vv;
return v;
}
void delete_val_list(cst_val *v)
{
if (v)
{
if (cst_val_consp(v))
{
delete_val_list(CST_VAL_CDR(v));
cst_free(v);
}
else
delete_val(v);
}
}
void delete_val(cst_val *v)
{
if (v)
{
if (cst_val_consp(v))
{
delete_val(CST_VAL_CAR(v));
delete_val(CST_VAL_CDR(v));
cst_free(v);
}
else if (val_dec_refcount(v) == 0)
{
if (CST_VAL_TYPE(v) == CST_VAL_TYPE_STRING)
cst_free(CST_VAL_VOID(v));
else if (CST_VAL_TYPE(v) >= CST_VAL_TYPE_FIRST_FREE)
{
if (cst_val_defs[CST_VAL_TYPE(v)/2].delete_function)
(cst_val_defs[CST_VAL_TYPE(v)/2].delete_function)
(CST_VAL_VOID(v));
}
cst_free(v);
}
}
}
/* Accessor functions */
int val_int(const cst_val *v)
{
if (v && (CST_VAL_TYPE(v) == CST_VAL_TYPE_INT))
return CST_VAL_INT(v);
else if (v && (CST_VAL_TYPE(v) == CST_VAL_TYPE_FLOAT))
return (int)CST_VAL_FLOAT(v);
else if (v && (CST_VAL_TYPE(v) == CST_VAL_TYPE_STRING))
return atoi(CST_VAL_STRING(v));
else
{
cst_errmsg("VAL: tried to access int in %d typed val\n",
(v ? CST_VAL_TYPE(v) : -1));
cst_error();
}
return 0;
}
float val_float(const cst_val *v)
{
if (v && (CST_VAL_TYPE(v) == CST_VAL_TYPE_INT))
return (float)CST_VAL_INT(v);
else if (v && (CST_VAL_TYPE(v) == CST_VAL_TYPE_FLOAT))
return CST_VAL_FLOAT(v);
else if (v && (CST_VAL_TYPE(v) == CST_VAL_TYPE_STRING))
return cst_atof(CST_VAL_STRING(v));
else
{
cst_errmsg("VAL: tried to access float in %d typed val\n",
(v ? CST_VAL_TYPE(v) : -1));
cst_error();
}
return 0;
}
const char *val_string(const cst_val *v)
{
if (v && (CST_VAL_TYPE(v) == CST_VAL_TYPE_STRING))
return CST_VAL_STRING(v);
else
{
cst_errmsg("VAL: tried to access string in %d typed val\n",
(v ? CST_VAL_TYPE(v) : -1));
cst_error();
}
return 0;
}
const cst_val *val_car(const cst_val *v)
{
if (v && cst_val_consp(v))
return CST_VAL_CAR(v);
else
{
cst_errmsg("VAL: tried to access car in %d typed val\n",
(v ? CST_VAL_TYPE(v) : -1));
cst_error();
}
return 0;
}
const cst_val *val_cdr(const cst_val *v)
{
if (v && cst_val_consp(v))
return CST_VAL_CDR(v);
else
{
cst_errmsg("VAL: tried to access cdr in %d typed val\n",
(v ? CST_VAL_TYPE(v) : -1));
cst_error();
}
return 0;
}
void *val_generic(const cst_val *v, int type, const char *stype)
{ /* a generic access function that checks the expected type */
if (v && CST_VAL_TYPE(v) == type)
return CST_VAL_VOID(v);
else
{
cst_errmsg("VAL: tried to access %s in %d type val\n",
stype,
(v ? CST_VAL_TYPE(v) : -1));
cst_error();
}
return NULL;
}
void *val_void(const cst_val *v)
{
/* The scary, do anything function, this shouldn't be called by mortals */
if ((v == NULL) ||
(CST_VAL_TYPE(v) == CST_VAL_TYPE_CONS) ||
(CST_VAL_TYPE(v) == CST_VAL_TYPE_INT) ||
(CST_VAL_TYPE(v) == CST_VAL_TYPE_FLOAT))
{
cst_errmsg("VAL: tried to access void in %d typed val\n",
(v ? CST_VAL_TYPE(v) : -1));
cst_error();
return NULL;
}
else
return CST_VAL_VOID(v);
}
int cst_val_consp(const cst_val *v)
{
/* To keep a val cell down to 8 bytes we identify non-cons cells */
/* with non-zero values in the least significant bit of the first */
/* address in the cell (this is a standard technique used on Lisp */
/* machines */
#if 0
void *t;
int t1;
/* Hmm this still isn't right (it can be) but this isn't it */
t = CST_VAL_CAR(v);
t1 = *(int *)&t;
if ((t1&0x1) == 0)
return TRUE;
else
return FALSE;
#endif
const cst_val_atom *t;
t = (const cst_val_atom *)v;
if (t->type % 2 == 0)
return TRUE;
else
return FALSE;
}
const cst_val *set_cdr(cst_val *v1, const cst_val *v2)
{
/* destructive set cdr, be careful you have a pointer to current cdr */
if (!cst_val_consp(v1))
{
cst_errmsg("VAL: tried to set cdr of non-consp cell\n");
cst_error();
return NULL;
}
else
{
val_dec_refcount(CST_VAL_CDR(v1));
val_inc_refcount(v1);
CST_VAL_CDR(v1) = (cst_val *)v2;
}
return v1;
}
const cst_val *set_car(cst_val *v1, const cst_val *v2)
{
/* destructive set car, be careful you have a pointer to current cdr */
if (!cst_val_consp(v1))
{
cst_errmsg("VAL: tried to set car of non-consp cell\n");
cst_error();
return NULL;
}
else
{
val_dec_refcount(CST_VAL_CAR(v1));
val_inc_refcount(v1);
CST_VAL_CAR(v1) = (cst_val *)v2;
}
return v1;
}
#ifndef FLITE_PLUS_HTS_ENGINE
void val_print(cst_file fd,const cst_val *v)
{
const cst_val *p;
if (v == NULL)
cst_fprintf(fd,"[null]");
else if (CST_VAL_TYPE(v) == CST_VAL_TYPE_INT)
cst_fprintf(fd,"%d",val_int(v));
else if (CST_VAL_TYPE(v) == CST_VAL_TYPE_FLOAT)
cst_fprintf(fd,"%f",val_float(v));
else if (CST_VAL_TYPE(v) == CST_VAL_TYPE_STRING)
cst_fprintf(fd,"%s",val_string(v));
else if (cst_val_consp(v))
{
cst_fprintf(fd,"(");
for (p=v; p; )
{
val_print(fd,val_car(p));
p=val_cdr(p);
if (p)
cst_fprintf(fd," ");
}
cst_fprintf(fd,")");
}
else
cst_fprintf(fd,"[Val %s 0x%p]",
cst_val_defs[CST_VAL_TYPE(v)/2].name,CST_VAL_VOID(v));
}
#endif /* !FLITE_PLUS_HTS_ENGINE */
cst_val *val_reverse(cst_val *l)
{
cst_val *n,*np,*nl;
for (nl=0,n=l; n; nl=n,n=np)
{
np=CST_VAL_CDR(n);
CST_VAL_CDR(n) = nl;
}
return nl;
}
cst_val *val_append(cst_val *l1, cst_val *l2)
{
/* Destructively add l2 to the end of l1 return l1 */
cst_val *t;
if (l1 == 0)
return l2;
else
{
for (t=l1; val_cdr(t); t=CST_VAL_CDR(t));
CST_VAL_CDR(t) = l2;
return l1;
}
}
int val_length(const cst_val *l)
{
const cst_val *n;
int i;
for (i=0,n=l; n; n=val_cdr(n))
i++;
return i;
}
int val_equal(const cst_val *v1, const cst_val *v2)
{
if (v1 == v2)
return TRUE; /* its eq so its equal */
else if (v1 == 0)
return FALSE;
else if (CST_VAL_TYPE(v1) == CST_VAL_TYPE(v2))
{
if (cst_val_consp(v1))
return ((val_equal(val_car(v1),val_car(v2))) &&
(val_equal(val_cdr(v1),val_cdr(v2))));
else if (CST_VAL_TYPE(v1) == CST_VAL_TYPE_INT)
return (val_int(v1) == val_int(v2));
else if (CST_VAL_TYPE(v1) == CST_VAL_TYPE_FLOAT)
return (val_float(v1) == val_float(v2));
else if (CST_VAL_TYPE(v1) == CST_VAL_TYPE_STRING)
return (cst_streq(CST_VAL_STRING(v1),CST_VAL_STRING(v2)));
else
return CST_VAL_VOID(v1) == CST_VAL_VOID(v2);
}
else
return FALSE;
}
int val_less(const cst_val *v1, const cst_val *v2)
{
return val_float(v1) < val_float(v2);
}
int val_greater(const cst_val *v1,const cst_val *v2)
{
return val_float(v1) > val_float(v2);
}
int val_member(const cst_val *v1,const cst_val *l)
{
const cst_val *i;
for (i=l; i; i=val_cdr(i))
{
if (val_equal(val_car(i),v1))
return TRUE;
}
return FALSE;
}
int val_member_string(const char *v1,const cst_val *l)
{
const cst_val *i;
for (i=l; i; i=val_cdr(i))
{
if (cst_streq(v1,val_string(val_car(i))))
return TRUE;
}
return FALSE;
}
cst_val *val_inc_refcount(const cst_val *b)
{
cst_val *wb;
/* Well I was lying, they're not really const, but this is the place */
/* where breaking const is reasonable */
wb = (cst_val *)(void *)b;
if (CST_VAL_REFCOUNT(wb) == -1)
/* or is a cons cell in the text segment, how do I do that ? */
return wb;
else if (!cst_val_consp(wb)) /* we don't ref count cons cells */
CST_VAL_REFCOUNT(wb) += 1;
return wb;
}
int val_dec_refcount(const cst_val *b)
{
cst_val *wb;
wb = (cst_val *)(void *)b;
if (CST_VAL_REFCOUNT(wb) == -1)
/* or is a cons cell in the text segment, how do I do that ? */
return -1;
else if (cst_val_consp(wb)) /* we don't ref count cons cells */
return 0;
else if (CST_VAL_REFCOUNT(wb) == 0)
{
/* Otherwise, trying to free a val outside an
item/relation/etc has rather the opposite effect from what
you might have intended... */
return 0;
}
else
{
CST_VAL_REFCOUNT(wb) -= 1;
return CST_VAL_REFCOUNT(wb);
}
}
cst_val *cst_utf8_explode(const cst_string *utf8string)
{
/* return a list of utf-8 characters as strings */
const unsigned char *xxx = (const unsigned char *)utf8string;
cst_val *chars = NULL;
char utf8char[5];
for (int i=0; xxx[i]; i++)
{
if (xxx[i] < 0x80) /* one byte */
{
sprintf(utf8char, "%c", xxx[i]);
}
else if (xxx[i] < 0xe0) /* two bytes */
{
sprintf(utf8char, "%c%c", xxx[i], xxx[i+1]);
i++;
}
else if (xxx[i] < 0xff) /* three bytes */
{
sprintf(utf8char, "%c%c%c", xxx[i], xxx[i+1], xxx[i+2]);
i++; i++;
}
else
{
sprintf(utf8char, "%c%c%c%c", xxx[i], xxx[i+1], xxx[i+2], xxx[i+3]);
i++; i++; i++;
}
chars = cons_val(string_val(utf8char), chars);
}
return val_reverse(chars);
}
int val_stringp(const cst_val *v)
{
if (cst_val_consp(v))
return FALSE;
else if (CST_VAL_TYPE(v) == CST_VAL_TYPE_STRING)
return TRUE;
else
return FALSE;
}
const cst_val *val_assoc_string(const char *v1,const cst_val *al)
{
const cst_val *i;
for (i=al; i; i=val_cdr(i))
{
if (cst_streq(v1,val_string(val_car(val_car(i)))))
return val_car(i);
}
return NULL;
}
cst_string *cst_implode(const cst_val *sl)
{
const cst_val *v;
int l=0;
char *s;
for (v=sl; v; v=val_cdr(v))
{
if (val_stringp(val_car(v)))
l += cst_strlen(val_string(val_car(v)));
}
s = cst_alloc(cst_string,l+1);
for (v=sl; v; v=val_cdr(v))
{
if (val_stringp(val_car(v)))
cst_sprintf(s,"%s%s",s,val_string(val_car(v)));
}
return s;
}
@@ -0,0 +1,173 @@
/*************************************************************************/
/* */
/* 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 */
/*************************************************************************/
/* */
/* Without a real garbage collector we need some basic constant val */
/* to avoid having to create them on the fly */
/* */
/*************************************************************************/
#include "cst_val.h"
#include "cst_features.h"
#include "cst_string.h"
DEF_CONST_VAL_STRING(val_string_0,"0");
DEF_CONST_VAL_STRING(val_string_1,"1");
DEF_CONST_VAL_STRING(val_string_2,"2");
DEF_CONST_VAL_STRING(val_string_3,"3");
DEF_CONST_VAL_STRING(val_string_4,"4");
DEF_CONST_VAL_STRING(val_string_5,"5");
DEF_CONST_VAL_STRING(val_string_6,"6");
DEF_CONST_VAL_STRING(val_string_7,"7");
DEF_CONST_VAL_STRING(val_string_8,"8");
DEF_CONST_VAL_STRING(val_string_9,"9");
DEF_CONST_VAL_STRING(val_string_10,"10");
DEF_CONST_VAL_STRING(val_string_11,"11");
DEF_CONST_VAL_STRING(val_string_12,"12");
DEF_CONST_VAL_STRING(val_string_13,"13");
DEF_CONST_VAL_STRING(val_string_14,"14");
DEF_CONST_VAL_STRING(val_string_15,"15");
DEF_CONST_VAL_STRING(val_string_16,"16");
DEF_CONST_VAL_STRING(val_string_17,"17");
DEF_CONST_VAL_STRING(val_string_18,"18");
DEF_CONST_VAL_STRING(val_string_19,"19");
DEF_CONST_VAL_INT(val_int_0,0);
DEF_CONST_VAL_INT(val_int_1,1);
DEF_CONST_VAL_INT(val_int_2,2);
DEF_CONST_VAL_INT(val_int_3,3);
DEF_CONST_VAL_INT(val_int_4,4);
DEF_CONST_VAL_INT(val_int_5,5);
DEF_CONST_VAL_INT(val_int_6,6);
DEF_CONST_VAL_INT(val_int_7,7);
DEF_CONST_VAL_INT(val_int_8,8);
DEF_CONST_VAL_INT(val_int_9,9);
DEF_CONST_VAL_INT(val_int_10,10);
DEF_CONST_VAL_INT(val_int_11,11);
DEF_CONST_VAL_INT(val_int_12,12);
DEF_CONST_VAL_INT(val_int_13,13);
DEF_CONST_VAL_INT(val_int_14,14);
DEF_CONST_VAL_INT(val_int_15,15);
DEF_CONST_VAL_INT(val_int_16,16);
DEF_CONST_VAL_INT(val_int_17,17);
DEF_CONST_VAL_INT(val_int_18,18);
DEF_CONST_VAL_INT(val_int_19,19);
static const int val_int_const_max = 20;
static const cst_val * const val_int_const [] = {
VAL_INT_0,
VAL_INT_1,
VAL_INT_2,
VAL_INT_3,
VAL_INT_4,
VAL_INT_5,
VAL_INT_6,
VAL_INT_7,
VAL_INT_8,
VAL_INT_9,
VAL_INT_10,
VAL_INT_11,
VAL_INT_12,
VAL_INT_13,
VAL_INT_14,
VAL_INT_15,
VAL_INT_16,
VAL_INT_17,
VAL_INT_18,
VAL_INT_19 };
static const cst_val * const val_string_const [] = {
VAL_STRING_0,
VAL_STRING_1,
VAL_STRING_2,
VAL_STRING_3,
VAL_STRING_4,
VAL_STRING_5,
VAL_STRING_6,
VAL_STRING_7,
VAL_STRING_8,
VAL_STRING_9,
VAL_STRING_10,
VAL_STRING_11,
VAL_STRING_12,
VAL_STRING_13,
VAL_STRING_14,
VAL_STRING_15,
VAL_STRING_16,
VAL_STRING_17,
VAL_STRING_18,
VAL_STRING_19 };
const cst_val *val_int_n(int n)
{
if (n < val_int_const_max)
return val_int_const[n];
else
return val_int_const[val_int_const_max-1];
}
/* carts are pretty confused about strings/ints, and some features */
/* are actually used as floats and as int/strings */
const cst_val *val_string_n(int n)
{
if (n < 0)
return val_string_const[0];
else if (n < val_int_const_max) /* yes I mean *int*, its the table size */
return val_string_const[n];
else
return val_string_const[val_int_const_max-1];
}
#if 0
/* This technique isn't thread safe, so I replaced it with val_consts */
static cst_features *val_string_consts = NULL;
const cst_val *val_string_x(const char *n)
{
const cst_val *v;
/* *BUG* This will have to be fixed soon */
if (val_string_consts == NULL)
val_string_consts = new_features();
v = feat_val(val_string_consts,n);
if (v)
return v;
else
{
feat_set_string(val_string_consts,n,n);
return feat_val(val_string_consts,n);
}
}
#endif
+165
View File
@@ -0,0 +1,165 @@
/*************************************************************************/
/* */
/* 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 1999 */
/*************************************************************************/
/* */
/* User defined type registration */
/* */
/* I'd like to make this file be automatically generated */
/* */
/*************************************************************************/
/* ----------------------------------------------------------------- */
/* 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. */
/* ----------------------------------------------------------------- */
#include "cst_val.h"
#include "cst_string.h"
CST_VAL_REG_TD_TYPE(utterance,cst_utterance,7)
#ifndef FLITE_PLUS_HTS_ENGINE
CST_VAL_REG_TD_TYPE(wave,cst_wave,9)
CST_VAL_REG_TD_TYPE(track,cst_track,11)
CST_VAL_REG_TD_TYPE(lpcres,cst_lpcres,13)
CST_VAL_REG_TD_FUNCPTR(uttfunc,cst_uttfunc,15)
#else
CST_VAL_REG_TD_TYPE(wave,NULL,9)
CST_VAL_REG_TD_TYPE(track,NULL,11)
CST_VAL_REG_TD_TYPE(lpcres,NULL,13)
CST_VAL_REG_TD_FUNCPTR(uttfunc,NULL,15)
#endif /* !FLITE_PLUS_HTS_ENGINE */
CST_VAL_REG_TD_FUNCPTR(ffunc,cst_ffunction,17)
CST_VAL_REG_TD_TYPE_NODEL(relation,cst_relation,19)
CST_VAL_REG_TD_TYPE_NODEL(item,cst_item,21)
CST_VAL_REG_TD_TYPE_NODEL(cart,cst_cart,23)
CST_VAL_REG_TD_TYPE_NODEL(phoneset,cst_phoneset,25)
CST_VAL_REG_TD_TYPE_NODEL(lexicon,cst_lexicon,27)
CST_VAL_REG_TD_TYPE_NODEL(dur_stats,dur_stats,29)
CST_VAL_REG_TD_TYPE_NODEL(diphone_db,cst_diphone_db,31)
CST_VAL_REG_TD_TYPE_NODEL(clunit_db,cst_clunit_db,33)
CST_VAL_REG_TD_TYPE_NODEL(vit_cand,cst_vit_cand,35)
CST_VAL_REG_TD_TYPE_NODEL(sts_list,cst_sts_list,37)
CST_VAL_REG_TD_TYPE_NODEL(userdata,cst_userdata,41)
CST_VAL_REGISTER_TYPE_NODEL(userdata,cst_userdata)
CST_VAL_REG_TD_FUNCPTR(itemfunc,cst_itemfunc,43)
CST_VAL_REG_TD_TYPE(features,cst_features,45)
CST_VAL_REG_TD_FUNCPTR(breakfunc,cst_breakfunc,47)
CST_VAL_REG_TD_TYPE_NODEL(cg_db,cst_cg_db,49)
CST_VAL_REG_TD_TYPE(voice,cst_voice,51)
CST_VAL_REG_TD_TYPE(audio_streaming_info,cst_audio_streaming_info,53)
const cst_val_def cst_val_defs[] = {
/* These ones are never called */
{ "int" , NULL }, /* 1 INT */
{ "float", NULL }, /* 3 FLOAT */
{ "string", NULL }, /* 5 STRING */
/* These are indexed (type/2) at print and delete time */
{ "utterance", val_delete_utterance }, /* 7 utterance */
#ifndef FLITE_PLUS_HTS_ENGINE
{ "wave", val_delete_wave }, /* 9 wave */
{ "track", val_delete_track }, /* 11 track */
{ "lpcres", val_delete_lpcres }, /* 13 lpcres */
{ "uttfunc", val_delete_uttfunc }, /* 15 uttfunc */
#else
{ "wave", NULL }, /* 9 wave */
{ "track", NULL }, /* 11 track */
{ "lpcres", NULL }, /* 13 lpcres */
{ "uttfunc", NULL }, /* 15 uttfunc */
#endif /* !FLITE_PLUS_HTS_ENGINE */
{ "ffunc", val_delete_ffunc }, /* 17 ffunc */
{ "relation", val_delete_relation }, /* 19 relation */
{ "item", val_delete_item }, /* 21 item */
{ "cart", val_delete_cart }, /* 23 cart */
{ "phoneset", val_delete_phoneset }, /* 25 phoneset */
{ "lexicon", val_delete_lexicon }, /* 27 lexicon */
{ "dur_stats", val_delete_dur_stats }, /* 29 dur_stats */
{ "diphone_db", val_delete_diphone_db }, /* 31 diphone_db */
{ "clunit_db", val_delete_clunit_db }, /* 33 clunit_db */
{ "vit_cand", val_delete_vit_cand }, /* 35 vit_cand */
{ "sts_list", val_delete_sts_list }, /* 37 sts_list */
{ NULL, NULL }, /* 39 (reserved) */
{ "userdata", val_delete_userdata }, /* 41 userdata */
{ "itemfunc", val_delete_itemfunc }, /* 43 itemfunc */
{ "features", val_delete_features }, /* 45 itemfunc */
{ "breakfunc", val_delete_breakfunc }, /* 47 breakfunc */
{ "cg_db", val_delete_cg_db }, /* 49 cg_db */
#ifndef FLITE_PLUS_HTS_ENGINE
{ "voice", val_delete_voice }, /* 51 cst_voice */
{ "audio_streaming_info", val_delete_audio_streaming_info }, /* 53 asi */
#else
{ "voice", NULL }, /* 51 cst_voice */
{ "audio_streaming_info", NULL }, /* 53 asi */
#endif /* !FLITE_PLUS_HTS_ENGINE */
{ NULL, NULL } /* NULLs at end of list */
};