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

14
3rdparty/hts_engine_API/AUTHORS vendored Normal file
View File

@@ -0,0 +1,14 @@
The hts_engine API is software to synthesize speech waveform from HMMs trained
by the HMM-based speech synthesis system (HTS). This software is released
under the Modified BSD license. See the COPYING file in the same directory as
this file for the license.
The hts_engine_API has been developed by several members of HTS working group
and some graduate students in Nagoya Institute of Technology:
Keiichi Tokuda http://www.sp.nitech.ac.jp/~tokuda/
(Produce and Design)
Keiichiro Oura http://www.sp.nitech.ac.jp/~uratec/
(Design and Development, Main Maintainer)
Heiga Zen
Shinji Sako http://www.mmsp.nitech.ac.jp/~sako/

21
3rdparty/hts_engine_API/CMakeLists.txt vendored Normal file
View File

@@ -0,0 +1,21 @@
set(HTS_ENGINE_SOURCES
lib/HTS_audio.c
lib/HTS_engine.c
lib/HTS_gstream.c
lib/HTS_label.c
lib/HTS_misc.c
lib/HTS_model.c
lib/HTS_pstream.c
lib/HTS_sstream.c
lib/HTS_vocoder.c
)
add_library(hts_engine STATIC
${HTS_ENGINE_SOURCES}
)
target_include_directories(hts_engine PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)
add_library(Flightgear::HTSEngine ALIAS hts_engine)

43
3rdparty/hts_engine_API/COPYING vendored Normal file
View File

@@ -0,0 +1,43 @@
/* ----------------------------------------------------------------- */
/* The HMM-Based Speech Synthesis Engine "hts_engine API" */
/* developed by HTS Working Group */
/* http://hts-engine.sourceforge.net/ */
/* ----------------------------------------------------------------- */
/* */
/* Copyright (c) 2001-2015 Nagoya Institute of Technology */
/* Department of Computer Science */
/* */
/* 2001-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. */
/* ----------------------------------------------------------------- */

573
3rdparty/hts_engine_API/ChangeLog vendored Normal file
View File

@@ -0,0 +1,573 @@
2015-12-23 17:18 uratec
* lib/HTS_sstream.c: add label file checker.
2015-12-21 10:19 uratec
* COPYING, NEWS, README, configure.ac, bin/hts_engine.c,
include/HTS_engine.h, lib/HTS_audio.c, lib/HTS_engine.c,
lib/HTS_gstream.c, lib/HTS_hidden.h, lib/HTS_label.c,
lib/HTS_misc.c, lib/HTS_model.c, lib/HTS_pstream.c,
lib/HTS_sstream.c, lib/HTS_vocoder.c: update to version 1.10
2015-08-26 11:22 uratec
* lib/: HTS_engine.c, HTS_hidden.h, HTS_model.c, HTS_sstream.c: fix
a bug of interpolation weights: reported by Martin Sulir.
2014-12-11 19:01 uratec
* configure.ac: update autoconf setting
2014-12-02 12:42 uratec
* NEWS: update news.
2014-12-02 11:54 uratec
* configure.ac, bin/Makefile.am, lib/Makefile.am: modify makefiles
for latest automake
2014-12-01 11:05 uratec
* COPYING, README, configure.ac, bin/hts_engine.c,
include/HTS_engine.h, lib/HTS_audio.c, lib/HTS_engine.c,
lib/HTS_gstream.c, lib/HTS_hidden.h, lib/HTS_label.c,
lib/HTS_misc.c, lib/HTS_model.c, lib/HTS_pstream.c,
lib/HTS_sstream.c, lib/HTS_vocoder.c: update documents to ver
1.09
2014-11-12 11:31 uratec
* include/HTS_engine.h, lib/HTS_engine.c, lib/HTS_hidden.h,
lib/HTS_model.c: add label-check functions.
2014-11-12 11:28 uratec
* lib/HTS_model.c: fix 64bit problem in model loader
2014-11-12 11:26 uratec
* lib/HTS_misc.c: add null check for calloc func
2014-11-12 11:24 uratec
* lib/HTS_hidden.h: fix typo
2014-11-12 11:21 uratec
* lib/HTS_audio.c: support 64bit windows audio
2014-11-12 11:20 uratec
* lib/HTS_pstream.c: remove waring message from compiler.
2014-11-11 00:59 uratec
* bin/hts_engine.c: add -g option to change volume.
2013-12-26 17:06 uratec
* bin/hts_engine.c: Add audio buffer size option suggested by
Nicholas Volk.
2013-12-24 12:34 uratec
* lib/: HTS_audio.c, HTS_misc.c: Remove gcc warning message.
2013-12-11 23:58 uratec
* lib/HTS_misc.c: Make android gcc happy.
2013-12-11 18:29 uratec
* lib/HTS_misc.c: Make cygwin gcc happy.
2013-12-10 19:35 uratec
* COPYING, NEWS, README, configure.ac, bin/hts_engine.c,
include/HTS_engine.h, lib/HTS_hidden.h, lib/HTS_label.c,
lib/HTS_misc.c, lib/HTS_vocoder.c: Update documents to version
1.08.
2013-12-10 19:32 uratec
* include/HTS_engine.h: Change HTS_Boolean from int to char.
2013-12-10 19:31 uratec
* include/HTS_engine.h, lib/HTS_engine.c: Add some functions for
separating synthesis step.
2013-12-10 19:29 uratec
* lib/: HTS_gstream.c, HTS_pstream.c: Check memory allocation in
end of parameter generation.
2013-12-10 19:26 uratec
* lib/HTS_sstream.c: Fix a small bug: When model duration specified
by label is zero, shortest duration should be used.
2013-12-10 19:21 uratec
* lib/HTS_model.c: When the model interpolation weights are zero,
don't search the nodes.
2013-12-10 19:18 uratec
* lib/HTS_audio.c: Change return value of audio output function.
2013-05-07 12:51 uratec
* lib/: HTS_gstream.c, HTS_hidden.h, HTS_vocoder.c: Re-write
excitation function.
2013-04-23 09:46 uratec
* lib/HTS_vocoder.c: Fix a bug in postfilter calculation.
2013-02-08 13:13 uratec
* include/HTS_engine.h, lib/HTS_engine.c, lib/HTS_hidden.h,
lib/HTS_misc.c, lib/HTS_pstream.c, lib/HTS_vocoder.c: Add some
functions to get number of frames and generated parameters. Fix
tiny bugs.
2013-01-04 17:11 uratec
* lib/: HTS_engine.c, HTS_model.c: Support 64-bit machine.
2012-12-20 17:35 uratec
* bin/hts_engine.c: Revice help message.
2012-12-20 16:54 uratec
* include/HTS_engine.h: Revice comments in header.
2012-12-20 12:38 uratec
* COPYING, NEWS, README, configure.ac, include/HTS_engine.h: Update
documents.
2012-12-20 12:36 uratec
* lib/HTS_engine.c: Fix DB calculation bug and lower limit of
speech speed.
2012-12-17 15:38 uratec
* lib/: HTS_hidden.h, HTS_vocoder.c: Fix LSP expanding for
stability.
2012-12-15 20:08 uratec
* bin/hts_engine.c, lib/HTS_engine.c, lib/HTS_hidden.h,
lib/HTS_vocoder.c: Add LSP postfilter.
2012-12-15 16:42 uratec
* ChangeLog: Remove ChangeLog file from CVS.
2012-12-15 16:40 uratec
* bin/hts_engine.c, include/HTS_engine.h, lib/HTS_audio.c,
lib/HTS_engine.c, lib/HTS_gstream.c, lib/HTS_hidden.h,
lib/HTS_label.c, lib/HTS_misc.c, lib/HTS_model.c,
lib/HTS_pstream.c, lib/HTS_sstream.c, lib/HTS_vocoder.c:
Re-construction to support new HTS voice format.
2012-12-06 17:06 uratec
* include/HTS_engine.h, lib/HTS_engine.c: Change volume unit to DB.
2012-06-26 22:39 uratec
* lib/HTS_sstream.c: Fix check function for the interpolation
weight.
2012-06-11 22:48 uratec
* include/HTS_engine.h, lib/HTS_engine.c, lib/HTS_gstream.c,
lib/HTS_vocoder.c: add HTS_Engine_get_nsample() and
HTS_Engine_get_speech().
2012-05-29 09:28 uratec
* lib/HTS_sstream.c: optimize the functions which check the
interpolation weight
2012-05-29 09:26 uratec
* bin/hts_engine.c: fix stream index for GV
2012-01-02 13:49 uratec
* ChangeLog, lib/HTS_sstream.c: Fix a bug in -vp option.
2011-12-20 23:46 uratec
* AUTHORS, ChangeLog, README: Fix documents.
2011-12-20 13:18 uratec
* ChangeLog, include/HTS_engine.h: Fix macro
2011-12-20 11:24 uratec
* ChangeLog, NEWS, README, configure.ac, include/HTS_engine.h:
Update documents to version 1.06
2011-12-20 11:21 uratec
* lib/HTS_misc.c: Fix a tiny bug of file loading
2011-12-12 13:02 uratec
* ChangeLog, include/HTS_engine.h, lib/HTS_engine.c,
lib/HTS_gstream.c, lib/HTS_hidden.h, lib/HTS_label.c,
lib/HTS_misc.c, lib/HTS_model.c, lib/HTS_pstream.c,
lib/HTS_sstream.c, lib/HTS_vocoder.c: Change many function from
void to boolean.
2011-12-12 11:21 uratec
* ChangeLog, bin/hts_engine.c, include/HTS_engine.h,
lib/HTS_audio.c, lib/HTS_engine.c, lib/HTS_gstream.c,
lib/HTS_hidden.h, lib/HTS_label.c, lib/HTS_misc.c,
lib/HTS_model.c, lib/HTS_pstream.c, lib/HTS_sstream.c,
lib/HTS_vocoder.c: Change source format.
2011-12-12 11:15 uratec
* ChangeLog, bin/hts_engine.c, include/HTS_engine.h,
lib/HTS_engine.c, lib/HTS_hidden.h, lib/HTS_label.c,
lib/HTS_misc.c, lib/HTS_model.c, lib/HTS_sstream.c: Add FILE
wrapper. Modify state duration calculation.
2011-08-10 21:16 uratec
* ChangeLog, configure.ac, lib/HTS_label.c: fix a small bug in
label loader.
2011-08-10 21:14 uratec
* lib/HTS_audio.c: remove warning message of PortAudio.
2011-07-07 08:05 uratec
* ChangeLog, NEWS, README, configure.ac, include/HTS_engine.h,
lib/HTS_engine.c: fix a tiny bug. update all documents to 1.05.
2011-06-16 13:31 uratec
* COPYING, ChangeLog, README, configure.ac, bin/hts_engine.c,
include/HTS_engine.h, lib/HTS_audio.c, lib/HTS_engine.c,
lib/HTS_gstream.c, lib/HTS_hidden.h, lib/HTS_label.c,
lib/HTS_misc.c, lib/HTS_model.c, lib/HTS_pstream.c,
lib/HTS_sstream.c, lib/HTS_vocoder.c: Add PortAudio functions for
audio output.
2010-12-27 12:37 uratec
* ChangeLog, bin/hts_engine.c, include/HTS_engine.h,
lib/HTS_gstream.c, lib/HTS_vocoder.c: Avoid alloc and free for
MLSA filter: suggested by Nicholas Volk.
2010-12-18 15:57 uratec
* ChangeLog, README: modify spaces in readme.
2010-12-13 23:21 uratec
* ChangeLog, README: Update README.
2010-12-12 21:50 uratec
* ChangeLog, README, bin/hts_engine.c, include/HTS_engine.h,
lib/HTS_audio.c, lib/HTS_engine.c, lib/HTS_gstream.c,
lib/HTS_hidden.h, lib/HTS_label.c, lib/HTS_misc.c,
lib/HTS_model.c, lib/HTS_pstream.c, lib/HTS_sstream.c,
lib/HTS_vocoder.c: Update all documents.
2010-12-12 17:36 uratec
* AUTHORS, COPYING, ChangeLog, README: Update documents.
2010-12-12 17:09 uratec
* ChangeLog, README: Fix a typo.
2010-12-09 20:45 uratec
* ChangeLog, include/HTS_engine.h, lib/HTS_engine.c: Add
HTS_Engine_get_nstream function.
2010-12-09 19:52 uratec
* ChangeLog, NEWS, bin/hts_engine.c, include/HTS_engine.h,
lib/HTS_engine.c, lib/HTS_gstream.c, lib/HTS_hidden.h,
lib/HTS_vocoder.c: Add low-pass filter stream.
2010-10-25 16:36 uratec
* ChangeLog, include/HTS_engine.h, lib/HTS_label.c,
lib/HTS_model.c: Remove warning for cygwin compiler.
2010-10-15 14:15 uratec
* ChangeLog, NEWS, README, configure.ac, include/HTS_engine.h:
update all documents for version 1.04.
2010-10-15 14:02 uratec
* ChangeLog, bin/hts_engine.c, include/HTS_engine.h,
lib/HTS_engine.c, lib/HTS_hidden.h, lib/HTS_pstream.c: Change
definition of GV weights.
2010-10-14 00:28 uratec
* ChangeLog, bin/hts_engine.c, include/HTS_engine.h,
lib/HTS_audio.c, lib/HTS_engine.c, lib/HTS_gstream.c,
lib/HTS_hidden.h, lib/HTS_label.c, lib/HTS_misc.c,
lib/HTS_model.c, lib/HTS_pstream.c, lib/HTS_sstream.c,
lib/HTS_vocoder.c: Accept C++ compiler.
2010-10-13 23:21 uratec
* ChangeLog, include/HTS_engine.h, lib/HTS_engine.c: Add functions:
HTS_Engine_get_sampling_rate, HTS_Engine_get_fperiod,
HTS_Engine_get_total_state, HTS_Engine_set_state_mean,
HTS_Engine_get_state_mean, HTS_Engine_get_state_duration, and
HTS_Engine_get_nstate.
2010-10-12 23:09 uratec
* ChangeLog, lib/HTS_gstream.c: Fix a tiny bug.
2010-10-12 22:54 uratec
* ChangeLog, include/HTS_engine.h, lib/HTS_engine.c,
lib/HTS_gstream.c, lib/HTS_vocoder.c: add barge-in function and
volume controller.
2010-09-13 18:51 uratec
* ChangeLog, bin/Makefile.mak, bin/hts_engine.c,
include/HTS_engine.h, lib/HTS_engine.c, lib/HTS_sstream.c,
lib/Makefile.mak: Fix a tiny bug: unify type of 'stage' value.
2010-04-28 13:30 uratec
* ChangeLog, lib/HTS_pstream.c: Fix a bug suggested by Yu Sansuo:
change step in parameter generation using gv.
2010-04-20 00:38 uratec
* ChangeLog, lib/HTS_engine.c: Fix a small typo suggested by oaomly
voooo.
2010-04-19 10:18 uratec
* ChangeLog, README: Update README for version 1.03.
2010-04-08 14:20 uratec
* ChangeLog, NEWS: Update 'NEWS' for version 1.03.
2010-04-08 14:15 uratec
* COPYING, ChangeLog, README, configure.ac, bin/hts_engine.c,
include/HTS_engine.h, lib/HTS_audio.c, lib/HTS_engine.c,
lib/HTS_gstream.c, lib/HTS_hidden.h, lib/HTS_label.c,
lib/HTS_misc.c, lib/HTS_model.c, lib/HTS_pstream.c,
lib/HTS_sstream.c, lib/HTS_vocoder.c: Add '-z' option to control
audio buffer size. Update all description for verion 1.03.
2010-02-17 22:13 uratec
* ChangeLog, lib/HTS_model.c: Fix a small bug for new format of PDF
files.
2010-01-26 10:32 uratec
* ChangeLog, lib/HTS_model.c: Change *.pdf file format in CM
command
2009-12-17 00:17 uratec
* ChangeLog, INSTALL, NEWS, README, configure.ac,
include/HTS_engine.h, lib/HTS_label.c, lib/HTS_sstream.c: update
all documents to version 1.02. bug fix : misalignment for
singing voice synthesis.
2009-12-02 01:21 uratec
* ChangeLog, bin/hts_engine.c: small simplification of help
message.
2009-12-01 21:32 uratec
* ChangeLog, include/HTS_engine.h, lib/HTS_engine.c,
lib/HTS_model.c: Add information of type of GV to log file.
2009-12-01 21:00 uratec
* ChangeLog, bin/hts_engine.c, include/HTS_engine.h,
lib/HTS_engine.c, lib/HTS_model.c, lib/HTS_pstream.c,
lib/HTS_sstream.c: Add function of context-dependent GV without
silent and pause phoneme.
2009-12-01 19:06 uratec
* AUTHORS, COPYING, ChangeLog, INSTALL, README, configure.ac,
bin/hts_engine.c, include/HTS_engine.h, lib/HTS_audio.c,
lib/HTS_engine.c, lib/HTS_gstream.c, lib/HTS_hidden.h,
lib/HTS_label.c, lib/HTS_misc.c, lib/HTS_model.c,
lib/HTS_pstream.c, lib/HTS_sstream.c, lib/HTS_vocoder.c: Revice
all documents and copyrights. Change F0 modification to
half-tone. Fix a bug about speaker interpolation weight=0.0.
2009-11-03 18:07 uratec
* bin/hts_engine.c, include/HTS_engine.h, lib/HTS_label.c,
lib/HTS_model.c, lib/HTS_pstream.c, lib/HTS_sstream.c,
lib/HTS_vocoder.c: Fix bug: First and final delta calculation in
parameter generation step. Add func.: Advanced label reader for
singing voice synthesis. Fix typo: In help message.
2009-09-04 02:20 uratec
* include/HTS_engine.h, lib/HTS_model.c: If there is not tree,
engine stop with error output.
2009-06-01 13:57 uratec
* bin/hts_engine.c, include/HTS_engine.h, lib/HTS_engine.c,
lib/HTS_model.c: Add many information to
HTS_Enging_save_information().
2009-02-26 20:19 uratec
* Makefile.mak: Remove description of version from Makefile.mak.
2009-02-26 20:15 uratec
* configure.ac: Fix small bug for autoconf in cygwin.
2009-02-03 17:56 uratec
* Makefile.am, configure.ac, bin/Makefile.am, bin/hts_engine.c,
lib/HTS_audio.c, lib/Makefile.am, include/HTS_engine.h: Remove
'--enable-audio-win32' and '--enable-audio-wince' options. Add
compiler checker (WIN32/WINCE/CYGWIN/MIGW) for using audio device
in win32/wince.
2009-02-03 17:45 uratec
* Makefile.mak, bin/Makefile.mak, lib/Makefile.mak: ***
Keywords were replaced. ***
2009-02-03 17:44 uratec
* Makefile.mak, bin/Makefile.mak, lib/Makefile.mak: Add
Makefile.mak for 'nmake' in Visual C++.
2009-01-07 20:38 uratec
* lib/HTS_model.c: A bug in HTS_model.c. This bug causes
segmentation fault when a tree have only one leaf.
2008-11-20 16:13 uratec
* lib/HTS_sstream.c: use variance to determine frame length.
2008-09-29 13:19 uratec
* lib/HTS_engine.c, include/HTS_engine.h, ChangeLog: add
HTS_Engine_get_audio_buff_size().
2008-09-29 13:02 uratec
* ChangeLog: Fix suggested by Nicholas Volk: fix an overflow
problem (-32768 <= short <= 32767).
2008-09-29 12:58 uratec
* lib/HTS_vocoder.c: Fix suggested by Nicholas Volk: fix an
overflow problem (-32768 <= short <= 32767).
2008-09-29 11:51 uratec
* ChangeLog: [no log message]
2008-09-29 11:46 uratec
* lib/HTS_pstream.c: Fix suggested by Nicholas Volk: fix a minor
bug.
2008-08-29 15:07 uratec
* .cvsignore, ChangeLog: Fix suggested by Nicholas Volk: fix a bug
in HTS_Vocoder_synthesize().
2008-08-29 14:57 uratec
* lib/HTS_vocoder.c: Fix suggested by Nicholas Volk: fix a bug in
HTS_Vocoder_synthesize().
2008-08-29 14:49 uratec
* lib/HTS_vocoder.c: Fix suggested by Nicholas Volk: speed up
mc2b().
2008-07-30 13:34 uratec
* INSTALL, Makefile.am, NEWS, README: update 1.00 -> 1.01.
2008-07-29 14:22 uratec
* README, configure.ac, lib/HTS_gstream.c, lib/HTS_vocoder.c,
lib/HTS_audio.c, lib/HTS_hidden.h, lib/HTS_engine.c,
lib/HTS_misc.c, lib/HTS_pstream.c, lib/HTS_sstream.c,
bin/hts_engine.c, include/HTS_engine.h, lib/HTS_label.c,
lib/HTS_model.c: update 1.00 -> 1.01. remove /* $Id: XXX.c,v
1.25 200X/XX/XX XX:XX:XX uratec Exp $ */.
2008-07-23 18:44 uratec
* README, bin/hts_engine.c, lib/HTS_audio.c, lib/HTS_engine.c,
lib/HTS_gstream.c, lib/HTS_hidden.h, lib/HTS_label.c,
lib/HTS_misc.c, lib/HTS_model.c, lib/HTS_pstream.c,
lib/HTS_sstream.c, lib/HTS_vocoder.c, include/HTS_engine.h:
change address from http://hts.sp.nitech.ac.jp/ to
http://hts-engine.sourceforge.net/. remove hts_engine_API.pdf.
Fix suggested by Alexis Moinet: change frame type from "int" to
"double".
2008-07-15 20:05 uratec
* bin/hts_engine.c, include/HTS_engine.h, lib/HTS_audio.c,
lib/HTS_engine.c, lib/HTS_gstream.c, lib/HTS_hidden.h,
lib/HTS_label.c, lib/HTS_misc.c, lib/HTS_model.c,
lib/HTS_pstream.c, lib/HTS_sstream.c, lib/HTS_vocoder.c: change
address from http://hts.sp.nitech.ac.jp/ to
http://hts-engine.sourceforge.net/.
2008-07-15 20:04 uratec
* INSTALL, README, AUTHORS, COPYING, Makefile.am, NEWS,
bin/Makefile.am, lib/Makefile.am: *** Keywords were replaced. ***
2008-07-08 19:13 uratec
* INSTALL, README, .cvsignore, NEWS, configure.ac, AUTHORS,
COPYING, Makefile.am, lib/HTS_vocoder.c, lib/.cvsignore,
lib/HTS_engine.c, lib/HTS_sstream.c, lib/Makefile.am,
lib/HTS_gstream.c, lib/HTS_hidden.h, lib/HTS_model.c,
lib/HTS_audio.c, lib/HTS_label.c, lib/HTS_misc.c,
lib/HTS_pstream.c, bin/.cvsignore, bin/Makefile.am,
bin/hts_engine.c, config/.cvsignore, include/HTS_engine.h:
initialize hts_engine_API.

20
3rdparty/hts_engine_API/INSTALL vendored Normal file
View File

@@ -0,0 +1,20 @@
Installation Instructions
*************************
1. After unpacking the tar.gz file, cd to the hts_engine API directory.
2. Run configure script with appropriate options.
% ./configure
For detail, please see.
% ./configure --help
3. Run make.
% make
4. Install library and binary.
% make install

12
3rdparty/hts_engine_API/Makefile.am vendored Normal file
View File

@@ -0,0 +1,12 @@
EXTRA_DIST = AUTHORS COPYING ChangeLog INSTALL NEWS README Makefile.mak
SUBDIRS = lib bin
include_HEADERS = include/HTS_engine.h
DISTCLEANFILES = *.log *.out *~ config/*~ include/*~
MAINTAINERCLEANFILES = aclocal.m4 configure Makefile.in config/compile \
config/config.guess config/config.sub config/depcomp \
config/install-sh config/missing

827
3rdparty/hts_engine_API/Makefile.in vendored Normal file
View File

@@ -0,0 +1,827 @@
# Makefile.in generated by automake 1.15 from Makefile.am.
# @configure_input@
# Copyright (C) 1994-2014 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
@SET_MAKE@
VPATH = @srcdir@
am__is_gnu_make = { \
if test -z '$(MAKELEVEL)'; then \
false; \
elif test -n '$(MAKE_HOST)'; then \
true; \
elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
true; \
else \
false; \
fi; \
}
am__make_running_with_option = \
case $${target_option-} in \
?) ;; \
*) echo "am__make_running_with_option: internal error: invalid" \
"target option '$${target_option-}' specified" >&2; \
exit 1;; \
esac; \
has_opt=no; \
sane_makeflags=$$MAKEFLAGS; \
if $(am__is_gnu_make); then \
sane_makeflags=$$MFLAGS; \
else \
case $$MAKEFLAGS in \
*\\[\ \ ]*) \
bs=\\; \
sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
| sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \
esac; \
fi; \
skip_next=no; \
strip_trailopt () \
{ \
flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
}; \
for flg in $$sane_makeflags; do \
test $$skip_next = yes && { skip_next=no; continue; }; \
case $$flg in \
*=*|--*) continue;; \
-*I) strip_trailopt 'I'; skip_next=yes;; \
-*I?*) strip_trailopt 'I';; \
-*O) strip_trailopt 'O'; skip_next=yes;; \
-*O?*) strip_trailopt 'O';; \
-*l) strip_trailopt 'l'; skip_next=yes;; \
-*l?*) strip_trailopt 'l';; \
-[dEDm]) skip_next=yes;; \
-[JT]) skip_next=yes;; \
esac; \
case $$flg in \
*$$target_option*) has_opt=yes; break;; \
esac; \
done; \
test $$has_opt = yes
am__make_dryrun = (target_option=n; $(am__make_running_with_option))
am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
pkgdatadir = $(datadir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkglibexecdir = $(libexecdir)/@PACKAGE@
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
install_sh_DATA = $(install_sh) -c -m 644
install_sh_PROGRAM = $(install_sh) -c
install_sh_SCRIPT = $(install_sh) -c
INSTALL_HEADER = $(INSTALL_DATA)
transform = $(program_transform_name)
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
subdir = .
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
DIST_COMMON = $(srcdir)/Makefile.am $(top_srcdir)/configure \
$(am__configure_deps) $(include_HEADERS) $(am__DIST_COMMON)
am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \
configure.lineno config.status.lineno
mkinstalldirs = $(install_sh) -d
CONFIG_CLEAN_FILES =
CONFIG_CLEAN_VPATH_FILES =
AM_V_P = $(am__v_P_@AM_V@)
am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
am__v_P_0 = false
am__v_P_1 = :
AM_V_GEN = $(am__v_GEN_@AM_V@)
am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
am__v_GEN_0 = @echo " GEN " $@;
am__v_GEN_1 =
AM_V_at = $(am__v_at_@AM_V@)
am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
am__v_at_0 = @
am__v_at_1 =
SOURCES =
DIST_SOURCES =
RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \
ctags-recursive dvi-recursive html-recursive info-recursive \
install-data-recursive install-dvi-recursive \
install-exec-recursive install-html-recursive \
install-info-recursive install-pdf-recursive \
install-ps-recursive install-recursive installcheck-recursive \
installdirs-recursive pdf-recursive ps-recursive \
tags-recursive uninstall-recursive
am__can_run_installinfo = \
case $$AM_UPDATE_INFO_DIR in \
n|no|NO) false;; \
*) (install-info --version) >/dev/null 2>&1;; \
esac
am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
am__vpath_adj = case $$p in \
$(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
*) f=$$p;; \
esac;
am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
am__install_max = 40
am__nobase_strip_setup = \
srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
am__nobase_strip = \
for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
am__nobase_list = $(am__nobase_strip_setup); \
for p in $$list; do echo "$$p $$p"; done | \
sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
$(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
if (++n[$$2] == $(am__install_max)) \
{ print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
END { for (dir in files) print dir, files[dir] }'
am__base_list = \
sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
am__uninstall_files_from_dir = { \
test -z "$$files" \
|| { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \
|| { echo " ( cd '$$dir' && rm -f" $$files ")"; \
$(am__cd) "$$dir" && rm -f $$files; }; \
}
am__installdirs = "$(DESTDIR)$(includedir)"
HEADERS = $(include_HEADERS)
RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \
distclean-recursive maintainer-clean-recursive
am__recursive_targets = \
$(RECURSIVE_TARGETS) \
$(RECURSIVE_CLEAN_TARGETS) \
$(am__extra_recursive_targets)
AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \
cscope distdir dist dist-all distcheck
am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
# Read a list of newline-separated strings from the standard input,
# and print each of them once, without duplicates. Input order is
# *not* preserved.
am__uniquify_input = $(AWK) '\
BEGIN { nonempty = 0; } \
{ items[$$0] = 1; nonempty = 1; } \
END { if (nonempty) { for (i in items) print i; }; } \
'
# Make sure the list of sources is unique. This is necessary because,
# e.g., the same source file might be shared among _SOURCES variables
# for different programs/libraries.
am__define_uniq_tagged_files = \
list='$(am__tagged_files)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | $(am__uniquify_input)`
ETAGS = etags
CTAGS = ctags
CSCOPE = cscope
DIST_SUBDIRS = $(SUBDIRS)
am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/config/compile \
$(top_srcdir)/config/config.guess \
$(top_srcdir)/config/config.sub \
$(top_srcdir)/config/install-sh $(top_srcdir)/config/missing \
AUTHORS COPYING ChangeLog INSTALL NEWS README config/compile \
config/config.guess config/config.sub config/depcomp \
config/install-sh config/missing
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
distdir = $(PACKAGE)-$(VERSION)
top_distdir = $(distdir)
am__remove_distdir = \
if test -d "$(distdir)"; then \
find "$(distdir)" -type d ! -perm -200 -exec chmod u+w {} ';' \
&& rm -rf "$(distdir)" \
|| { sleep 5 && rm -rf "$(distdir)"; }; \
else :; fi
am__post_remove_distdir = $(am__remove_distdir)
am__relativize = \
dir0=`pwd`; \
sed_first='s,^\([^/]*\)/.*$$,\1,'; \
sed_rest='s,^[^/]*/*,,'; \
sed_last='s,^.*/\([^/]*\)$$,\1,'; \
sed_butlast='s,/*[^/]*$$,,'; \
while test -n "$$dir1"; do \
first=`echo "$$dir1" | sed -e "$$sed_first"`; \
if test "$$first" != "."; then \
if test "$$first" = ".."; then \
dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \
dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \
else \
first2=`echo "$$dir2" | sed -e "$$sed_first"`; \
if test "$$first2" = "$$first"; then \
dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \
else \
dir2="../$$dir2"; \
fi; \
dir0="$$dir0"/"$$first"; \
fi; \
fi; \
dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \
done; \
reldir="$$dir2"
DIST_ARCHIVES = $(distdir).tar.gz
GZIP_ENV = --best
DIST_TARGETS = dist-gzip
distuninstallcheck_listfiles = find . -type f -print
am__distuninstallcheck_listfiles = $(distuninstallcheck_listfiles) \
| sed 's|^\./|$(prefix)/|' | grep -v '$(infodir)/dir$$'
distcleancheck_listfiles = find . -type f -print
ACLOCAL = @ACLOCAL@
AMTAR = @AMTAR@
AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
AR = @AR@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
AWK = @AWK@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
GREP = @GREP@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LDFLAGS = @LDFLAGS@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
LTLIBOBJS = @LTLIBOBJS@
MAKEINFO = @MAKEINFO@
MKDIR_P = @MKDIR_P@
OBJEXT = @OBJEXT@
PACKAGE = @PACKAGE@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_URL = @PACKAGE_URL@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
RANLIB = @RANLIB@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
VERSION = @VERSION@
abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
abs_top_builddir = @abs_top_builddir@
abs_top_srcdir = @abs_top_srcdir@
ac_ct_CC = @ac_ct_CC@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
am__quote = @am__quote@
am__tar = @am__tar@
am__untar = @am__untar@
bindir = @bindir@
build = @build@
build_alias = @build_alias@
build_cpu = @build_cpu@
build_os = @build_os@
build_vendor = @build_vendor@
builddir = @builddir@
datadir = @datadir@
datarootdir = @datarootdir@
docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
host_os = @host_os@
host_vendor = @host_vendor@
htmldir = @htmldir@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
libdir = @libdir@
libexecdir = @libexecdir@
localedir = @localedir@
localstatedir = @localstatedir@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
sysconfdir = @sysconfdir@
target_alias = @target_alias@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
EXTRA_DIST = AUTHORS COPYING ChangeLog INSTALL NEWS README Makefile.mak
SUBDIRS = lib bin
include_HEADERS = include/HTS_engine.h
DISTCLEANFILES = *.log *.out *~ config/*~ include/*~
MAINTAINERCLEANFILES = aclocal.m4 configure Makefile.in config/compile \
config/config.guess config/config.sub config/depcomp \
config/install-sh config/missing
all: all-recursive
.SUFFIXES:
am--refresh: Makefile
@:
$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
echo ' cd $(srcdir) && $(AUTOMAKE) --gnu'; \
$(am__cd) $(srcdir) && $(AUTOMAKE) --gnu \
&& exit 0; \
exit 1;; \
esac; \
done; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu Makefile'; \
$(am__cd) $(top_srcdir) && \
$(AUTOMAKE) --gnu Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
*config.status*) \
echo ' $(SHELL) ./config.status'; \
$(SHELL) ./config.status;; \
*) \
echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)'; \
cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe);; \
esac;
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
$(SHELL) ./config.status --recheck
$(top_srcdir)/configure: $(am__configure_deps)
$(am__cd) $(srcdir) && $(AUTOCONF)
$(ACLOCAL_M4): $(am__aclocal_m4_deps)
$(am__cd) $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS)
$(am__aclocal_m4_deps):
install-includeHEADERS: $(include_HEADERS)
@$(NORMAL_INSTALL)
@list='$(include_HEADERS)'; test -n "$(includedir)" || list=; \
if test -n "$$list"; then \
echo " $(MKDIR_P) '$(DESTDIR)$(includedir)'"; \
$(MKDIR_P) "$(DESTDIR)$(includedir)" || exit 1; \
fi; \
for p in $$list; do \
if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
echo "$$d$$p"; \
done | $(am__base_list) | \
while read files; do \
echo " $(INSTALL_HEADER) $$files '$(DESTDIR)$(includedir)'"; \
$(INSTALL_HEADER) $$files "$(DESTDIR)$(includedir)" || exit $$?; \
done
uninstall-includeHEADERS:
@$(NORMAL_UNINSTALL)
@list='$(include_HEADERS)'; test -n "$(includedir)" || list=; \
files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
dir='$(DESTDIR)$(includedir)'; $(am__uninstall_files_from_dir)
# This directory's subdirectories are mostly independent; you can cd
# into them and run 'make' without going through this Makefile.
# To change the values of 'make' variables: instead of editing Makefiles,
# (1) if the variable is set in 'config.status', edit 'config.status'
# (which will cause the Makefiles to be regenerated when you run 'make');
# (2) otherwise, pass the desired values on the 'make' command line.
$(am__recursive_targets):
@fail=; \
if $(am__make_keepgoing); then \
failcom='fail=yes'; \
else \
failcom='exit 1'; \
fi; \
dot_seen=no; \
target=`echo $@ | sed s/-recursive//`; \
case "$@" in \
distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \
*) list='$(SUBDIRS)' ;; \
esac; \
for subdir in $$list; do \
echo "Making $$target in $$subdir"; \
if test "$$subdir" = "."; then \
dot_seen=yes; \
local_target="$$target-am"; \
else \
local_target="$$target"; \
fi; \
($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
|| eval $$failcom; \
done; \
if test "$$dot_seen" = "no"; then \
$(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \
fi; test -z "$$fail"
ID: $(am__tagged_files)
$(am__define_uniq_tagged_files); mkid -fID $$unique
tags: tags-recursive
TAGS: tags
tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
set x; \
here=`pwd`; \
if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \
include_option=--etags-include; \
empty_fix=.; \
else \
include_option=--include; \
empty_fix=; \
fi; \
list='$(SUBDIRS)'; for subdir in $$list; do \
if test "$$subdir" = .; then :; else \
test ! -f $$subdir/TAGS || \
set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \
fi; \
done; \
$(am__define_uniq_tagged_files); \
shift; \
if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
test -n "$$unique" || unique=$$empty_fix; \
if test $$# -gt 0; then \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
"$$@" $$unique; \
else \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
$$unique; \
fi; \
fi
ctags: ctags-recursive
CTAGS: ctags
ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
$(am__define_uniq_tagged_files); \
test -z "$(CTAGS_ARGS)$$unique" \
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
$$unique
GTAGS:
here=`$(am__cd) $(top_builddir) && pwd` \
&& $(am__cd) $(top_srcdir) \
&& gtags -i $(GTAGS_ARGS) "$$here"
cscope: cscope.files
test ! -s cscope.files \
|| $(CSCOPE) -b -q $(AM_CSCOPEFLAGS) $(CSCOPEFLAGS) -i cscope.files $(CSCOPE_ARGS)
clean-cscope:
-rm -f cscope.files
cscope.files: clean-cscope cscopelist
cscopelist: cscopelist-recursive
cscopelist-am: $(am__tagged_files)
list='$(am__tagged_files)'; \
case "$(srcdir)" in \
[\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
*) sdir=$(subdir)/$(srcdir) ;; \
esac; \
for i in $$list; do \
if test -f "$$i"; then \
echo "$(subdir)/$$i"; \
else \
echo "$$sdir/$$i"; \
fi; \
done >> $(top_builddir)/cscope.files
distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
-rm -f cscope.out cscope.in.out cscope.po.out cscope.files
distdir: $(DISTFILES)
$(am__remove_distdir)
test -d "$(distdir)" || mkdir "$(distdir)"
@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
list='$(DISTFILES)'; \
dist_files=`for file in $$list; do echo $$file; done | \
sed -e "s|^$$srcdirstrip/||;t" \
-e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
case $$dist_files in \
*/*) $(MKDIR_P) `echo "$$dist_files" | \
sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
sort -u` ;; \
esac; \
for file in $$dist_files; do \
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
if test -d $$d/$$file; then \
dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
if test -d "$(distdir)/$$file"; then \
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
fi; \
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
fi; \
cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
else \
test -f "$(distdir)/$$file" \
|| cp -p $$d/$$file "$(distdir)/$$file" \
|| exit 1; \
fi; \
done
@list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
if test "$$subdir" = .; then :; else \
$(am__make_dryrun) \
|| test -d "$(distdir)/$$subdir" \
|| $(MKDIR_P) "$(distdir)/$$subdir" \
|| exit 1; \
dir1=$$subdir; dir2="$(distdir)/$$subdir"; \
$(am__relativize); \
new_distdir=$$reldir; \
dir1=$$subdir; dir2="$(top_distdir)"; \
$(am__relativize); \
new_top_distdir=$$reldir; \
echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \
echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \
($(am__cd) $$subdir && \
$(MAKE) $(AM_MAKEFLAGS) \
top_distdir="$$new_top_distdir" \
distdir="$$new_distdir" \
am__remove_distdir=: \
am__skip_length_check=: \
am__skip_mode_fix=: \
distdir) \
|| exit 1; \
fi; \
done
-test -n "$(am__skip_mode_fix)" \
|| find "$(distdir)" -type d ! -perm -755 \
-exec chmod u+rwx,go+rx {} \; -o \
! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \
! -type d ! -perm -400 -exec chmod a+r {} \; -o \
! -type d ! -perm -444 -exec $(install_sh) -c -m a+r {} {} \; \
|| chmod -R a+r "$(distdir)"
dist-gzip: distdir
tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
$(am__post_remove_distdir)
dist-bzip2: distdir
tardir=$(distdir) && $(am__tar) | BZIP2=$${BZIP2--9} bzip2 -c >$(distdir).tar.bz2
$(am__post_remove_distdir)
dist-lzip: distdir
tardir=$(distdir) && $(am__tar) | lzip -c $${LZIP_OPT--9} >$(distdir).tar.lz
$(am__post_remove_distdir)
dist-xz: distdir
tardir=$(distdir) && $(am__tar) | XZ_OPT=$${XZ_OPT--e} xz -c >$(distdir).tar.xz
$(am__post_remove_distdir)
dist-tarZ: distdir
@echo WARNING: "Support for distribution archives compressed with" \
"legacy program 'compress' is deprecated." >&2
@echo WARNING: "It will be removed altogether in Automake 2.0" >&2
tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z
$(am__post_remove_distdir)
dist-shar: distdir
@echo WARNING: "Support for shar distribution archives is" \
"deprecated." >&2
@echo WARNING: "It will be removed altogether in Automake 2.0" >&2
shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz
$(am__post_remove_distdir)
dist-zip: distdir
-rm -f $(distdir).zip
zip -rq $(distdir).zip $(distdir)
$(am__post_remove_distdir)
dist dist-all:
$(MAKE) $(AM_MAKEFLAGS) $(DIST_TARGETS) am__post_remove_distdir='@:'
$(am__post_remove_distdir)
# This target untars the dist file and tries a VPATH configuration. Then
# it guarantees that the distribution is self-contained by making another
# tarfile.
distcheck: dist
case '$(DIST_ARCHIVES)' in \
*.tar.gz*) \
GZIP=$(GZIP_ENV) gzip -dc $(distdir).tar.gz | $(am__untar) ;;\
*.tar.bz2*) \
bzip2 -dc $(distdir).tar.bz2 | $(am__untar) ;;\
*.tar.lz*) \
lzip -dc $(distdir).tar.lz | $(am__untar) ;;\
*.tar.xz*) \
xz -dc $(distdir).tar.xz | $(am__untar) ;;\
*.tar.Z*) \
uncompress -c $(distdir).tar.Z | $(am__untar) ;;\
*.shar.gz*) \
GZIP=$(GZIP_ENV) gzip -dc $(distdir).shar.gz | unshar ;;\
*.zip*) \
unzip $(distdir).zip ;;\
esac
chmod -R a-w $(distdir)
chmod u+w $(distdir)
mkdir $(distdir)/_build $(distdir)/_build/sub $(distdir)/_inst
chmod a-w $(distdir)
test -d $(distdir)/_build || exit 0; \
dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \
&& dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \
&& am__cwd=`pwd` \
&& $(am__cd) $(distdir)/_build/sub \
&& ../../configure \
$(AM_DISTCHECK_CONFIGURE_FLAGS) \
$(DISTCHECK_CONFIGURE_FLAGS) \
--srcdir=../.. --prefix="$$dc_install_base" \
&& $(MAKE) $(AM_MAKEFLAGS) \
&& $(MAKE) $(AM_MAKEFLAGS) dvi \
&& $(MAKE) $(AM_MAKEFLAGS) check \
&& $(MAKE) $(AM_MAKEFLAGS) install \
&& $(MAKE) $(AM_MAKEFLAGS) installcheck \
&& $(MAKE) $(AM_MAKEFLAGS) uninstall \
&& $(MAKE) $(AM_MAKEFLAGS) distuninstallcheck_dir="$$dc_install_base" \
distuninstallcheck \
&& chmod -R a-w "$$dc_install_base" \
&& ({ \
(cd ../.. && umask 077 && mkdir "$$dc_destdir") \
&& $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" install \
&& $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" uninstall \
&& $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" \
distuninstallcheck_dir="$$dc_destdir" distuninstallcheck; \
} || { rm -rf "$$dc_destdir"; exit 1; }) \
&& rm -rf "$$dc_destdir" \
&& $(MAKE) $(AM_MAKEFLAGS) dist \
&& rm -rf $(DIST_ARCHIVES) \
&& $(MAKE) $(AM_MAKEFLAGS) distcleancheck \
&& cd "$$am__cwd" \
|| exit 1
$(am__post_remove_distdir)
@(echo "$(distdir) archives ready for distribution: "; \
list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \
sed -e 1h -e 1s/./=/g -e 1p -e 1x -e '$$p' -e '$$x'
distuninstallcheck:
@test -n '$(distuninstallcheck_dir)' || { \
echo 'ERROR: trying to run $@ with an empty' \
'$$(distuninstallcheck_dir)' >&2; \
exit 1; \
}; \
$(am__cd) '$(distuninstallcheck_dir)' || { \
echo 'ERROR: cannot chdir into $(distuninstallcheck_dir)' >&2; \
exit 1; \
}; \
test `$(am__distuninstallcheck_listfiles) | wc -l` -eq 0 \
|| { echo "ERROR: files left after uninstall:" ; \
if test -n "$(DESTDIR)"; then \
echo " (check DESTDIR support)"; \
fi ; \
$(distuninstallcheck_listfiles) ; \
exit 1; } >&2
distcleancheck: distclean
@if test '$(srcdir)' = . ; then \
echo "ERROR: distcleancheck can only run from a VPATH build" ; \
exit 1 ; \
fi
@test `$(distcleancheck_listfiles) | wc -l` -eq 0 \
|| { echo "ERROR: files left in build directory after distclean:" ; \
$(distcleancheck_listfiles) ; \
exit 1; } >&2
check-am: all-am
check: check-recursive
all-am: Makefile $(HEADERS)
installdirs: installdirs-recursive
installdirs-am:
for dir in "$(DESTDIR)$(includedir)"; do \
test -z "$$dir" || $(MKDIR_P) "$$dir"; \
done
install: install-recursive
install-exec: install-exec-recursive
install-data: install-data-recursive
uninstall: uninstall-recursive
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
installcheck: installcheck-recursive
install-strip:
if test -z '$(STRIP)'; then \
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
install; \
else \
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
"INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
fi
mostlyclean-generic:
clean-generic:
distclean-generic:
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
-test -z "$(DISTCLEANFILES)" || rm -f $(DISTCLEANFILES)
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@echo "it deletes files that may require special tools to rebuild."
-test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES)
clean: clean-recursive
clean-am: clean-generic mostlyclean-am
distclean: distclean-recursive
-rm -f $(am__CONFIG_DISTCLEAN_FILES)
-rm -f Makefile
distclean-am: clean-am distclean-generic distclean-tags
dvi: dvi-recursive
dvi-am:
html: html-recursive
html-am:
info: info-recursive
info-am:
install-data-am: install-includeHEADERS
install-dvi: install-dvi-recursive
install-dvi-am:
install-exec-am:
install-html: install-html-recursive
install-html-am:
install-info: install-info-recursive
install-info-am:
install-man:
install-pdf: install-pdf-recursive
install-pdf-am:
install-ps: install-ps-recursive
install-ps-am:
installcheck-am:
maintainer-clean: maintainer-clean-recursive
-rm -f $(am__CONFIG_DISTCLEAN_FILES)
-rm -rf $(top_srcdir)/autom4te.cache
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-recursive
mostlyclean-am: mostlyclean-generic
pdf: pdf-recursive
pdf-am:
ps: ps-recursive
ps-am:
uninstall-am: uninstall-includeHEADERS
.MAKE: $(am__recursive_targets) install-am install-strip
.PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am \
am--refresh check check-am clean clean-cscope clean-generic \
cscope cscopelist-am ctags ctags-am dist dist-all dist-bzip2 \
dist-gzip dist-lzip dist-shar dist-tarZ dist-xz dist-zip \
distcheck distclean distclean-generic distclean-tags \
distcleancheck distdir distuninstallcheck dvi dvi-am html \
html-am info info-am install install-am install-data \
install-data-am install-dvi install-dvi-am install-exec \
install-exec-am install-html install-html-am \
install-includeHEADERS install-info install-info-am \
install-man install-pdf install-pdf-am install-ps \
install-ps-am install-strip installcheck installcheck-am \
installdirs installdirs-am maintainer-clean \
maintainer-clean-generic mostlyclean mostlyclean-generic pdf \
pdf-am ps ps-am tags tags-am uninstall uninstall-am \
uninstall-includeHEADERS
.PRECIOUS: Makefile
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:

32
3rdparty/hts_engine_API/Makefile.mak vendored Normal file
View File

@@ -0,0 +1,32 @@
INSTALLDIR = C:\hts_engine_API
all:
cd lib
nmake /f Makefile.mak
cd ..
cd bin
nmake /f Makefile.mak
cd ..
clean:
cd lib
nmake /f Makefile.mak clean
cd ..
cd bin
nmake /f Makefile.mak clean
cd ..
install::
@if not exist "$(INSTALLDIR)\lib" mkdir "$(INSTALLDIR)\lib"
cd lib
copy *.lib $(INSTALLDIR)\lib
cd ..
@if not exist "$(INSTALLDIR)\bin" mkdir "$(INSTALLDIR)\bin"
cd bin
copy *.exe $(INSTALLDIR)\bin
cd ..
@if not exist "$(INSTALLDIR)\include" mkdir "$(INSTALLDIR)\include"
cd include
copy *.h $(INSTALLDIR)\include
cd ..

77
3rdparty/hts_engine_API/NEWS vendored Normal file
View File

@@ -0,0 +1,77 @@
Version 1.10:
* bug fixes.
Version 1.09:
* add '-g' option to change volume.
* add some functions to get fullcontext label format and version defined in HTS voice.
* support 64-bit Windows audio.
* bug fixes.
Version 1.08:
* support 64-bit machine.
* re-write excitation function.
* add some functions to get generated parameters and number of frames.
* add some functions for separating synthesis step.
* bug fixes.
Version 1.07:
* support new HTS voice format.
* add LSP postfilter.
* change volume unit to DB.
* add function to get generated speech.
* bug fixes.
Version 1.06:
* modify state duration calculation algorithm.
* change many function from void to boolean.
* change source format.
* bug fixes.
Version 1.05:
* support PortAudio for audio output.
Version 1.04:
* support C++ compiler.
* add low-pass filter stream.
* change definition of GV weights.
* add stop switch.
* add volume controller.
* bug fixes.
Version 1.03:
* add '-z' option to control audio buffer size.
* change PDF file format.
* bug fixes.
Version 1.02:
* context-dependent GV without silent and pause phoneme.
* buffer size control of audio output for Windows.
* makefiles for nmake of VC.
* save detail information.
* support singing voice synthesis.
* bug fixes.
Version 1.01:
* bug fixes.
* transfer site to SourceForge.
Version 1.00:
* bug fixes and performance improvements.
* support linear gain in addition to log gain for LSP-type parameters.
* first stable release.
Version 0.99:
* bug fixes.
* switch license to the New and Simplified BSD license.
Version 0.96:
* bug fixes.
* support flexible model structure.
* support LSP-type parameters.
Version 0.95:
* support GV.
Version 0.9:
* implement API-style hts_engine.
* support speaker-interpolation.

129
3rdparty/hts_engine_API/README vendored Normal file
View File

@@ -0,0 +1,129 @@
===============================================================================
The HMM-Based Speech Synthesis Engine "hts_engine API" version 1.10
release December 25, 2015
The hts_engine API is an API version of hts_engine which has been released
since HTS version 1.1. It has been being developed by the HTS working group
(see "Who we are" below) and some graduate students in Nagoya Institute of
Technology (see "AUTHORS" in the same directory).
*******************************************************************************
Copying
*******************************************************************************
The hts_engine API is released under the Modified BSD license (see
http://www.opensource.org/). Using and distributing this software is free
(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 conditions in the following license:
/* ----------------------------------------------------------------- */
/* The HMM-Based Speech Synthesis Engine "hts_engine API" */
/* developed by HTS Working Group */
/* http://hts-engine.sourceforge.net/ */
/* ----------------------------------------------------------------- */
/* */
/* Copyright (c) 2001-2015 Nagoya Institute of Technology */
/* Department of Computer Science */
/* */
/* 2001-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. */
/* ----------------------------------------------------------------- */
Although this software is free, we still offer no warranties and no
maintenance. We will continue to endeavor to fix bugs and answer queries when
can, but are not in a position to guarantee it. We will consider consultancy if
desired, please contacts us for details.
If you are using the hts_engine API in commercial environments, even though no
license is required, we would be grateful if you let us know as it helps
justify ourselves to our various sponsors. We also strongly encourage you to
* refer to the use of hts_engine API in any publications that use this
software
* report bugs, where possible with bug fixes, that are found
See also "COPYING" file in the current directory for details.
*******************************************************************************
Installation
*******************************************************************************
See "INSTALL" in the same directory for details.
*******************************************************************************
Documentation
*******************************************************************************
Reference manual of hts_engine API is available at
http://hts-engine.sourceforge.net/
*******************************************************************************
Acknowledgements
*******************************************************************************
Keiichi Tokuda
Shinji Sako
Heiga Zen
Keiichiro Oura
Kazuhiro Nakamura
Keijiro Saino
*******************************************************************************
Who we are
*******************************************************************************
The HTS working group is a voluntary group for developing the HMM-Based Speech
Synthesis System. Current members are
Keiichi Tokuda http://www.sp.nitech.ac.jp/~tokuda/
(Produce and Design)
Keiichiro Oura http://www.sp.nitech.ac.jp/~uratec/
(Design and Development, Main Maintainer)
Kei Hashimoto http://www.sp.nitech.ac.jp/~bonanza/
Shinji Takaki http://www.sp.nitech.ac.jp/~k-prr44/
Heiga Zen
Junichi Yamagishi http://homepages.inf.ed.ac.uk/jyamagis/
Tomoki Toda http://spalab.naist.jp/~tomoki/index_e.html
Takashi Nose
Shinji Sako http://www.mmsp.nitech.ac.jp/~sako/
Alan W. Black http://www.cs.cmu.edu/~awb/
and the members are dynamically changing. The current formal contact address of
HTS working group and a mailing list for HTS users can be found at
http://hts.sp.nitech.ac.jp/
===============================================================================

1152
3rdparty/hts_engine_API/aclocal.m4 vendored Normal file

File diff suppressed because it is too large Load Diff

14
3rdparty/hts_engine_API/bin/Makefile.am vendored Normal file
View File

@@ -0,0 +1,14 @@
EXTRA_DIST = Makefile.mak
AM_CPPFLAGS = -I @top_srcdir@/include
bin_PROGRAMS = hts_engine
hts_engine_SOURCES = hts_engine.c
hts_engine_LDADD = ../lib/libHTSEngine.a
DISTCLEANFILES = *.log *.out *~
MAINTAINERCLEANFILES = Makefile.in

578
3rdparty/hts_engine_API/bin/Makefile.in vendored Normal file
View File

@@ -0,0 +1,578 @@
# Makefile.in generated by automake 1.15 from Makefile.am.
# @configure_input@
# Copyright (C) 1994-2014 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
@SET_MAKE@
VPATH = @srcdir@
am__is_gnu_make = { \
if test -z '$(MAKELEVEL)'; then \
false; \
elif test -n '$(MAKE_HOST)'; then \
true; \
elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
true; \
else \
false; \
fi; \
}
am__make_running_with_option = \
case $${target_option-} in \
?) ;; \
*) echo "am__make_running_with_option: internal error: invalid" \
"target option '$${target_option-}' specified" >&2; \
exit 1;; \
esac; \
has_opt=no; \
sane_makeflags=$$MAKEFLAGS; \
if $(am__is_gnu_make); then \
sane_makeflags=$$MFLAGS; \
else \
case $$MAKEFLAGS in \
*\\[\ \ ]*) \
bs=\\; \
sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
| sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \
esac; \
fi; \
skip_next=no; \
strip_trailopt () \
{ \
flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
}; \
for flg in $$sane_makeflags; do \
test $$skip_next = yes && { skip_next=no; continue; }; \
case $$flg in \
*=*|--*) continue;; \
-*I) strip_trailopt 'I'; skip_next=yes;; \
-*I?*) strip_trailopt 'I';; \
-*O) strip_trailopt 'O'; skip_next=yes;; \
-*O?*) strip_trailopt 'O';; \
-*l) strip_trailopt 'l'; skip_next=yes;; \
-*l?*) strip_trailopt 'l';; \
-[dEDm]) skip_next=yes;; \
-[JT]) skip_next=yes;; \
esac; \
case $$flg in \
*$$target_option*) has_opt=yes; break;; \
esac; \
done; \
test $$has_opt = yes
am__make_dryrun = (target_option=n; $(am__make_running_with_option))
am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
pkgdatadir = $(datadir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkglibexecdir = $(libexecdir)/@PACKAGE@
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
install_sh_DATA = $(install_sh) -c -m 644
install_sh_PROGRAM = $(install_sh) -c
install_sh_SCRIPT = $(install_sh) -c
INSTALL_HEADER = $(INSTALL_DATA)
transform = $(program_transform_name)
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
bin_PROGRAMS = hts_engine$(EXEEXT)
subdir = bin
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
mkinstalldirs = $(install_sh) -d
CONFIG_CLEAN_FILES =
CONFIG_CLEAN_VPATH_FILES =
am__installdirs = "$(DESTDIR)$(bindir)"
PROGRAMS = $(bin_PROGRAMS)
am_hts_engine_OBJECTS = hts_engine.$(OBJEXT)
hts_engine_OBJECTS = $(am_hts_engine_OBJECTS)
hts_engine_DEPENDENCIES = ../lib/libHTSEngine.a
AM_V_P = $(am__v_P_@AM_V@)
am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
am__v_P_0 = false
am__v_P_1 = :
AM_V_GEN = $(am__v_GEN_@AM_V@)
am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
am__v_GEN_0 = @echo " GEN " $@;
am__v_GEN_1 =
AM_V_at = $(am__v_at_@AM_V@)
am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
am__v_at_0 = @
am__v_at_1 =
DEFAULT_INCLUDES = -I.@am__isrc@
depcomp = $(SHELL) $(top_srcdir)/config/depcomp
am__depfiles_maybe = depfiles
am__mv = mv -f
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
AM_V_CC = $(am__v_CC_@AM_V@)
am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@)
am__v_CC_0 = @echo " CC " $@;
am__v_CC_1 =
CCLD = $(CC)
LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
AM_V_CCLD = $(am__v_CCLD_@AM_V@)
am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
am__v_CCLD_0 = @echo " CCLD " $@;
am__v_CCLD_1 =
SOURCES = $(hts_engine_SOURCES)
DIST_SOURCES = $(hts_engine_SOURCES)
am__can_run_installinfo = \
case $$AM_UPDATE_INFO_DIR in \
n|no|NO) false;; \
*) (install-info --version) >/dev/null 2>&1;; \
esac
am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
# Read a list of newline-separated strings from the standard input,
# and print each of them once, without duplicates. Input order is
# *not* preserved.
am__uniquify_input = $(AWK) '\
BEGIN { nonempty = 0; } \
{ items[$$0] = 1; nonempty = 1; } \
END { if (nonempty) { for (i in items) print i; }; } \
'
# Make sure the list of sources is unique. This is necessary because,
# e.g., the same source file might be shared among _SOURCES variables
# for different programs/libraries.
am__define_uniq_tagged_files = \
list='$(am__tagged_files)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | $(am__uniquify_input)`
ETAGS = etags
CTAGS = ctags
am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/config/depcomp
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
ACLOCAL = @ACLOCAL@
AMTAR = @AMTAR@
AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
AR = @AR@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
AWK = @AWK@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
GREP = @GREP@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LDFLAGS = @LDFLAGS@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
LTLIBOBJS = @LTLIBOBJS@
MAKEINFO = @MAKEINFO@
MKDIR_P = @MKDIR_P@
OBJEXT = @OBJEXT@
PACKAGE = @PACKAGE@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_URL = @PACKAGE_URL@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
RANLIB = @RANLIB@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
VERSION = @VERSION@
abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
abs_top_builddir = @abs_top_builddir@
abs_top_srcdir = @abs_top_srcdir@
ac_ct_CC = @ac_ct_CC@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
am__quote = @am__quote@
am__tar = @am__tar@
am__untar = @am__untar@
bindir = @bindir@
build = @build@
build_alias = @build_alias@
build_cpu = @build_cpu@
build_os = @build_os@
build_vendor = @build_vendor@
builddir = @builddir@
datadir = @datadir@
datarootdir = @datarootdir@
docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
host_os = @host_os@
host_vendor = @host_vendor@
htmldir = @htmldir@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
libdir = @libdir@
libexecdir = @libexecdir@
localedir = @localedir@
localstatedir = @localstatedir@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
sysconfdir = @sysconfdir@
target_alias = @target_alias@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
EXTRA_DIST = Makefile.mak
AM_CPPFLAGS = -I @top_srcdir@/include
hts_engine_SOURCES = hts_engine.c
hts_engine_LDADD = ../lib/libHTSEngine.a
DISTCLEANFILES = *.log *.out *~
MAINTAINERCLEANFILES = Makefile.in
all: all-am
.SUFFIXES:
.SUFFIXES: .c .o .obj
$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
&& { if test -f $@; then exit 0; else break; fi; }; \
exit 1;; \
esac; \
done; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu bin/Makefile'; \
$(am__cd) $(top_srcdir) && \
$(AUTOMAKE) --gnu bin/Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
*config.status*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
*) \
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
esac;
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(top_srcdir)/configure: $(am__configure_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(ACLOCAL_M4): $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(am__aclocal_m4_deps):
install-binPROGRAMS: $(bin_PROGRAMS)
@$(NORMAL_INSTALL)
@list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \
if test -n "$$list"; then \
echo " $(MKDIR_P) '$(DESTDIR)$(bindir)'"; \
$(MKDIR_P) "$(DESTDIR)$(bindir)" || exit 1; \
fi; \
for p in $$list; do echo "$$p $$p"; done | \
sed 's/$(EXEEXT)$$//' | \
while read p p1; do if test -f $$p \
; then echo "$$p"; echo "$$p"; else :; fi; \
done | \
sed -e 'p;s,.*/,,;n;h' \
-e 's|.*|.|' \
-e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \
sed 'N;N;N;s,\n, ,g' | \
$(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \
{ d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \
if ($$2 == $$4) files[d] = files[d] " " $$1; \
else { print "f", $$3 "/" $$4, $$1; } } \
END { for (d in files) print "f", d, files[d] }' | \
while read type dir files; do \
if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \
test -z "$$files" || { \
echo " $(INSTALL_PROGRAM_ENV) $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(bindir)$$dir'"; \
$(INSTALL_PROGRAM_ENV) $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \
} \
; done
uninstall-binPROGRAMS:
@$(NORMAL_UNINSTALL)
@list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \
files=`for p in $$list; do echo "$$p"; done | \
sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \
-e 's/$$/$(EXEEXT)/' \
`; \
test -n "$$list" || exit 0; \
echo " ( cd '$(DESTDIR)$(bindir)' && rm -f" $$files ")"; \
cd "$(DESTDIR)$(bindir)" && rm -f $$files
clean-binPROGRAMS:
-test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS)
hts_engine$(EXEEXT): $(hts_engine_OBJECTS) $(hts_engine_DEPENDENCIES) $(EXTRA_hts_engine_DEPENDENCIES)
@rm -f hts_engine$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(hts_engine_OBJECTS) $(hts_engine_LDADD) $(LIBS)
mostlyclean-compile:
-rm -f *.$(OBJEXT)
distclean-compile:
-rm -f *.tab.c
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hts_engine.Po@am__quote@
.c.o:
@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $<
.c.obj:
@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
ID: $(am__tagged_files)
$(am__define_uniq_tagged_files); mkid -fID $$unique
tags: tags-am
TAGS: tags
tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
set x; \
here=`pwd`; \
$(am__define_uniq_tagged_files); \
shift; \
if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
test -n "$$unique" || unique=$$empty_fix; \
if test $$# -gt 0; then \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
"$$@" $$unique; \
else \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
$$unique; \
fi; \
fi
ctags: ctags-am
CTAGS: ctags
ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
$(am__define_uniq_tagged_files); \
test -z "$(CTAGS_ARGS)$$unique" \
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
$$unique
GTAGS:
here=`$(am__cd) $(top_builddir) && pwd` \
&& $(am__cd) $(top_srcdir) \
&& gtags -i $(GTAGS_ARGS) "$$here"
cscopelist: cscopelist-am
cscopelist-am: $(am__tagged_files)
list='$(am__tagged_files)'; \
case "$(srcdir)" in \
[\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
*) sdir=$(subdir)/$(srcdir) ;; \
esac; \
for i in $$list; do \
if test -f "$$i"; then \
echo "$(subdir)/$$i"; \
else \
echo "$$sdir/$$i"; \
fi; \
done >> $(top_builddir)/cscope.files
distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
distdir: $(DISTFILES)
@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
list='$(DISTFILES)'; \
dist_files=`for file in $$list; do echo $$file; done | \
sed -e "s|^$$srcdirstrip/||;t" \
-e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
case $$dist_files in \
*/*) $(MKDIR_P) `echo "$$dist_files" | \
sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
sort -u` ;; \
esac; \
for file in $$dist_files; do \
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
if test -d $$d/$$file; then \
dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
if test -d "$(distdir)/$$file"; then \
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
fi; \
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
fi; \
cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
else \
test -f "$(distdir)/$$file" \
|| cp -p $$d/$$file "$(distdir)/$$file" \
|| exit 1; \
fi; \
done
check-am: all-am
check: check-am
all-am: Makefile $(PROGRAMS)
installdirs:
for dir in "$(DESTDIR)$(bindir)"; do \
test -z "$$dir" || $(MKDIR_P) "$$dir"; \
done
install: install-am
install-exec: install-exec-am
install-data: install-data-am
uninstall: uninstall-am
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
installcheck: installcheck-am
install-strip:
if test -z '$(STRIP)'; then \
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
install; \
else \
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
"INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
fi
mostlyclean-generic:
clean-generic:
distclean-generic:
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
-test -z "$(DISTCLEANFILES)" || rm -f $(DISTCLEANFILES)
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@echo "it deletes files that may require special tools to rebuild."
-test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES)
clean: clean-am
clean-am: clean-binPROGRAMS clean-generic mostlyclean-am
distclean: distclean-am
-rm -rf ./$(DEPDIR)
-rm -f Makefile
distclean-am: clean-am distclean-compile distclean-generic \
distclean-tags
dvi: dvi-am
dvi-am:
html: html-am
html-am:
info: info-am
info-am:
install-data-am:
install-dvi: install-dvi-am
install-dvi-am:
install-exec-am: install-binPROGRAMS
install-html: install-html-am
install-html-am:
install-info: install-info-am
install-info-am:
install-man:
install-pdf: install-pdf-am
install-pdf-am:
install-ps: install-ps-am
install-ps-am:
installcheck-am:
maintainer-clean: maintainer-clean-am
-rm -rf ./$(DEPDIR)
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-am
mostlyclean-am: mostlyclean-compile mostlyclean-generic
pdf: pdf-am
pdf-am:
ps: ps-am
ps-am:
uninstall-am: uninstall-binPROGRAMS
.MAKE: install-am install-strip
.PHONY: CTAGS GTAGS TAGS all all-am check check-am clean \
clean-binPROGRAMS clean-generic cscopelist-am ctags ctags-am \
distclean distclean-compile distclean-generic distclean-tags \
distdir dvi dvi-am html html-am info info-am install \
install-am install-binPROGRAMS install-data install-data-am \
install-dvi install-dvi-am install-exec install-exec-am \
install-html install-html-am install-info install-info-am \
install-man install-pdf install-pdf-am install-ps \
install-ps-am install-strip installcheck installcheck-am \
installdirs maintainer-clean maintainer-clean-generic \
mostlyclean mostlyclean-compile mostlyclean-generic pdf pdf-am \
ps ps-am tags tags-am uninstall uninstall-am \
uninstall-binPROGRAMS
.PRECIOUS: Makefile
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:

View File

@@ -0,0 +1,18 @@
CC = cl
CL = link
CFLAGS = /O2 /Ob2 /Oi /Ot /Oy /GT /GL /TC /I ..\include
LFLAGS = /LTCG
LIBS = ..\lib\hts_engine_API.lib winmm.lib
all: hts_engine.exe
hts_engine.exe : hts_engine.obj
$(CC) $(CFLAGS) /c $(@B).c
$(CL) $(LFLAGS) /OUT:$@ $(LIBS) $(@B).obj
clean:
del *.exe
del *.obj

344
3rdparty/hts_engine_API/bin/hts_engine.c vendored Normal file
View File

@@ -0,0 +1,344 @@
/* ----------------------------------------------------------------- */
/* The HMM-Based Speech Synthesis Engine "hts_engine API" */
/* developed by HTS Working Group */
/* http://hts-engine.sourceforge.net/ */
/* ----------------------------------------------------------------- */
/* */
/* Copyright (c) 2001-2015 Nagoya Institute of Technology */
/* Department of Computer Science */
/* */
/* 2001-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 HTS_ENGINE_C
#define HTS_ENGINE_C
#ifdef __cplusplus
#define HTS_ENGINE_C_START extern "C" {
#define HTS_ENGINE_C_END }
#else
#define HTS_ENGINE_C_START
#define HTS_ENGINE_C_END
#endif /* __CPLUSPLUS */
HTS_ENGINE_C_START;
#include <stdlib.h>
#include "HTS_engine.h"
/* usage: output usage */
void usage(void)
{
fprintf(stderr, "%s\n", HTS_COPYRIGHT);
fprintf(stderr, "hts_engine - The HMM-based speech synthesis engine \"hts_engine API\"\n");
fprintf(stderr, "\n");
fprintf(stderr, " usage:\n");
fprintf(stderr, " hts_engine [ options ] [ infile ]\n");
fprintf(stderr, " options: [ def][ min-- max]\n");
fprintf(stderr, " -m htsvoice : HTS voice files [ N/A]\n");
fprintf(stderr, " -od s : filename of output label with duration [ N/A]\n");
fprintf(stderr, " -om s : filename of output spectrum [ N/A]\n");
fprintf(stderr, " -of s : filename of output log F0 [ N/A]\n");
fprintf(stderr, " -ol s : filename of output low-pass filter [ N/A]\n");
fprintf(stderr, " -or s : filename of output raw audio (generated speech) [ N/A]\n");
fprintf(stderr, " -ow s : filename of output wav audio (generated speech) [ N/A]\n");
fprintf(stderr, " -ot s : filename of output trace information [ N/A]\n");
fprintf(stderr, " -vp : use phoneme alignment for duration [ N/A]\n");
fprintf(stderr, " -i i f1 .. fi : enable interpolation & specify number(i),coefficient(f) [ N/A]\n");
fprintf(stderr, " -s i : sampling frequency [ auto][ 1-- ]\n");
fprintf(stderr, " -p i : frame period (point) [ auto][ 1-- ]\n");
fprintf(stderr, " -a f : all-pass constant [ auto][ 0.0-- 1.0]\n");
fprintf(stderr, " -b f : postfiltering coefficient [ 0.0][ 0.0-- 1.0]\n");
fprintf(stderr, " -r f : speech speed rate [ 1.0][ 0.0-- ]\n");
fprintf(stderr, " -fm f : additional half-tone [ 0.0][ -- ]\n");
fprintf(stderr, " -u f : voiced/unvoiced threshold [ 0.5][ 0.0-- 1.0]\n");
fprintf(stderr, " -jm f : weight of GV for spectrum [ 1.0][ 0.0-- ]\n");
fprintf(stderr, " -jf f : weight of GV for log F0 [ 1.0][ 0.0-- ]\n");
fprintf(stderr, " -g f : volume (dB) [ 0.0][ -- ]\n");
fprintf(stderr, " -z i : audio buffer size (if i==0, turn off) [ 0][ 0-- ]\n");
fprintf(stderr, " infile:\n");
fprintf(stderr, " label file\n");
fprintf(stderr, " note:\n");
fprintf(stderr, " generated spectrum, log F0, and low-pass filter coefficient\n");
fprintf(stderr, " sequences are saved in natural endian, binary (float) format.\n");
fprintf(stderr, "\n");
exit(0);
}
int main(int argc, char **argv)
{
int i;
double f;
/* hts_engine API */
HTS_Engine engine;
/* HTS voices */
size_t num_voices;
char **fn_voices;
/* input label file name */
char *labfn = NULL;
/* output file pointers */
FILE *durfp = NULL, *mgcfp = NULL, *lf0fp = NULL, *lpffp = NULL, *wavfp = NULL, *rawfp = NULL, *tracefp = NULL;
/* interpolation weights */
size_t num_interpolation_weights;
/* output usage */
if (argc <= 1)
usage();
/* initialize hts_engine API */
HTS_Engine_initialize(&engine);
/* get HTS voice file names */
num_voices = 0;
fn_voices = (char **) malloc(argc * sizeof(char *));
for (i = 0; i < argc; i++) {
if (argv[i][0] == '-' && argv[i][1] == 'm')
fn_voices[num_voices++] = argv[++i];
if (argv[i][0] == '-' && argv[i][1] == 'h')
usage();
}
if (num_voices == 0) {
fprintf(stderr, "Error: HTS voice must be specified.\n");
free(fn_voices);
exit(1);
}
/* load HTS voices */
if (HTS_Engine_load(&engine, fn_voices, num_voices) != TRUE) {
fprintf(stderr, "Error: HTS voices cannot be loaded.\n");
free(fn_voices);
HTS_Engine_clear(&engine);
exit(1);
}
free(fn_voices);
/* get options */
while (--argc) {
if (**++argv == '-') {
switch (*(*argv + 1)) {
case 'v':
switch (*(*argv + 2)) {
case 'p':
HTS_Engine_set_phoneme_alignment_flag(&engine, TRUE);
break;
default:
fprintf(stderr, "Error: Invalid option '-v%c'.\n", *(*argv + 2));
HTS_Engine_clear(&engine);
exit(1);
}
break;
case 'o':
switch (*(*argv + 2)) {
case 'w':
wavfp = fopen(*++argv, "wb");
break;
case 'r':
rawfp = fopen(*++argv, "wb");
break;
case 'd':
durfp = fopen(*++argv, "wt");
break;
case 'm':
mgcfp = fopen(*++argv, "wb");
break;
case 'f':
case 'p':
lf0fp = fopen(*++argv, "wb");
break;
case 'l':
lpffp = fopen(*++argv, "wb");
break;
case 't':
tracefp = fopen(*++argv, "wt");
break;
default:
fprintf(stderr, "Error: Invalid option '-o%c'.\n", *(*argv + 2));
HTS_Engine_clear(&engine);
exit(1);
}
--argc;
break;
case 'h':
usage();
break;
case 'm':
argv++; /* HTS voices were already loaded */
--argc;
break;
case 's':
HTS_Engine_set_sampling_frequency(&engine, (size_t) atoi(*++argv));
--argc;
break;
case 'p':
HTS_Engine_set_fperiod(&engine, (size_t) atoi(*++argv));
--argc;
break;
case 'a':
HTS_Engine_set_alpha(&engine, atof(*++argv));
--argc;
break;
case 'b':
HTS_Engine_set_beta(&engine, atof(*++argv));
--argc;
break;
case 'r':
HTS_Engine_set_speed(&engine, atof(*++argv));
--argc;
break;
case 'f':
switch (*(*argv + 2)) {
case 'm':
HTS_Engine_add_half_tone(&engine, atof(*++argv));
break;
default:
fprintf(stderr, "Error: Invalid option '-f%c'.\n", *(*argv + 2));
HTS_Engine_clear(&engine);
exit(1);
}
--argc;
break;
case 'u':
HTS_Engine_set_msd_threshold(&engine, 1, atof(*++argv));
--argc;
break;
case 'i':
num_interpolation_weights = atoi(*++argv);
argc--;
if (num_interpolation_weights != num_voices) {
HTS_Engine_clear(&engine);
exit(1);
}
for (i = 0; i < num_interpolation_weights; i++) {
f = atof(*++argv);
argc--;
HTS_Engine_set_duration_interpolation_weight(&engine, i, f);
HTS_Engine_set_parameter_interpolation_weight(&engine, i, 0, f);
HTS_Engine_set_parameter_interpolation_weight(&engine, i, 1, f);
HTS_Engine_set_gv_interpolation_weight(&engine, i, 0, f);
HTS_Engine_set_gv_interpolation_weight(&engine, i, 1, f);
}
break;
case 'j':
switch (*(*argv + 2)) {
case 'm':
HTS_Engine_set_gv_weight(&engine, 0, atof(*++argv));
break;
case 'f':
case 'p':
HTS_Engine_set_gv_weight(&engine, 1, atof(*++argv));
break;
default:
fprintf(stderr, "Error: Invalid option '-j%c'.\n", *(*argv + 2));
HTS_Engine_clear(&engine);
exit(1);
}
--argc;
break;
case 'g':
HTS_Engine_set_volume(&engine, atof(*++argv));
--argc;
break;
case 'z':
HTS_Engine_set_audio_buff_size(&engine, (size_t) atoi(*++argv));
--argc;
break;
default:
fprintf(stderr, "Error: Invalid option '-%c'.\n", *(*argv + 1));
HTS_Engine_clear(&engine);
exit(1);
}
} else {
labfn = *argv;
}
}
/* synthesize */
if (HTS_Engine_synthesize_from_fn(&engine, labfn) != TRUE) {
fprintf(stderr, "Error: waveform cannot be synthesized.\n");
HTS_Engine_clear(&engine);
exit(1);
}
/* output */
if (tracefp != NULL)
HTS_Engine_save_information(&engine, tracefp);
if (durfp != NULL)
HTS_Engine_save_label(&engine, durfp);
if (rawfp)
HTS_Engine_save_generated_speech(&engine, rawfp);
if (wavfp)
HTS_Engine_save_riff(&engine, wavfp);
if (mgcfp)
HTS_Engine_save_generated_parameter(&engine, 0, mgcfp);
if (lf0fp)
HTS_Engine_save_generated_parameter(&engine, 1, lf0fp);
if (lpffp)
HTS_Engine_save_generated_parameter(&engine, 2, lpffp);
/* reset */
HTS_Engine_refresh(&engine);
/* free memory */
HTS_Engine_clear(&engine);
/* close files */
if (durfp != NULL)
fclose(durfp);
if (mgcfp != NULL)
fclose(mgcfp);
if (lf0fp != NULL)
fclose(lf0fp);
if (lpffp != NULL)
fclose(lpffp);
if (wavfp != NULL)
fclose(wavfp);
if (rawfp != NULL)
fclose(rawfp);
if (tracefp != NULL)
fclose(tracefp);
return 0;
}
HTS_ENGINE_C_END;
#endif /* !HTS_ENGINE_C */

347
3rdparty/hts_engine_API/config/compile vendored Executable file
View File

@@ -0,0 +1,347 @@
#! /bin/sh
# Wrapper for compilers which do not understand '-c -o'.
scriptversion=2012-10-14.11; # UTC
# Copyright (C) 1999-2013 Free Software Foundation, Inc.
# Written by Tom Tromey <tromey@cygnus.com>.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.
# This file is maintained in Automake, please report
# bugs to <bug-automake@gnu.org> or send patches to
# <automake-patches@gnu.org>.
nl='
'
# We need space, tab and new line, in precisely that order. Quoting is
# there to prevent tools from complaining about whitespace usage.
IFS=" "" $nl"
file_conv=
# func_file_conv build_file lazy
# Convert a $build file to $host form and store it in $file
# Currently only supports Windows hosts. If the determined conversion
# type is listed in (the comma separated) LAZY, no conversion will
# take place.
func_file_conv ()
{
file=$1
case $file in
/ | /[!/]*) # absolute file, and not a UNC file
if test -z "$file_conv"; then
# lazily determine how to convert abs files
case `uname -s` in
MINGW*)
file_conv=mingw
;;
CYGWIN*)
file_conv=cygwin
;;
*)
file_conv=wine
;;
esac
fi
case $file_conv/,$2, in
*,$file_conv,*)
;;
mingw/*)
file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'`
;;
cygwin/*)
file=`cygpath -m "$file" || echo "$file"`
;;
wine/*)
file=`winepath -w "$file" || echo "$file"`
;;
esac
;;
esac
}
# func_cl_dashL linkdir
# Make cl look for libraries in LINKDIR
func_cl_dashL ()
{
func_file_conv "$1"
if test -z "$lib_path"; then
lib_path=$file
else
lib_path="$lib_path;$file"
fi
linker_opts="$linker_opts -LIBPATH:$file"
}
# func_cl_dashl library
# Do a library search-path lookup for cl
func_cl_dashl ()
{
lib=$1
found=no
save_IFS=$IFS
IFS=';'
for dir in $lib_path $LIB
do
IFS=$save_IFS
if $shared && test -f "$dir/$lib.dll.lib"; then
found=yes
lib=$dir/$lib.dll.lib
break
fi
if test -f "$dir/$lib.lib"; then
found=yes
lib=$dir/$lib.lib
break
fi
if test -f "$dir/lib$lib.a"; then
found=yes
lib=$dir/lib$lib.a
break
fi
done
IFS=$save_IFS
if test "$found" != yes; then
lib=$lib.lib
fi
}
# func_cl_wrapper cl arg...
# Adjust compile command to suit cl
func_cl_wrapper ()
{
# Assume a capable shell
lib_path=
shared=:
linker_opts=
for arg
do
if test -n "$eat"; then
eat=
else
case $1 in
-o)
# configure might choose to run compile as 'compile cc -o foo foo.c'.
eat=1
case $2 in
*.o | *.[oO][bB][jJ])
func_file_conv "$2"
set x "$@" -Fo"$file"
shift
;;
*)
func_file_conv "$2"
set x "$@" -Fe"$file"
shift
;;
esac
;;
-I)
eat=1
func_file_conv "$2" mingw
set x "$@" -I"$file"
shift
;;
-I*)
func_file_conv "${1#-I}" mingw
set x "$@" -I"$file"
shift
;;
-l)
eat=1
func_cl_dashl "$2"
set x "$@" "$lib"
shift
;;
-l*)
func_cl_dashl "${1#-l}"
set x "$@" "$lib"
shift
;;
-L)
eat=1
func_cl_dashL "$2"
;;
-L*)
func_cl_dashL "${1#-L}"
;;
-static)
shared=false
;;
-Wl,*)
arg=${1#-Wl,}
save_ifs="$IFS"; IFS=','
for flag in $arg; do
IFS="$save_ifs"
linker_opts="$linker_opts $flag"
done
IFS="$save_ifs"
;;
-Xlinker)
eat=1
linker_opts="$linker_opts $2"
;;
-*)
set x "$@" "$1"
shift
;;
*.cc | *.CC | *.cxx | *.CXX | *.[cC]++)
func_file_conv "$1"
set x "$@" -Tp"$file"
shift
;;
*.c | *.cpp | *.CPP | *.lib | *.LIB | *.Lib | *.OBJ | *.obj | *.[oO])
func_file_conv "$1" mingw
set x "$@" "$file"
shift
;;
*)
set x "$@" "$1"
shift
;;
esac
fi
shift
done
if test -n "$linker_opts"; then
linker_opts="-link$linker_opts"
fi
exec "$@" $linker_opts
exit 1
}
eat=
case $1 in
'')
echo "$0: No command. Try '$0 --help' for more information." 1>&2
exit 1;
;;
-h | --h*)
cat <<\EOF
Usage: compile [--help] [--version] PROGRAM [ARGS]
Wrapper for compilers which do not understand '-c -o'.
Remove '-o dest.o' from ARGS, run PROGRAM with the remaining
arguments, and rename the output as expected.
If you are trying to build a whole package this is not the
right script to run: please start by reading the file 'INSTALL'.
Report bugs to <bug-automake@gnu.org>.
EOF
exit $?
;;
-v | --v*)
echo "compile $scriptversion"
exit $?
;;
cl | *[/\\]cl | cl.exe | *[/\\]cl.exe )
func_cl_wrapper "$@" # Doesn't return...
;;
esac
ofile=
cfile=
for arg
do
if test -n "$eat"; then
eat=
else
case $1 in
-o)
# configure might choose to run compile as 'compile cc -o foo foo.c'.
# So we strip '-o arg' only if arg is an object.
eat=1
case $2 in
*.o | *.obj)
ofile=$2
;;
*)
set x "$@" -o "$2"
shift
;;
esac
;;
*.c)
cfile=$1
set x "$@" "$1"
shift
;;
*)
set x "$@" "$1"
shift
;;
esac
fi
shift
done
if test -z "$ofile" || test -z "$cfile"; then
# If no '-o' option was seen then we might have been invoked from a
# pattern rule where we don't need one. That is ok -- this is a
# normal compilation that the losing compiler can handle. If no
# '.c' file was seen then we are probably linking. That is also
# ok.
exec "$@"
fi
# Name of file we expect compiler to create.
cofile=`echo "$cfile" | sed 's|^.*[\\/]||; s|^[a-zA-Z]:||; s/\.c$/.o/'`
# Create the lock directory.
# Note: use '[/\\:.-]' here to ensure that we don't use the same name
# that we are using for the .o file. Also, base the name on the expected
# object file name, since that is what matters with a parallel build.
lockdir=`echo "$cofile" | sed -e 's|[/\\:.-]|_|g'`.d
while true; do
if mkdir "$lockdir" >/dev/null 2>&1; then
break
fi
sleep 1
done
# FIXME: race condition here if user kills between mkdir and trap.
trap "rmdir '$lockdir'; exit 1" 1 2 15
# Run the compile.
"$@"
ret=$?
if test -f "$cofile"; then
test "$cofile" = "$ofile" || mv "$cofile" "$ofile"
elif test -f "${cofile}bj"; then
test "${cofile}bj" = "$ofile" || mv "${cofile}bj" "$ofile"
fi
rmdir "$lockdir"
exit $ret
# Local Variables:
# mode: shell-script
# sh-indentation: 2
# eval: (add-hook 'write-file-hooks 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-time-zone: "UTC"
# time-stamp-end: "; # UTC"
# End:

1568
3rdparty/hts_engine_API/config/config.guess vendored Executable file

File diff suppressed because it is too large Load Diff

1793
3rdparty/hts_engine_API/config/config.sub vendored Executable file

File diff suppressed because it is too large Load Diff

791
3rdparty/hts_engine_API/config/depcomp vendored Executable file
View File

@@ -0,0 +1,791 @@
#! /bin/sh
# depcomp - compile a program generating dependencies as side-effects
scriptversion=2013-05-30.07; # UTC
# Copyright (C) 1999-2013 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.
# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>.
case $1 in
'')
echo "$0: No command. Try '$0 --help' for more information." 1>&2
exit 1;
;;
-h | --h*)
cat <<\EOF
Usage: depcomp [--help] [--version] PROGRAM [ARGS]
Run PROGRAMS ARGS to compile a file, generating dependencies
as side-effects.
Environment variables:
depmode Dependency tracking mode.
source Source file read by 'PROGRAMS ARGS'.
object Object file output by 'PROGRAMS ARGS'.
DEPDIR directory where to store dependencies.
depfile Dependency file to output.
tmpdepfile Temporary file to use when outputting dependencies.
libtool Whether libtool is used (yes/no).
Report bugs to <bug-automake@gnu.org>.
EOF
exit $?
;;
-v | --v*)
echo "depcomp $scriptversion"
exit $?
;;
esac
# Get the directory component of the given path, and save it in the
# global variables '$dir'. Note that this directory component will
# be either empty or ending with a '/' character. This is deliberate.
set_dir_from ()
{
case $1 in
*/*) dir=`echo "$1" | sed -e 's|/[^/]*$|/|'`;;
*) dir=;;
esac
}
# Get the suffix-stripped basename of the given path, and save it the
# global variable '$base'.
set_base_from ()
{
base=`echo "$1" | sed -e 's|^.*/||' -e 's/\.[^.]*$//'`
}
# If no dependency file was actually created by the compiler invocation,
# we still have to create a dummy depfile, to avoid errors with the
# Makefile "include basename.Plo" scheme.
make_dummy_depfile ()
{
echo "#dummy" > "$depfile"
}
# Factor out some common post-processing of the generated depfile.
# Requires the auxiliary global variable '$tmpdepfile' to be set.
aix_post_process_depfile ()
{
# If the compiler actually managed to produce a dependency file,
# post-process it.
if test -f "$tmpdepfile"; then
# Each line is of the form 'foo.o: dependency.h'.
# Do two passes, one to just change these to
# $object: dependency.h
# and one to simply output
# dependency.h:
# which is needed to avoid the deleted-header problem.
{ sed -e "s,^.*\.[$lower]*:,$object:," < "$tmpdepfile"
sed -e "s,^.*\.[$lower]*:[$tab ]*,," -e 's,$,:,' < "$tmpdepfile"
} > "$depfile"
rm -f "$tmpdepfile"
else
make_dummy_depfile
fi
}
# A tabulation character.
tab=' '
# A newline character.
nl='
'
# Character ranges might be problematic outside the C locale.
# These definitions help.
upper=ABCDEFGHIJKLMNOPQRSTUVWXYZ
lower=abcdefghijklmnopqrstuvwxyz
digits=0123456789
alpha=${upper}${lower}
if test -z "$depmode" || test -z "$source" || test -z "$object"; then
echo "depcomp: Variables source, object and depmode must be set" 1>&2
exit 1
fi
# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po.
depfile=${depfile-`echo "$object" |
sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`}
tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
rm -f "$tmpdepfile"
# Avoid interferences from the environment.
gccflag= dashmflag=
# Some modes work just like other modes, but use different flags. We
# parameterize here, but still list the modes in the big case below,
# to make depend.m4 easier to write. Note that we *cannot* use a case
# here, because this file can only contain one case statement.
if test "$depmode" = hp; then
# HP compiler uses -M and no extra arg.
gccflag=-M
depmode=gcc
fi
if test "$depmode" = dashXmstdout; then
# This is just like dashmstdout with a different argument.
dashmflag=-xM
depmode=dashmstdout
fi
cygpath_u="cygpath -u -f -"
if test "$depmode" = msvcmsys; then
# This is just like msvisualcpp but w/o cygpath translation.
# Just convert the backslash-escaped backslashes to single forward
# slashes to satisfy depend.m4
cygpath_u='sed s,\\\\,/,g'
depmode=msvisualcpp
fi
if test "$depmode" = msvc7msys; then
# This is just like msvc7 but w/o cygpath translation.
# Just convert the backslash-escaped backslashes to single forward
# slashes to satisfy depend.m4
cygpath_u='sed s,\\\\,/,g'
depmode=msvc7
fi
if test "$depmode" = xlc; then
# IBM C/C++ Compilers xlc/xlC can output gcc-like dependency information.
gccflag=-qmakedep=gcc,-MF
depmode=gcc
fi
case "$depmode" in
gcc3)
## gcc 3 implements dependency tracking that does exactly what
## we want. Yay! Note: for some reason libtool 1.4 doesn't like
## it if -MD -MP comes after the -MF stuff. Hmm.
## Unfortunately, FreeBSD c89 acceptance of flags depends upon
## the command line argument order; so add the flags where they
## appear in depend2.am. Note that the slowdown incurred here
## affects only configure: in makefiles, %FASTDEP% shortcuts this.
for arg
do
case $arg in
-c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;;
*) set fnord "$@" "$arg" ;;
esac
shift # fnord
shift # $arg
done
"$@"
stat=$?
if test $stat -ne 0; then
rm -f "$tmpdepfile"
exit $stat
fi
mv "$tmpdepfile" "$depfile"
;;
gcc)
## Note that this doesn't just cater to obsosete pre-3.x GCC compilers.
## but also to in-use compilers like IMB xlc/xlC and the HP C compiler.
## (see the conditional assignment to $gccflag above).
## There are various ways to get dependency output from gcc. Here's
## why we pick this rather obscure method:
## - Don't want to use -MD because we'd like the dependencies to end
## up in a subdir. Having to rename by hand is ugly.
## (We might end up doing this anyway to support other compilers.)
## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like
## -MM, not -M (despite what the docs say). Also, it might not be
## supported by the other compilers which use the 'gcc' depmode.
## - Using -M directly means running the compiler twice (even worse
## than renaming).
if test -z "$gccflag"; then
gccflag=-MD,
fi
"$@" -Wp,"$gccflag$tmpdepfile"
stat=$?
if test $stat -ne 0; then
rm -f "$tmpdepfile"
exit $stat
fi
rm -f "$depfile"
echo "$object : \\" > "$depfile"
# The second -e expression handles DOS-style file names with drive
# letters.
sed -e 's/^[^:]*: / /' \
-e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile"
## This next piece of magic avoids the "deleted header file" problem.
## The problem is that when a header file which appears in a .P file
## is deleted, the dependency causes make to die (because there is
## typically no way to rebuild the header). We avoid this by adding
## dummy dependencies for each header file. Too bad gcc doesn't do
## this for us directly.
## Some versions of gcc put a space before the ':'. On the theory
## that the space means something, we add a space to the output as
## well. hp depmode also adds that space, but also prefixes the VPATH
## to the object. Take care to not repeat it in the output.
## Some versions of the HPUX 10.20 sed can't process this invocation
## correctly. Breaking it into two sed invocations is a workaround.
tr ' ' "$nl" < "$tmpdepfile" \
| sed -e 's/^\\$//' -e '/^$/d' -e "s|.*$object$||" -e '/:$/d' \
| sed -e 's/$/ :/' >> "$depfile"
rm -f "$tmpdepfile"
;;
hp)
# This case exists only to let depend.m4 do its work. It works by
# looking at the text of this script. This case will never be run,
# since it is checked for above.
exit 1
;;
sgi)
if test "$libtool" = yes; then
"$@" "-Wp,-MDupdate,$tmpdepfile"
else
"$@" -MDupdate "$tmpdepfile"
fi
stat=$?
if test $stat -ne 0; then
rm -f "$tmpdepfile"
exit $stat
fi
rm -f "$depfile"
if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files
echo "$object : \\" > "$depfile"
# Clip off the initial element (the dependent). Don't try to be
# clever and replace this with sed code, as IRIX sed won't handle
# lines with more than a fixed number of characters (4096 in
# IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines;
# the IRIX cc adds comments like '#:fec' to the end of the
# dependency line.
tr ' ' "$nl" < "$tmpdepfile" \
| sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' \
| tr "$nl" ' ' >> "$depfile"
echo >> "$depfile"
# The second pass generates a dummy entry for each header file.
tr ' ' "$nl" < "$tmpdepfile" \
| sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
>> "$depfile"
else
make_dummy_depfile
fi
rm -f "$tmpdepfile"
;;
xlc)
# This case exists only to let depend.m4 do its work. It works by
# looking at the text of this script. This case will never be run,
# since it is checked for above.
exit 1
;;
aix)
# The C for AIX Compiler uses -M and outputs the dependencies
# in a .u file. In older versions, this file always lives in the
# current directory. Also, the AIX compiler puts '$object:' at the
# start of each line; $object doesn't have directory information.
# Version 6 uses the directory in both cases.
set_dir_from "$object"
set_base_from "$object"
if test "$libtool" = yes; then
tmpdepfile1=$dir$base.u
tmpdepfile2=$base.u
tmpdepfile3=$dir.libs/$base.u
"$@" -Wc,-M
else
tmpdepfile1=$dir$base.u
tmpdepfile2=$dir$base.u
tmpdepfile3=$dir$base.u
"$@" -M
fi
stat=$?
if test $stat -ne 0; then
rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
exit $stat
fi
for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
do
test -f "$tmpdepfile" && break
done
aix_post_process_depfile
;;
tcc)
# tcc (Tiny C Compiler) understand '-MD -MF file' since version 0.9.26
# FIXME: That version still under development at the moment of writing.
# Make that this statement remains true also for stable, released
# versions.
# It will wrap lines (doesn't matter whether long or short) with a
# trailing '\', as in:
#
# foo.o : \
# foo.c \
# foo.h \
#
# It will put a trailing '\' even on the last line, and will use leading
# spaces rather than leading tabs (at least since its commit 0394caf7
# "Emit spaces for -MD").
"$@" -MD -MF "$tmpdepfile"
stat=$?
if test $stat -ne 0; then
rm -f "$tmpdepfile"
exit $stat
fi
rm -f "$depfile"
# Each non-empty line is of the form 'foo.o : \' or ' dep.h \'.
# We have to change lines of the first kind to '$object: \'.
sed -e "s|.*:|$object :|" < "$tmpdepfile" > "$depfile"
# And for each line of the second kind, we have to emit a 'dep.h:'
# dummy dependency, to avoid the deleted-header problem.
sed -n -e 's|^ *\(.*\) *\\$|\1:|p' < "$tmpdepfile" >> "$depfile"
rm -f "$tmpdepfile"
;;
## The order of this option in the case statement is important, since the
## shell code in configure will try each of these formats in the order
## listed in this file. A plain '-MD' option would be understood by many
## compilers, so we must ensure this comes after the gcc and icc options.
pgcc)
# Portland's C compiler understands '-MD'.
# Will always output deps to 'file.d' where file is the root name of the
# source file under compilation, even if file resides in a subdirectory.
# The object file name does not affect the name of the '.d' file.
# pgcc 10.2 will output
# foo.o: sub/foo.c sub/foo.h
# and will wrap long lines using '\' :
# foo.o: sub/foo.c ... \
# sub/foo.h ... \
# ...
set_dir_from "$object"
# Use the source, not the object, to determine the base name, since
# that's sadly what pgcc will do too.
set_base_from "$source"
tmpdepfile=$base.d
# For projects that build the same source file twice into different object
# files, the pgcc approach of using the *source* file root name can cause
# problems in parallel builds. Use a locking strategy to avoid stomping on
# the same $tmpdepfile.
lockdir=$base.d-lock
trap "
echo '$0: caught signal, cleaning up...' >&2
rmdir '$lockdir'
exit 1
" 1 2 13 15
numtries=100
i=$numtries
while test $i -gt 0; do
# mkdir is a portable test-and-set.
if mkdir "$lockdir" 2>/dev/null; then
# This process acquired the lock.
"$@" -MD
stat=$?
# Release the lock.
rmdir "$lockdir"
break
else
# If the lock is being held by a different process, wait
# until the winning process is done or we timeout.
while test -d "$lockdir" && test $i -gt 0; do
sleep 1
i=`expr $i - 1`
done
fi
i=`expr $i - 1`
done
trap - 1 2 13 15
if test $i -le 0; then
echo "$0: failed to acquire lock after $numtries attempts" >&2
echo "$0: check lockdir '$lockdir'" >&2
exit 1
fi
if test $stat -ne 0; then
rm -f "$tmpdepfile"
exit $stat
fi
rm -f "$depfile"
# Each line is of the form `foo.o: dependent.h',
# or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'.
# Do two passes, one to just change these to
# `$object: dependent.h' and one to simply `dependent.h:'.
sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile"
# Some versions of the HPUX 10.20 sed can't process this invocation
# correctly. Breaking it into two sed invocations is a workaround.
sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" \
| sed -e 's/$/ :/' >> "$depfile"
rm -f "$tmpdepfile"
;;
hp2)
# The "hp" stanza above does not work with aCC (C++) and HP's ia64
# compilers, which have integrated preprocessors. The correct option
# to use with these is +Maked; it writes dependencies to a file named
# 'foo.d', which lands next to the object file, wherever that
# happens to be.
# Much of this is similar to the tru64 case; see comments there.
set_dir_from "$object"
set_base_from "$object"
if test "$libtool" = yes; then
tmpdepfile1=$dir$base.d
tmpdepfile2=$dir.libs/$base.d
"$@" -Wc,+Maked
else
tmpdepfile1=$dir$base.d
tmpdepfile2=$dir$base.d
"$@" +Maked
fi
stat=$?
if test $stat -ne 0; then
rm -f "$tmpdepfile1" "$tmpdepfile2"
exit $stat
fi
for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2"
do
test -f "$tmpdepfile" && break
done
if test -f "$tmpdepfile"; then
sed -e "s,^.*\.[$lower]*:,$object:," "$tmpdepfile" > "$depfile"
# Add 'dependent.h:' lines.
sed -ne '2,${
s/^ *//
s/ \\*$//
s/$/:/
p
}' "$tmpdepfile" >> "$depfile"
else
make_dummy_depfile
fi
rm -f "$tmpdepfile" "$tmpdepfile2"
;;
tru64)
# The Tru64 compiler uses -MD to generate dependencies as a side
# effect. 'cc -MD -o foo.o ...' puts the dependencies into 'foo.o.d'.
# At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
# dependencies in 'foo.d' instead, so we check for that too.
# Subdirectories are respected.
set_dir_from "$object"
set_base_from "$object"
if test "$libtool" = yes; then
# Libtool generates 2 separate objects for the 2 libraries. These
# two compilations output dependencies in $dir.libs/$base.o.d and
# in $dir$base.o.d. We have to check for both files, because
# one of the two compilations can be disabled. We should prefer
# $dir$base.o.d over $dir.libs/$base.o.d because the latter is
# automatically cleaned when .libs/ is deleted, while ignoring
# the former would cause a distcleancheck panic.
tmpdepfile1=$dir$base.o.d # libtool 1.5
tmpdepfile2=$dir.libs/$base.o.d # Likewise.
tmpdepfile3=$dir.libs/$base.d # Compaq CCC V6.2-504
"$@" -Wc,-MD
else
tmpdepfile1=$dir$base.d
tmpdepfile2=$dir$base.d
tmpdepfile3=$dir$base.d
"$@" -MD
fi
stat=$?
if test $stat -ne 0; then
rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
exit $stat
fi
for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
do
test -f "$tmpdepfile" && break
done
# Same post-processing that is required for AIX mode.
aix_post_process_depfile
;;
msvc7)
if test "$libtool" = yes; then
showIncludes=-Wc,-showIncludes
else
showIncludes=-showIncludes
fi
"$@" $showIncludes > "$tmpdepfile"
stat=$?
grep -v '^Note: including file: ' "$tmpdepfile"
if test $stat -ne 0; then
rm -f "$tmpdepfile"
exit $stat
fi
rm -f "$depfile"
echo "$object : \\" > "$depfile"
# The first sed program below extracts the file names and escapes
# backslashes for cygpath. The second sed program outputs the file
# name when reading, but also accumulates all include files in the
# hold buffer in order to output them again at the end. This only
# works with sed implementations that can handle large buffers.
sed < "$tmpdepfile" -n '
/^Note: including file: *\(.*\)/ {
s//\1/
s/\\/\\\\/g
p
}' | $cygpath_u | sort -u | sed -n '
s/ /\\ /g
s/\(.*\)/'"$tab"'\1 \\/p
s/.\(.*\) \\/\1:/
H
$ {
s/.*/'"$tab"'/
G
p
}' >> "$depfile"
echo >> "$depfile" # make sure the fragment doesn't end with a backslash
rm -f "$tmpdepfile"
;;
msvc7msys)
# This case exists only to let depend.m4 do its work. It works by
# looking at the text of this script. This case will never be run,
# since it is checked for above.
exit 1
;;
#nosideeffect)
# This comment above is used by automake to tell side-effect
# dependency tracking mechanisms from slower ones.
dashmstdout)
# Important note: in order to support this mode, a compiler *must*
# always write the preprocessed file to stdout, regardless of -o.
"$@" || exit $?
# Remove the call to Libtool.
if test "$libtool" = yes; then
while test "X$1" != 'X--mode=compile'; do
shift
done
shift
fi
# Remove '-o $object'.
IFS=" "
for arg
do
case $arg in
-o)
shift
;;
$object)
shift
;;
*)
set fnord "$@" "$arg"
shift # fnord
shift # $arg
;;
esac
done
test -z "$dashmflag" && dashmflag=-M
# Require at least two characters before searching for ':'
# in the target name. This is to cope with DOS-style filenames:
# a dependency such as 'c:/foo/bar' could be seen as target 'c' otherwise.
"$@" $dashmflag |
sed "s|^[$tab ]*[^:$tab ][^:][^:]*:[$tab ]*|$object: |" > "$tmpdepfile"
rm -f "$depfile"
cat < "$tmpdepfile" > "$depfile"
# Some versions of the HPUX 10.20 sed can't process this sed invocation
# correctly. Breaking it into two sed invocations is a workaround.
tr ' ' "$nl" < "$tmpdepfile" \
| sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \
| sed -e 's/$/ :/' >> "$depfile"
rm -f "$tmpdepfile"
;;
dashXmstdout)
# This case only exists to satisfy depend.m4. It is never actually
# run, as this mode is specially recognized in the preamble.
exit 1
;;
makedepend)
"$@" || exit $?
# Remove any Libtool call
if test "$libtool" = yes; then
while test "X$1" != 'X--mode=compile'; do
shift
done
shift
fi
# X makedepend
shift
cleared=no eat=no
for arg
do
case $cleared in
no)
set ""; shift
cleared=yes ;;
esac
if test $eat = yes; then
eat=no
continue
fi
case "$arg" in
-D*|-I*)
set fnord "$@" "$arg"; shift ;;
# Strip any option that makedepend may not understand. Remove
# the object too, otherwise makedepend will parse it as a source file.
-arch)
eat=yes ;;
-*|$object)
;;
*)
set fnord "$@" "$arg"; shift ;;
esac
done
obj_suffix=`echo "$object" | sed 's/^.*\././'`
touch "$tmpdepfile"
${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@"
rm -f "$depfile"
# makedepend may prepend the VPATH from the source file name to the object.
# No need to regex-escape $object, excess matching of '.' is harmless.
sed "s|^.*\($object *:\)|\1|" "$tmpdepfile" > "$depfile"
# Some versions of the HPUX 10.20 sed can't process the last invocation
# correctly. Breaking it into two sed invocations is a workaround.
sed '1,2d' "$tmpdepfile" \
| tr ' ' "$nl" \
| sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \
| sed -e 's/$/ :/' >> "$depfile"
rm -f "$tmpdepfile" "$tmpdepfile".bak
;;
cpp)
# Important note: in order to support this mode, a compiler *must*
# always write the preprocessed file to stdout.
"$@" || exit $?
# Remove the call to Libtool.
if test "$libtool" = yes; then
while test "X$1" != 'X--mode=compile'; do
shift
done
shift
fi
# Remove '-o $object'.
IFS=" "
for arg
do
case $arg in
-o)
shift
;;
$object)
shift
;;
*)
set fnord "$@" "$arg"
shift # fnord
shift # $arg
;;
esac
done
"$@" -E \
| sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
-e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
| sed '$ s: \\$::' > "$tmpdepfile"
rm -f "$depfile"
echo "$object : \\" > "$depfile"
cat < "$tmpdepfile" >> "$depfile"
sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile"
rm -f "$tmpdepfile"
;;
msvisualcpp)
# Important note: in order to support this mode, a compiler *must*
# always write the preprocessed file to stdout.
"$@" || exit $?
# Remove the call to Libtool.
if test "$libtool" = yes; then
while test "X$1" != 'X--mode=compile'; do
shift
done
shift
fi
IFS=" "
for arg
do
case "$arg" in
-o)
shift
;;
$object)
shift
;;
"-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
set fnord "$@"
shift
shift
;;
*)
set fnord "$@" "$arg"
shift
shift
;;
esac
done
"$@" -E 2>/dev/null |
sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile"
rm -f "$depfile"
echo "$object : \\" > "$depfile"
sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::'"$tab"'\1 \\:p' >> "$depfile"
echo "$tab" >> "$depfile"
sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile"
rm -f "$tmpdepfile"
;;
msvcmsys)
# This case exists only to let depend.m4 do its work. It works by
# looking at the text of this script. This case will never be run,
# since it is checked for above.
exit 1
;;
none)
exec "$@"
;;
*)
echo "Unknown depmode $depmode" 1>&2
exit 1
;;
esac
exit 0
# Local Variables:
# mode: shell-script
# sh-indentation: 2
# eval: (add-hook 'write-file-hooks 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-time-zone: "UTC"
# time-stamp-end: "; # UTC"
# End:

527
3rdparty/hts_engine_API/config/install-sh vendored Executable file
View File

@@ -0,0 +1,527 @@
#!/bin/sh
# install - install a program, script, or datafile
scriptversion=2011-11-20.07; # UTC
# This originates from X11R5 (mit/util/scripts/install.sh), which was
# later released in X11R6 (xc/config/util/install.sh) with the
# following copyright and license.
#
# Copyright (C) 1994 X Consortium
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to
# deal in the Software without restriction, including without limitation the
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
# sell copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC-
# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
# Except as contained in this notice, the name of the X Consortium shall not
# be used in advertising or otherwise to promote the sale, use or other deal-
# ings in this Software without prior written authorization from the X Consor-
# tium.
#
#
# FSF changes to this file are in the public domain.
#
# Calling this script install-sh is preferred over install.sh, to prevent
# 'make' implicit rules from creating a file called install from it
# when there is no Makefile.
#
# This script is compatible with the BSD install script, but was written
# from scratch.
nl='
'
IFS=" "" $nl"
# set DOITPROG to echo to test this script
# Don't use :- since 4.3BSD and earlier shells don't like it.
doit=${DOITPROG-}
if test -z "$doit"; then
doit_exec=exec
else
doit_exec=$doit
fi
# Put in absolute file names if you don't have them in your path;
# or use environment vars.
chgrpprog=${CHGRPPROG-chgrp}
chmodprog=${CHMODPROG-chmod}
chownprog=${CHOWNPROG-chown}
cmpprog=${CMPPROG-cmp}
cpprog=${CPPROG-cp}
mkdirprog=${MKDIRPROG-mkdir}
mvprog=${MVPROG-mv}
rmprog=${RMPROG-rm}
stripprog=${STRIPPROG-strip}
posix_glob='?'
initialize_posix_glob='
test "$posix_glob" != "?" || {
if (set -f) 2>/dev/null; then
posix_glob=
else
posix_glob=:
fi
}
'
posix_mkdir=
# Desired mode of installed file.
mode=0755
chgrpcmd=
chmodcmd=$chmodprog
chowncmd=
mvcmd=$mvprog
rmcmd="$rmprog -f"
stripcmd=
src=
dst=
dir_arg=
dst_arg=
copy_on_change=false
no_target_directory=
usage="\
Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE
or: $0 [OPTION]... SRCFILES... DIRECTORY
or: $0 [OPTION]... -t DIRECTORY SRCFILES...
or: $0 [OPTION]... -d DIRECTORIES...
In the 1st form, copy SRCFILE to DSTFILE.
In the 2nd and 3rd, copy all SRCFILES to DIRECTORY.
In the 4th, create DIRECTORIES.
Options:
--help display this help and exit.
--version display version info and exit.
-c (ignored)
-C install only if different (preserve the last data modification time)
-d create directories instead of installing files.
-g GROUP $chgrpprog installed files to GROUP.
-m MODE $chmodprog installed files to MODE.
-o USER $chownprog installed files to USER.
-s $stripprog installed files.
-t DIRECTORY install into DIRECTORY.
-T report an error if DSTFILE is a directory.
Environment variables override the default commands:
CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG
RMPROG STRIPPROG
"
while test $# -ne 0; do
case $1 in
-c) ;;
-C) copy_on_change=true;;
-d) dir_arg=true;;
-g) chgrpcmd="$chgrpprog $2"
shift;;
--help) echo "$usage"; exit $?;;
-m) mode=$2
case $mode in
*' '* | *' '* | *'
'* | *'*'* | *'?'* | *'['*)
echo "$0: invalid mode: $mode" >&2
exit 1;;
esac
shift;;
-o) chowncmd="$chownprog $2"
shift;;
-s) stripcmd=$stripprog;;
-t) dst_arg=$2
# Protect names problematic for 'test' and other utilities.
case $dst_arg in
-* | [=\(\)!]) dst_arg=./$dst_arg;;
esac
shift;;
-T) no_target_directory=true;;
--version) echo "$0 $scriptversion"; exit $?;;
--) shift
break;;
-*) echo "$0: invalid option: $1" >&2
exit 1;;
*) break;;
esac
shift
done
if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then
# When -d is used, all remaining arguments are directories to create.
# When -t is used, the destination is already specified.
# Otherwise, the last argument is the destination. Remove it from $@.
for arg
do
if test -n "$dst_arg"; then
# $@ is not empty: it contains at least $arg.
set fnord "$@" "$dst_arg"
shift # fnord
fi
shift # arg
dst_arg=$arg
# Protect names problematic for 'test' and other utilities.
case $dst_arg in
-* | [=\(\)!]) dst_arg=./$dst_arg;;
esac
done
fi
if test $# -eq 0; then
if test -z "$dir_arg"; then
echo "$0: no input file specified." >&2
exit 1
fi
# It's OK to call 'install-sh -d' without argument.
# This can happen when creating conditional directories.
exit 0
fi
if test -z "$dir_arg"; then
do_exit='(exit $ret); exit $ret'
trap "ret=129; $do_exit" 1
trap "ret=130; $do_exit" 2
trap "ret=141; $do_exit" 13
trap "ret=143; $do_exit" 15
# Set umask so as not to create temps with too-generous modes.
# However, 'strip' requires both read and write access to temps.
case $mode in
# Optimize common cases.
*644) cp_umask=133;;
*755) cp_umask=22;;
*[0-7])
if test -z "$stripcmd"; then
u_plus_rw=
else
u_plus_rw='% 200'
fi
cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;;
*)
if test -z "$stripcmd"; then
u_plus_rw=
else
u_plus_rw=,u+rw
fi
cp_umask=$mode$u_plus_rw;;
esac
fi
for src
do
# Protect names problematic for 'test' and other utilities.
case $src in
-* | [=\(\)!]) src=./$src;;
esac
if test -n "$dir_arg"; then
dst=$src
dstdir=$dst
test -d "$dstdir"
dstdir_status=$?
else
# Waiting for this to be detected by the "$cpprog $src $dsttmp" command
# might cause directories to be created, which would be especially bad
# if $src (and thus $dsttmp) contains '*'.
if test ! -f "$src" && test ! -d "$src"; then
echo "$0: $src does not exist." >&2
exit 1
fi
if test -z "$dst_arg"; then
echo "$0: no destination specified." >&2
exit 1
fi
dst=$dst_arg
# If destination is a directory, append the input filename; won't work
# if double slashes aren't ignored.
if test -d "$dst"; then
if test -n "$no_target_directory"; then
echo "$0: $dst_arg: Is a directory" >&2
exit 1
fi
dstdir=$dst
dst=$dstdir/`basename "$src"`
dstdir_status=0
else
# Prefer dirname, but fall back on a substitute if dirname fails.
dstdir=`
(dirname "$dst") 2>/dev/null ||
expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
X"$dst" : 'X\(//\)[^/]' \| \
X"$dst" : 'X\(//\)$' \| \
X"$dst" : 'X\(/\)' \| . 2>/dev/null ||
echo X"$dst" |
sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
s//\1/
q
}
/^X\(\/\/\)[^/].*/{
s//\1/
q
}
/^X\(\/\/\)$/{
s//\1/
q
}
/^X\(\/\).*/{
s//\1/
q
}
s/.*/./; q'
`
test -d "$dstdir"
dstdir_status=$?
fi
fi
obsolete_mkdir_used=false
if test $dstdir_status != 0; then
case $posix_mkdir in
'')
# Create intermediate dirs using mode 755 as modified by the umask.
# This is like FreeBSD 'install' as of 1997-10-28.
umask=`umask`
case $stripcmd.$umask in
# Optimize common cases.
*[2367][2367]) mkdir_umask=$umask;;
.*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;;
*[0-7])
mkdir_umask=`expr $umask + 22 \
- $umask % 100 % 40 + $umask % 20 \
- $umask % 10 % 4 + $umask % 2
`;;
*) mkdir_umask=$umask,go-w;;
esac
# With -d, create the new directory with the user-specified mode.
# Otherwise, rely on $mkdir_umask.
if test -n "$dir_arg"; then
mkdir_mode=-m$mode
else
mkdir_mode=
fi
posix_mkdir=false
case $umask in
*[123567][0-7][0-7])
# POSIX mkdir -p sets u+wx bits regardless of umask, which
# is incompatible with FreeBSD 'install' when (umask & 300) != 0.
;;
*)
tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$
trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0
if (umask $mkdir_umask &&
exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1
then
if test -z "$dir_arg" || {
# Check for POSIX incompatibilities with -m.
# HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or
# other-writable bit of parent directory when it shouldn't.
# FreeBSD 6.1 mkdir -m -p sets mode of existing directory.
ls_ld_tmpdir=`ls -ld "$tmpdir"`
case $ls_ld_tmpdir in
d????-?r-*) different_mode=700;;
d????-?--*) different_mode=755;;
*) false;;
esac &&
$mkdirprog -m$different_mode -p -- "$tmpdir" && {
ls_ld_tmpdir_1=`ls -ld "$tmpdir"`
test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1"
}
}
then posix_mkdir=:
fi
rmdir "$tmpdir/d" "$tmpdir"
else
# Remove any dirs left behind by ancient mkdir implementations.
rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null
fi
trap '' 0;;
esac;;
esac
if
$posix_mkdir && (
umask $mkdir_umask &&
$doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir"
)
then :
else
# The umask is ridiculous, or mkdir does not conform to POSIX,
# or it failed possibly due to a race condition. Create the
# directory the slow way, step by step, checking for races as we go.
case $dstdir in
/*) prefix='/';;
[-=\(\)!]*) prefix='./';;
*) prefix='';;
esac
eval "$initialize_posix_glob"
oIFS=$IFS
IFS=/
$posix_glob set -f
set fnord $dstdir
shift
$posix_glob set +f
IFS=$oIFS
prefixes=
for d
do
test X"$d" = X && continue
prefix=$prefix$d
if test -d "$prefix"; then
prefixes=
else
if $posix_mkdir; then
(umask=$mkdir_umask &&
$doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break
# Don't fail if two instances are running concurrently.
test -d "$prefix" || exit 1
else
case $prefix in
*\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;;
*) qprefix=$prefix;;
esac
prefixes="$prefixes '$qprefix'"
fi
fi
prefix=$prefix/
done
if test -n "$prefixes"; then
# Don't fail if two instances are running concurrently.
(umask $mkdir_umask &&
eval "\$doit_exec \$mkdirprog $prefixes") ||
test -d "$dstdir" || exit 1
obsolete_mkdir_used=true
fi
fi
fi
if test -n "$dir_arg"; then
{ test -z "$chowncmd" || $doit $chowncmd "$dst"; } &&
{ test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } &&
{ test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false ||
test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1
else
# Make a couple of temp file names in the proper directory.
dsttmp=$dstdir/_inst.$$_
rmtmp=$dstdir/_rm.$$_
# Trap to clean up those temp files at exit.
trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0
# Copy the file name to the temp name.
(umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") &&
# and set any options; do chmod last to preserve setuid bits.
#
# If any of these fail, we abort the whole thing. If we want to
# ignore errors from any of these, just make sure not to ignore
# errors from the above "$doit $cpprog $src $dsttmp" command.
#
{ test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } &&
{ test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } &&
{ test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } &&
{ test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } &&
# If -C, don't bother to copy if it wouldn't change the file.
if $copy_on_change &&
old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` &&
new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` &&
eval "$initialize_posix_glob" &&
$posix_glob set -f &&
set X $old && old=:$2:$4:$5:$6 &&
set X $new && new=:$2:$4:$5:$6 &&
$posix_glob set +f &&
test "$old" = "$new" &&
$cmpprog "$dst" "$dsttmp" >/dev/null 2>&1
then
rm -f "$dsttmp"
else
# Rename the file to the real destination.
$doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null ||
# The rename failed, perhaps because mv can't rename something else
# to itself, or perhaps because mv is so ancient that it does not
# support -f.
{
# Now remove or move aside any old file at destination location.
# We try this two ways since rm can't unlink itself on some
# systems and the destination file might be busy for other
# reasons. In this case, the final cleanup might fail but the new
# file should still install successfully.
{
test ! -f "$dst" ||
$doit $rmcmd -f "$dst" 2>/dev/null ||
{ $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null &&
{ $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; }
} ||
{ echo "$0: cannot unlink or rename $dst" >&2
(exit 1); exit 1
}
} &&
# Now rename the file to the real destination.
$doit $mvcmd "$dsttmp" "$dst"
}
fi || exit 1
trap '' 0
fi
done
# Local variables:
# eval: (add-hook 'write-file-hooks 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-time-zone: "UTC"
# time-stamp-end: "; # UTC"
# End:

215
3rdparty/hts_engine_API/config/missing vendored Executable file
View File

@@ -0,0 +1,215 @@
#! /bin/sh
# Common wrapper for a few potentially missing GNU programs.
scriptversion=2013-10-28.13; # UTC
# Copyright (C) 1996-2013 Free Software Foundation, Inc.
# Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.
if test $# -eq 0; then
echo 1>&2 "Try '$0 --help' for more information"
exit 1
fi
case $1 in
--is-lightweight)
# Used by our autoconf macros to check whether the available missing
# script is modern enough.
exit 0
;;
--run)
# Back-compat with the calling convention used by older automake.
shift
;;
-h|--h|--he|--hel|--help)
echo "\
$0 [OPTION]... PROGRAM [ARGUMENT]...
Run 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due
to PROGRAM being missing or too old.
Options:
-h, --help display this help and exit
-v, --version output version information and exit
Supported PROGRAM values:
aclocal autoconf autoheader autom4te automake makeinfo
bison yacc flex lex help2man
Version suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and
'g' are ignored when checking the name.
Send bug reports to <bug-automake@gnu.org>."
exit $?
;;
-v|--v|--ve|--ver|--vers|--versi|--versio|--version)
echo "missing $scriptversion (GNU Automake)"
exit $?
;;
-*)
echo 1>&2 "$0: unknown '$1' option"
echo 1>&2 "Try '$0 --help' for more information"
exit 1
;;
esac
# Run the given program, remember its exit status.
"$@"; st=$?
# If it succeeded, we are done.
test $st -eq 0 && exit 0
# Also exit now if we it failed (or wasn't found), and '--version' was
# passed; such an option is passed most likely to detect whether the
# program is present and works.
case $2 in --version|--help) exit $st;; esac
# Exit code 63 means version mismatch. This often happens when the user
# tries to use an ancient version of a tool on a file that requires a
# minimum version.
if test $st -eq 63; then
msg="probably too old"
elif test $st -eq 127; then
# Program was missing.
msg="missing on your system"
else
# Program was found and executed, but failed. Give up.
exit $st
fi
perl_URL=http://www.perl.org/
flex_URL=http://flex.sourceforge.net/
gnu_software_URL=http://www.gnu.org/software
program_details ()
{
case $1 in
aclocal|automake)
echo "The '$1' program is part of the GNU Automake package:"
echo "<$gnu_software_URL/automake>"
echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:"
echo "<$gnu_software_URL/autoconf>"
echo "<$gnu_software_URL/m4/>"
echo "<$perl_URL>"
;;
autoconf|autom4te|autoheader)
echo "The '$1' program is part of the GNU Autoconf package:"
echo "<$gnu_software_URL/autoconf/>"
echo "It also requires GNU m4 and Perl in order to run:"
echo "<$gnu_software_URL/m4/>"
echo "<$perl_URL>"
;;
esac
}
give_advice ()
{
# Normalize program name to check for.
normalized_program=`echo "$1" | sed '
s/^gnu-//; t
s/^gnu//; t
s/^g//; t'`
printf '%s\n' "'$1' is $msg."
configure_deps="'configure.ac' or m4 files included by 'configure.ac'"
case $normalized_program in
autoconf*)
echo "You should only need it if you modified 'configure.ac',"
echo "or m4 files included by it."
program_details 'autoconf'
;;
autoheader*)
echo "You should only need it if you modified 'acconfig.h' or"
echo "$configure_deps."
program_details 'autoheader'
;;
automake*)
echo "You should only need it if you modified 'Makefile.am' or"
echo "$configure_deps."
program_details 'automake'
;;
aclocal*)
echo "You should only need it if you modified 'acinclude.m4' or"
echo "$configure_deps."
program_details 'aclocal'
;;
autom4te*)
echo "You might have modified some maintainer files that require"
echo "the 'autom4te' program to be rebuilt."
program_details 'autom4te'
;;
bison*|yacc*)
echo "You should only need it if you modified a '.y' file."
echo "You may want to install the GNU Bison package:"
echo "<$gnu_software_URL/bison/>"
;;
lex*|flex*)
echo "You should only need it if you modified a '.l' file."
echo "You may want to install the Fast Lexical Analyzer package:"
echo "<$flex_URL>"
;;
help2man*)
echo "You should only need it if you modified a dependency" \
"of a man page."
echo "You may want to install the GNU Help2man package:"
echo "<$gnu_software_URL/help2man/>"
;;
makeinfo*)
echo "You should only need it if you modified a '.texi' file, or"
echo "any other file indirectly affecting the aspect of the manual."
echo "You might want to install the Texinfo package:"
echo "<$gnu_software_URL/texinfo/>"
echo "The spurious makeinfo call might also be the consequence of"
echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might"
echo "want to install GNU make:"
echo "<$gnu_software_URL/make/>"
;;
*)
echo "You might have modified some files without having the proper"
echo "tools for further handling them. Check the 'README' file, it"
echo "often tells you about the needed prerequisites for installing"
echo "this package. You may also peek at any GNU archive site, in"
echo "case some other package contains this missing '$1' program."
;;
esac
}
give_advice "$1" | sed -e '1s/^/WARNING: /' \
-e '2,$s/^/ /' >&2
# Propagate the correct exit status (expected to be 127 for a program
# not found, 63 for a program that failed due to version mismatch).
exit $st
# Local variables:
# eval: (add-hook 'write-file-hooks 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-time-zone: "UTC"
# time-stamp-end: "; # UTC"
# End:

6353
3rdparty/hts_engine_API/configure vendored Executable file

File diff suppressed because it is too large Load Diff

79
3rdparty/hts_engine_API/configure.ac vendored Normal file
View File

@@ -0,0 +1,79 @@
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
AC_PREREQ(2.59)
AC_INIT(hts_engine_API, 1.10, hts-engine-users@lists.sourceforge.net, hts_engine_API)
AC_CONFIG_AUX_DIR([config])
AC_COPYRIGHT(Copyright 2001-2015 Nagoya Institute of Technology)
AC_COPYRIGHT(Copyright 2001-2008 Tokyo Institute of Technology)
AM_INIT_AUTOMAKE
# Checks for C compiler
AC_PROG_CC
AM_PROG_CC_C_O
AC_PROG_INSTALL
AC_PROG_RANLIB
AN_MAKEVAR([AR], [AC_PROG_AR])
AN_PROGRAM([ar], [AC_PROG_AR])
AC_DEFUN([AC_PROG_AR], [AC_CHECK_TOOL(AR, ar, :)])
AC_PROG_AR
# Checks for libraries.
AC_CHECK_LIB([m], [log])
# Checks for header files.
AC_HEADER_STDC
AC_CHECK_HEADERS([stdlib.h string.h])
# Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
AC_TYPE_SIZE_T
# Checks for library functions.
AC_FUNC_VPRINTF
AC_CHECK_FUNCS([sqrt strchr strrchr strstr])
# Checks for embedded device compile
AC_ARG_ENABLE(embedded, [ --enable-embedded turn on compiling for embedded devices (default=no)],,enable_embedded=no)
AC_MSG_CHECKING(whether to enable compiling for embedded devices)
if test x$enable_embedded = xyes; then
AC_MSG_RESULT(yes)
AC_DEFINE(HTS_EMBEDDED)
else
AC_MSG_RESULT(no)
fi
# Checks for using festival
AC_ARG_ENABLE(festival, [ --enable-festival use memory allocation/free functions of speech tools (default=no)],,enable_festival=no)
AC_MSG_CHECKING(whether to use memory allocation/free functions of speech tools)
if test x$enable_festival = xyes; then
AC_MSG_RESULT(yes)
AC_DEFINE(FESTIVAL)
else
AC_MSG_RESULT(no)
fi
AC_CANONICAL_HOST
AC_C_BIGENDIAN
# Checks library for windows audio devices
case "$host_os" in
*win32* | *wince* | *cygwin* | *mingw* )
AC_HAVE_LIBRARY([winmm],,AC_MSG_ERROR(No winmm))
;;
*)
;;
esac
AC_CONFIG_FILES([Makefile bin/Makefile lib/Makefile])
AC_OUTPUT

View File

@@ -0,0 +1,473 @@
/* ----------------------------------------------------------------- */
/* The HMM-Based Speech Synthesis Engine "hts_engine API" */
/* developed by HTS Working Group */
/* http://hts-engine.sourceforge.net/ */
/* ----------------------------------------------------------------- */
/* */
/* Copyright (c) 2001-2015 Nagoya Institute of Technology */
/* Department of Computer Science */
/* */
/* 2001-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 HTS_ENGINE_H
#define HTS_ENGINE_H
#ifdef __cplusplus
#define HTS_ENGINE_H_START extern "C" {
#define HTS_ENGINE_H_END }
#else
#define HTS_ENGINE_H_START
#define HTS_ENGINE_H_END
#endif /* __CPLUSPLUS */
HTS_ENGINE_H_START;
#include <stdio.h>
/* common ---------------------------------------------------------- */
typedef char HTS_Boolean;
#ifndef TRUE
#define TRUE 1
#endif /* !TRUE */
#ifndef FALSE
#define FALSE 0
#endif /* !FALSE */
#ifndef HTS_NODATA
#define HTS_NODATA (-1.0e+10)
#endif /* HTS_NODATA */
/* copyright ------------------------------------------------------- */
#define HTS_COPYRIGHT "The HMM-Based Speech Synthesis Engine \"hts_engine API\"\nVersion 1.10 (http://hts-engine.sourceforge.net/)\nCopyright (C) 2001-2015 Nagoya Institute of Technology\n 2001-2008 Tokyo Institute of Technology\nAll rights reserved.\n"
/* audio ----------------------------------------------------------- */
/* HTS_Audio: audio output wrapper */
typedef struct _HTS_Audio {
size_t sampling_frequency; /* sampling frequency */
size_t max_buff_size; /* buffer size for audio output interface */
short *buff; /* current buffer */
size_t buff_size; /* current buffer size */
void *audio_interface; /* audio interface specified in compile step */
} HTS_Audio;
/* model ----------------------------------------------------------- */
/* HTS_Window: window coefficients to calculate dynamic features. */
typedef struct _HTS_Window {
size_t size; /* # of windows (static + deltas) */
int *l_width; /* left width of windows */
int *r_width; /* right width of windows */
double **coefficient; /* window coefficient */
size_t max_width; /* maximum width of windows */
} HTS_Window;
/* HTS_Pattern: list of patterns in a question and a tree. */
typedef struct _HTS_Pattern {
char *string; /* pattern string */
struct _HTS_Pattern *next; /* pointer to the next pattern */
} HTS_Pattern;
/* HTS_Question: list of questions in a tree. */
typedef struct _HTS_Question {
char *string; /* name of this question */
HTS_Pattern *head; /* pointer to the head of pattern list */
struct _HTS_Question *next; /* pointer to the next question */
} HTS_Question;
/* HTS_Node: list of tree nodes in a tree. */
typedef struct _HTS_Node {
int index; /* index of this node */
size_t pdf; /* index of PDF for this node (leaf node only) */
struct _HTS_Node *yes; /* pointer to its child node (yes) */
struct _HTS_Node *no; /* pointer to its child node (no) */
struct _HTS_Node *next; /* pointer to the next node */
HTS_Question *quest; /* question applied at this node */
} HTS_Node;
/* HTS_Tree: list of decision trees in a model. */
typedef struct _HTS_Tree {
HTS_Pattern *head; /* pointer to the head of pattern list for this tree */
struct _HTS_Tree *next; /* pointer to next tree */
HTS_Node *root; /* root node of this tree */
size_t state; /* state index of this tree */
} HTS_Tree;
/* HTS_Model: set of PDFs, decision trees and questions. */
typedef struct _HTS_Model {
size_t vector_length; /* vector length (static features only) */
size_t num_windows; /* # of windows for delta */
HTS_Boolean is_msd; /* flag for MSD */
size_t ntree; /* # of trees */
size_t *npdf; /* # of PDFs at each tree */
float ***pdf; /* PDFs */
HTS_Tree *tree; /* pointer to the list of trees */
HTS_Question *question; /* pointer to the list of questions */
} HTS_Model;
/* HTS_ModelSet: set of duration models, HMMs and GV models. */
typedef struct _HTS_ModelSet {
char *hts_voice_version; /* version of HTS voice format */
size_t sampling_frequency; /* sampling frequency */
size_t frame_period; /* frame period */
size_t num_voices; /* # of HTS voices */
size_t num_states; /* # of HMM states */
size_t num_streams; /* # of streams */
char *stream_type; /* stream type */
char *fullcontext_format; /* fullcontext label format */
char *fullcontext_version; /* version of fullcontext label */
HTS_Question *gv_off_context; /* GV switch */
char **option; /* options for each stream */
HTS_Model *duration; /* duration PDFs and trees */
HTS_Window *window; /* window coefficients for delta */
HTS_Model **stream; /* parameter PDFs and trees */
HTS_Model **gv; /* GV PDFs and trees */
} HTS_ModelSet;
/* label ----------------------------------------------------------- */
/* HTS_LabelString: individual label string with time information */
typedef struct _HTS_LabelString {
struct _HTS_LabelString *next; /* pointer to next label string */
char *name; /* label string */
double start; /* start frame specified in the given label */
double end; /* end frame specified in the given label */
} HTS_LabelString;
/* HTS_Label: list of label strings */
typedef struct _HTS_Label {
HTS_LabelString *head; /* pointer to the head of label string */
size_t size; /* # of label strings */
} HTS_Label;
/* sstream --------------------------------------------------------- */
/* HTS_SStream: individual state stream */
typedef struct _HTS_SStream {
size_t vector_length; /* vector length (static features only) */
double **mean; /* mean vector sequence */
double **vari; /* variance vector sequence */
double *msd; /* MSD parameter sequence */
size_t win_size; /* # of windows (static + deltas) */
int *win_l_width; /* left width of windows */
int *win_r_width; /* right width of windows */
double **win_coefficient; /* window cofficients */
size_t win_max_width; /* maximum width of windows */
double *gv_mean; /* mean vector of GV */
double *gv_vari; /* variance vector of GV */
HTS_Boolean *gv_switch; /* GV flag sequence */
} HTS_SStream;
/* HTS_SStreamSet: set of state stream */
typedef struct _HTS_SStreamSet {
HTS_SStream *sstream; /* state streams */
size_t nstream; /* # of streams */
size_t nstate; /* # of states */
size_t *duration; /* duration sequence */
size_t total_state; /* total state */
size_t total_frame; /* total frame */
} HTS_SStreamSet;
/* pstream --------------------------------------------------------- */
/* HTS_SMatrices: matrices/vectors used in the speech parameter generation algorithm. */
typedef struct _HTS_SMatrices {
double **mean; /* mean vector sequence */
double **ivar; /* inverse diag variance sequence */
double *g; /* vector used in the forward substitution */
double **wuw; /* W' U^-1 W */
double *wum; /* W' U^-1 mu */
} HTS_SMatrices;
/* HTS_PStream: individual PDF stream. */
typedef struct _HTS_PStream {
size_t vector_length; /* vector length (static features only) */
size_t length; /* stream length */
size_t width; /* width of dynamic window */
double **par; /* output parameter vector */
HTS_SMatrices sm; /* matrices for parameter generation */
size_t win_size; /* # of windows (static + deltas) */
int *win_l_width; /* left width of windows */
int *win_r_width; /* right width of windows */
double **win_coefficient; /* window coefficients */
HTS_Boolean *msd_flag; /* Boolean sequence for MSD */
double *gv_mean; /* mean vector of GV */
double *gv_vari; /* variance vector of GV */
HTS_Boolean *gv_switch; /* GV flag sequence */
size_t gv_length; /* frame length for GV calculation */
} HTS_PStream;
/* HTS_PStreamSet: set of PDF streams. */
typedef struct _HTS_PStreamSet {
HTS_PStream *pstream; /* PDF streams */
size_t nstream; /* # of PDF streams */
size_t total_frame; /* total frame */
} HTS_PStreamSet;
/* gstream --------------------------------------------------------- */
/* HTS_GStream: generated parameter stream. */
typedef struct _HTS_GStream {
size_t vector_length; /* vector length (static features only) */
double **par; /* generated parameter */
} HTS_GStream;
/* HTS_GStreamSet: set of generated parameter stream. */
typedef struct _HTS_GStreamSet {
size_t total_nsample; /* total sample */
size_t total_frame; /* total frame */
size_t nstream; /* # of streams */
HTS_GStream *gstream; /* generated parameter streams */
double *gspeech; /* generated speech */
} HTS_GStreamSet;
/* engine ---------------------------------------------------------- */
/* HTS_Condition: synthesis condition */
typedef struct _HTS_Condition {
/* global */
size_t sampling_frequency; /* sampling frequency */
size_t fperiod; /* frame period */
size_t audio_buff_size; /* audio buffer size (for audio device) */
HTS_Boolean stop; /* stop flag */
double volume; /* volume */
double *msd_threshold; /* MSD thresholds */
double *gv_weight; /* GV weights */
/* duration */
HTS_Boolean phoneme_alignment_flag; /* flag for using phoneme alignment in label */
double speed; /* speech speed */
/* spectrum */
size_t stage; /* if stage=0 then gamma=0 else gamma=-1/stage */
HTS_Boolean use_log_gain; /* log gain flag (for LSP) */
double alpha; /* all-pass constant */
double beta; /* postfiltering coefficient */
/* log F0 */
double additional_half_tone; /* additional half tone */
/* interpolation weights */
double *duration_iw; /* weights for duration interpolation */
double **parameter_iw; /* weights for parameter interpolation */
double **gv_iw; /* weights for GV interpolation */
} HTS_Condition;
/* HTS_Engine: Engine itself. */
typedef struct _HTS_Engine {
HTS_Condition condition; /* synthesis condition */
HTS_Audio audio; /* audio output */
HTS_ModelSet ms; /* set of duration models, HMMs and GV models */
HTS_Label label; /* label */
HTS_SStreamSet sss; /* set of state streams */
HTS_PStreamSet pss; /* set of PDF streams */
HTS_GStreamSet gss; /* set of generated parameter streams */
} HTS_Engine;
/* engine method --------------------------------------------------- */
/* HTS_Engine_initialize: initialize engine */
void HTS_Engine_initialize(HTS_Engine * engine);
/* HTS_Engine_load: load HTS voices */
HTS_Boolean HTS_Engine_load(HTS_Engine * engine, char **voices, size_t num_voices);
/* HTS_Engine_set_sampling_frequency: set sampling fraquency */
void HTS_Engine_set_sampling_frequency(HTS_Engine * engine, size_t i);
/* HTS_Engine_get_sampling_frequency: get sampling frequency */
size_t HTS_Engine_get_sampling_frequency(HTS_Engine * engine);
/* HTS_Engine_set_fperiod: set frame period */
void HTS_Engine_set_fperiod(HTS_Engine * engine, size_t i);
/* HTS_Engine_get_fperiod: get frame period */
size_t HTS_Engine_get_fperiod(HTS_Engine * engine);
/* HTS_Engine_set_audio_buff_size: set audio buffer size */
void HTS_Engine_set_audio_buff_size(HTS_Engine * engine, size_t i);
/* HTS_Engine_get_audio_buff_size: get audio buffer size */
size_t HTS_Engine_get_audio_buff_size(HTS_Engine * engine);
/* HTS_Engine_set_stop_flag: set stop flag */
void HTS_Engine_set_stop_flag(HTS_Engine * engine, HTS_Boolean b);
/* HTS_Engine_get_stop_flag: get stop flag */
HTS_Boolean HTS_Engine_get_stop_flag(HTS_Engine * engine);
/* HTS_Engine_set_volume: set volume in db */
void HTS_Engine_set_volume(HTS_Engine * engine, double f);
/* HTS_Engine_get_volume: get volume in db */
double HTS_Engine_get_volume(HTS_Engine * engine);
/* HTS_Egnine_set_msd_threshold: set MSD threshold */
void HTS_Engine_set_msd_threshold(HTS_Engine * engine, size_t stream_index, double f);
/* HTS_Engine_get_msd_threshold: get MSD threshold */
double HTS_Engine_get_msd_threshold(HTS_Engine * engine, size_t stream_index);
/* HTS_Engine_set_gv_weight: set GV weight */
void HTS_Engine_set_gv_weight(HTS_Engine * engine, size_t stream_index, double f);
/* HTS_Engine_get_gv_weight: get GV weight */
double HTS_Engine_get_gv_weight(HTS_Engine * engine, size_t stream_index);
/* HTS_Engine_set_speed: set speech speed */
void HTS_Engine_set_speed(HTS_Engine * engine, double f);
/* HTS_Engine_set_phoneme_alignment_flag: set flag for using phoneme alignment in label */
void HTS_Engine_set_phoneme_alignment_flag(HTS_Engine * engine, HTS_Boolean b);
/* HTS_Engine_set_alpha: set alpha */
void HTS_Engine_set_alpha(HTS_Engine * engine, double f);
/* HTS_Engine_get_alpha: get alpha */
double HTS_Engine_get_alpha(HTS_Engine * engine);
/* HTS_Engine_set_beta: set beta */
void HTS_Engine_set_beta(HTS_Engine * engine, double f);
/* HTS_Engine_get_beta: get beta */
double HTS_Engine_get_beta(HTS_Engine * engine);
/* HTS_Engine_add_half_tone: add half tone */
void HTS_Engine_add_half_tone(HTS_Engine * engine, double f);
/* HTS_Engine_set_duration_interpolation_weight: set interpolation weight for duration */
void HTS_Engine_set_duration_interpolation_weight(HTS_Engine * engine, size_t voice_index, double f);
/* HTS_Engine_get_duration_interpolation_weight: get interpolation weight for duration */
double HTS_Engine_get_duration_interpolation_weight(HTS_Engine * engine, size_t voice_index);
/* HTS_Engine_set_parameter_interpolation_weight: set interpolation weight for parameter */
void HTS_Engine_set_parameter_interpolation_weight(HTS_Engine * engine, size_t voice_index, size_t stream_index, double f);
/* HTS_Engine_get_parameter_interpolation_weight: get interpolation weight for parameter */
double HTS_Engine_get_parameter_interpolation_weight(HTS_Engine * engine, size_t voice_index, size_t stream_index);
/* HTS_Engine_set_gv_interpolation_weight: set interpolation weight for GV */
void HTS_Engine_set_gv_interpolation_weight(HTS_Engine * engine, size_t voice_index, size_t stream_index, double f);
/* HTS_Engine_get_gv_interpolation_weight: get interpolation weight for GV */
double HTS_Engine_get_gv_interpolation_weight(HTS_Engine * engine, size_t voice_index, size_t stream_index);
/* HTS_Engine_get_total_state: get total number of state */
size_t HTS_Engine_get_total_state(HTS_Engine * engine);
/* HTS_Engine_set_state_mean: set mean value of state */
void HTS_Engine_set_state_mean(HTS_Engine * engine, size_t stream_index, size_t state_index, size_t vector_index, double f);
/* HTS_Engine_get_state_mean: get mean value of state */
double HTS_Engine_get_state_mean(HTS_Engine * engine, size_t stream_index, size_t state_index, size_t vector_index);
/* HTS_Engine_get_state_duration: get state duration */
size_t HTS_Engine_get_state_duration(HTS_Engine * engine, size_t state_index);
/* HTS_Engine_get_nvoices: get number of voices */
size_t HTS_Engine_get_nvoices(HTS_Engine * engine);
/* HTS_Engine_get_nstream: get number of stream */
size_t HTS_Engine_get_nstream(HTS_Engine * engine);
/* HTS_Engine_get_nstate: get number of state */
size_t HTS_Engine_get_nstate(HTS_Engine * engine);
/* HTS_Engine_get_fullcontext_label_format: get full context label format */
const char *HTS_Engine_get_fullcontext_label_format(HTS_Engine * engine);
/* HTS_Engine_get_fullcontext_label_version: get full context label version */
const char *HTS_Engine_get_fullcontext_label_version(HTS_Engine * engine);
/* HTS_Engine_get_total_frame: get total number of frame */
size_t HTS_Engine_get_total_frame(HTS_Engine * engine);
/* HTS_Engine_get_nsamples: get number of samples */
size_t HTS_Engine_get_nsamples(HTS_Engine * engine);
/* HTS_Engine_get_generated_parameter: output generated parameter */
double HTS_Engine_get_generated_parameter(HTS_Engine * engine, size_t stream_index, size_t frame_index, size_t vector_index);
/* HTS_Engine_get_generated_speech: output generated speech */
double HTS_Engine_get_generated_speech(HTS_Engine * engine, size_t index);
/* HTS_Engine_synthesize_from_fn: synthesize speech from file name */
HTS_Boolean HTS_Engine_synthesize_from_fn(HTS_Engine * engine, const char *fn);
/* HTS_Engine_synthesize_from_strings: synthesize speech from string list */
HTS_Boolean HTS_Engine_synthesize_from_strings(HTS_Engine * engine, char **lines, size_t num_lines);
/* HTS_Engine_generate_state_sequence_from_fn: generate state sequence from file name (1st synthesis step) */
HTS_Boolean HTS_Engine_generate_state_sequence_from_fn(HTS_Engine * engine, const char *fn);
/* HTS_Engine_generate_state_sequence_from_strings: generate state sequence from string list (1st synthesis step) */
HTS_Boolean HTS_Engine_generate_state_sequence_from_strings(HTS_Engine * engine, char **lines, size_t num_lines);
/* HTS_Engine_generate_parameter_sequence: generate parameter sequence (2nd synthesis step) */
HTS_Boolean HTS_Engine_generate_parameter_sequence(HTS_Engine * engine);
/* HTS_Engine_generate_sample_sequence: generate sample sequence (3rd synthesis step) */
HTS_Boolean HTS_Engine_generate_sample_sequence(HTS_Engine * engine);
/* HTS_Engine_save_information: save trace information */
void HTS_Engine_save_information(HTS_Engine * engine, FILE * fp);
/* HTS_Engine_save_label: save label with time */
void HTS_Engine_save_label(HTS_Engine * engine, FILE * fp);
/* HTS_Engine_save_generated_parameter: save generated parameter */
void HTS_Engine_save_generated_parameter(HTS_Engine * engine, size_t stream_index, FILE * fp);
/* HTS_Engine_save_generated_speech: save generated speech */
void HTS_Engine_save_generated_speech(HTS_Engine * engine, FILE * fp);
/* HTS_Engine_save_riff: save RIFF format file */
void HTS_Engine_save_riff(HTS_Engine * engine, FILE * fp);
/* HTS_Engine_refresh: free memory per one time synthesis */
void HTS_Engine_refresh(HTS_Engine * engine);
/* HTS_Engine_clear: free engine */
void HTS_Engine_clear(HTS_Engine * engine);
HTS_ENGINE_H_END;
#endif /* !HTS_ENGINE_H */

508
3rdparty/hts_engine_API/lib/HTS_audio.c vendored Normal file
View File

@@ -0,0 +1,508 @@
/* ----------------------------------------------------------------- */
/* The HMM-Based Speech Synthesis Engine "hts_engine API" */
/* developed by HTS Working Group */
/* http://hts-engine.sourceforge.net/ */
/* ----------------------------------------------------------------- */
/* */
/* Copyright (c) 2001-2015 Nagoya Institute of Technology */
/* Department of Computer Science */
/* */
/* 2001-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 HTS_AUDIO_C
#define HTS_AUDIO_C
#ifdef __cplusplus
#define HTS_AUDIO_C_START extern "C" {
#define HTS_AUDIO_C_END }
#else
#define HTS_AUDIO_C_START
#define HTS_AUDIO_C_END
#endif /* __CPLUSPLUS */
HTS_AUDIO_C_START;
#if !defined(AUDIO_PLAY_WIN32) && !defined(AUDIO_PLAY_PORTAUDIO) && !defined(AUDIO_PLAY_NONE)
#if defined(__WINCE__) || defined(_WINCE) || defined(_WINCE) || defined(__WINCE) || defined(__WIN32__) || defined(__WIN32) || defined(_WIN32) || defined(WIN32) || defined(__CYGWIN__) || defined(__MINGW32__)
#define AUDIO_PLAY_WIN32
#else
#define AUDIO_PLAY_NONE
#endif /* __WINCE__ || _WINCE || _WINCE || __WINCE || __WIN32__ || __WIN32 || _WIN32 || WIN32 || __CYGWIN__ || __MINGW32__ */
#endif /* !AUDIO_PLAY_WIN32 && !AUDIO_PLAY_PORTAUDIO && !AUDIO_PLAY_NONE */
/* hts_engine libralies */
#include "HTS_hidden.h"
#ifdef AUDIO_PLAY_WIN32
#include <windows.h>
#include <mmsystem.h>
#define AUDIO_WAIT_BUFF_MS 10 /* wait time (0.01 sec) */
#define AUDIO_CHANNEL 1 /* monaural */
#ifdef _M_X64
#define AUDIO_POINTER_TYPE DWORD_PTR
#else
#define AUDIO_POINTER_TYPE DWORD
#endif
/* HTS_Audio: audio interface for Windows */
typedef struct _HTS_AudioInterface {
HWAVEOUT hwaveout; /* audio device handle */
WAVEFORMATEX waveformatex; /* wave formatex */
unsigned char which_buff; /* double buffering flag */
HTS_Boolean now_buff_1; /* double buffering flag */
HTS_Boolean now_buff_2; /* double buffering flag */
WAVEHDR buff_1; /* buffer */
WAVEHDR buff_2; /* buffer */
} HTS_AudioInterface;
/* HTS_AudioInterface_callback_function: callback function from audio device */
static void CALLBACK HTS_AudioInterface_callback_function(HWAVEOUT hwaveout, UINT msg, AUDIO_POINTER_TYPE user_data, AUDIO_POINTER_TYPE param1, AUDIO_POINTER_TYPE param2)
{
WAVEHDR *wavehdr = (WAVEHDR *) param1;
HTS_AudioInterface *audio_interface = (HTS_AudioInterface *) user_data;
if (msg == MM_WOM_DONE && wavehdr && (wavehdr->dwFlags & WHDR_DONE)) {
if (audio_interface->now_buff_1 == TRUE && wavehdr == &(audio_interface->buff_1)) {
audio_interface->now_buff_1 = FALSE;
} else if (audio_interface->now_buff_2 == TRUE && wavehdr == &(audio_interface->buff_2)) {
audio_interface->now_buff_2 = FALSE;
}
}
}
/* HTS_AudioInterface_write: send buffer to audio device */
static HTS_Boolean HTS_AudioInterface_write(HTS_AudioInterface * audio_interface, const short *buff, size_t buff_size)
{
MMRESULT result;
if (audio_interface->which_buff == 1) {
while (audio_interface->now_buff_1 == TRUE)
Sleep(AUDIO_WAIT_BUFF_MS);
audio_interface->now_buff_1 = TRUE;
audio_interface->which_buff = 2;
memcpy(audio_interface->buff_1.lpData, buff, buff_size * sizeof(short));
audio_interface->buff_1.dwBufferLength = (DWORD) buff_size *sizeof(short);
result = waveOutWrite(audio_interface->hwaveout, &(audio_interface->buff_1), sizeof(WAVEHDR));
} else {
while (audio_interface->now_buff_2 == TRUE)
Sleep(AUDIO_WAIT_BUFF_MS);
audio_interface->now_buff_2 = TRUE;
audio_interface->which_buff = 1;
memcpy(audio_interface->buff_2.lpData, buff, buff_size * sizeof(short));
audio_interface->buff_2.dwBufferLength = (DWORD) buff_size *sizeof(short);
result = waveOutWrite(audio_interface->hwaveout, &(audio_interface->buff_2), sizeof(WAVEHDR));
}
if (result != MMSYSERR_NOERROR)
HTS_error(0, "hts_engine: Cannot send datablocks to your output audio device to play waveform.\n");
return (result == MMSYSERR_NOERROR) ? TRUE : FALSE;
}
/* HTS_AudioInterface_close: close audio device */
static void HTS_AudioInterface_close(HTS_AudioInterface * audio_interface)
{
MMRESULT result;
/* stop audio */
result = waveOutReset(audio_interface->hwaveout);
if (result != MMSYSERR_NOERROR)
HTS_error(0, "hts_engine: Cannot stop and reset your output audio device.\n");
/* unprepare */
result = waveOutUnprepareHeader(audio_interface->hwaveout, &(audio_interface->buff_1), sizeof(WAVEHDR));
if (result != MMSYSERR_NOERROR)
HTS_error(0, "hts_engine: Cannot cleanup the audio datablocks to play waveform.\n");
result = waveOutUnprepareHeader(audio_interface->hwaveout, &(audio_interface->buff_2), sizeof(WAVEHDR));
if (result != MMSYSERR_NOERROR)
HTS_error(0, "hts_engine: Cannot cleanup the audio datablocks to play waveform.\n");
/* close */
result = waveOutClose(audio_interface->hwaveout);
if (result != MMSYSERR_NOERROR)
HTS_error(0, "hts_engine: Failed to close your output audio device.\n");
if (audio_interface->buff_1.lpData != NULL)
HTS_free(audio_interface->buff_1.lpData);
if (audio_interface->buff_2.lpData != NULL)
HTS_free(audio_interface->buff_2.lpData);
HTS_free(audio_interface);
}
static HTS_AudioInterface *HTS_AudioInterface_open(size_t sampling_frequency, size_t max_buff_size)
{
HTS_AudioInterface *audio_interface;
MMRESULT result;
/* make audio interface */
audio_interface = (HTS_AudioInterface *) HTS_calloc(1, sizeof(HTS_AudioInterface));
audio_interface->hwaveout = 0;
audio_interface->which_buff = 1;
audio_interface->now_buff_1 = FALSE;
audio_interface->now_buff_2 = FALSE;
/* format */
audio_interface->waveformatex.wFormatTag = WAVE_FORMAT_PCM;
audio_interface->waveformatex.nChannels = AUDIO_CHANNEL;
audio_interface->waveformatex.nSamplesPerSec = (DWORD) sampling_frequency;
audio_interface->waveformatex.wBitsPerSample = sizeof(short) * 8;
audio_interface->waveformatex.nBlockAlign = AUDIO_CHANNEL * audio_interface->waveformatex.wBitsPerSample / 8;
audio_interface->waveformatex.nAvgBytesPerSec = (DWORD) sampling_frequency *audio_interface->waveformatex.nBlockAlign;
/* open */
result = waveOutOpen(&audio_interface->hwaveout, WAVE_MAPPER, &audio_interface->waveformatex, (AUDIO_POINTER_TYPE) HTS_AudioInterface_callback_function, (AUDIO_POINTER_TYPE) audio_interface, CALLBACK_FUNCTION);
if (result != MMSYSERR_NOERROR) {
HTS_error(0, "hts_engine: Failed to open your output audio_interface device to play waveform.\n");
HTS_free(audio_interface);
return NULL;
}
/* prepare */
audio_interface->buff_1.lpData = (LPSTR) HTS_calloc(max_buff_size, sizeof(short));
audio_interface->buff_1.dwBufferLength = (DWORD) max_buff_size *sizeof(short);
audio_interface->buff_1.dwFlags = WHDR_BEGINLOOP | WHDR_ENDLOOP;
audio_interface->buff_1.dwLoops = 1;
audio_interface->buff_1.lpNext = 0;
audio_interface->buff_1.reserved = 0;
result = waveOutPrepareHeader(audio_interface->hwaveout, &(audio_interface->buff_1), sizeof(WAVEHDR));
if (result != MMSYSERR_NOERROR) {
HTS_error(0, "hts_engine: Cannot initialize audio_interface datablocks to play waveform.\n");
HTS_free(audio_interface->buff_1.lpData);
HTS_free(audio_interface);
return NULL;
}
audio_interface->buff_2.lpData = (LPSTR) HTS_calloc(max_buff_size, sizeof(short));
audio_interface->buff_2.dwBufferLength = (DWORD) max_buff_size *sizeof(short);
audio_interface->buff_2.dwFlags = WHDR_BEGINLOOP | WHDR_ENDLOOP;
audio_interface->buff_2.dwLoops = 1;
audio_interface->buff_2.lpNext = 0;
audio_interface->buff_2.reserved = 0;
result = waveOutPrepareHeader(audio_interface->hwaveout, &(audio_interface->buff_2), sizeof(WAVEHDR));
if (result != MMSYSERR_NOERROR) {
HTS_error(0, "hts_engine: Cannot initialize audio_interface datablocks to play waveform.\n");
HTS_free(audio_interface->buff_1.lpData);
HTS_free(audio_interface->buff_2.lpData);
HTS_free(audio_interface);
return NULL;
}
return audio_interface;
}
/* HTS_Audio_initialize: initialize audio */
void HTS_Audio_initialize(HTS_Audio * audio)
{
if (audio == NULL)
return;
audio->sampling_frequency = 0;
audio->max_buff_size = 0;
audio->buff = NULL;
audio->buff_size = 0;
audio->audio_interface = NULL;
}
/* HTS_Audio_set_parameter: set parameters for audio */
void HTS_Audio_set_parameter(HTS_Audio * audio, size_t sampling_frequency, size_t max_buff_size)
{
if (audio == NULL)
return;
if (audio->sampling_frequency == sampling_frequency && audio->max_buff_size == max_buff_size)
return;
HTS_Audio_clear(audio);
if (sampling_frequency == 0 || max_buff_size == 0)
return;
audio->audio_interface = HTS_AudioInterface_open(sampling_frequency, max_buff_size);
if (audio->audio_interface == NULL)
return;
audio->sampling_frequency = sampling_frequency;
audio->max_buff_size = max_buff_size;
audio->buff = (short *) HTS_calloc(max_buff_size, sizeof(short));
audio->buff_size = 0;
}
/* HTS_Audio_write: send data to audio */
void HTS_Audio_write(HTS_Audio * audio, short data)
{
if (audio == NULL || audio->audio_interface == NULL)
return;
audio->buff[audio->buff_size++] = data;
if (audio->buff_size >= audio->max_buff_size) {
if (HTS_AudioInterface_write((HTS_AudioInterface *) audio->audio_interface, audio->buff, audio->buff_size) != TRUE) {
HTS_Audio_clear(audio);
return;
}
audio->buff_size = 0;
}
}
/* HTS_Audio_flush: flush remain data */
void HTS_Audio_flush(HTS_Audio * audio)
{
HTS_AudioInterface *audio_interface;
if (audio == NULL || audio->audio_interface == NULL)
return;
audio_interface = (HTS_AudioInterface *) audio->audio_interface;
if (audio->buff_size > 0) {
if (HTS_AudioInterface_write(audio_interface, audio->buff, audio->buff_size) != TRUE) {
HTS_Audio_clear(audio);
return;
}
audio->buff_size = 0;
}
while (audio_interface->now_buff_1 == TRUE || audio_interface->now_buff_2 == TRUE)
Sleep(AUDIO_WAIT_BUFF_MS);
}
/* HTS_Audio_clear: free audio */
void HTS_Audio_clear(HTS_Audio * audio)
{
HTS_AudioInterface *audio_interface;
if (audio == NULL || audio->audio_interface == NULL)
return;
audio_interface = (HTS_AudioInterface *) audio->audio_interface;
HTS_AudioInterface_close(audio_interface);
if (audio->buff != NULL)
free(audio->buff);
HTS_Audio_initialize(audio);
}
#endif /* AUDIO_PLAY_WIN32 */
#ifdef AUDIO_PLAY_PORTAUDIO
#include "portaudio.h"
/* HTS_AudioInterface: audio output for PortAudio */
typedef struct _HTS_AudioInterface {
PaStreamParameters parameters; /* parameters for output stream */
PaStream *stream; /* output stream */
} HTS_AudioInterface;
/* HTS_AudioInterface_write: send data to audio device */
static void HTS_AudioInterface_write(HTS_AudioInterface * audio_interface, const short *buff, size_t buff_size)
{
PaError err;
err = Pa_WriteStream(audio_interface->stream, buff, buff_size);
if (err != paNoError && err != paOutputUnderflowed)
HTS_error(0, "hts_engine: Cannot send datablocks to your output audio device to play waveform.\n");
}
/* HTS_AudioInterface_close: close audio device */
static void HTS_AudioInterface_close(HTS_AudioInterface * audio_interface)
{
PaError err;
err = Pa_StopStream(audio_interface->stream);
if (err != paNoError)
HTS_error(0, "hts_engine: Cannot stop your output audio device.\n");
err = Pa_CloseStream(audio_interface->stream);
if (err != paNoError)
HTS_error(0, "hts_engine: Failed to close your output audio device.\n");
Pa_Terminate();
HTS_free(audio_interface);
}
static HTS_AudioInterface *HTS_AudioInterface_open(size_t sampling_frequency, size_t max_buff_size)
{
HTS_AudioInterface *audio_interface;
PaError err;
audio_interface = HTS_calloc(1, sizeof(HTS_AudioInterface));
audio_interface->stream = NULL;
err = Pa_Initialize();
if (err != paNoError) {
HTS_error(0, "hts_engine: Failed to initialize your output audio device to play waveform.\n");
HTS_free(audio_interface);
return NULL;
}
audio_interface->parameters.device = Pa_GetDefaultOutputDevice();
audio_interface->parameters.channelCount = 1;
audio_interface->parameters.sampleFormat = paInt16;
audio_interface->parameters.suggestedLatency = Pa_GetDeviceInfo(audio_interface->parameters.device)->defaultLowOutputLatency;
audio_interface->parameters.hostApiSpecificStreamInfo = NULL;
err = Pa_OpenStream(&audio_interface->stream, NULL, &audio_interface->parameters, sampling_frequency, max_buff_size, paClipOff, NULL, NULL);
if (err != paNoError) {
HTS_error(0, "hts_engine: Failed to open your output audio device to play waveform.\n");
Pa_Terminate();
HTS_free(audio_interface);
return NULL;
}
err = Pa_StartStream(audio_interface->stream);
if (err != paNoError) {
HTS_error(0, "hts_engine: Failed to start your output audio device to play waveform.\n");
Pa_CloseStream(audio_interface->stream);
Pa_Terminate();
HTS_free(audio_interface);
return NULL;
}
return audio_interface;
}
/* HTS_Audio_initialize: initialize audio */
void HTS_Audio_initialize(HTS_Audio * audio)
{
if (audio == NULL)
return;
audio->sampling_frequency = 0;
audio->max_buff_size = 0;
audio->buff = NULL;
audio->buff_size = 0;
audio->audio_interface = NULL;
}
/* HTS_Audio_set_parameter: set parameters for audio */
void HTS_Audio_set_parameter(HTS_Audio * audio, size_t sampling_frequency, size_t max_buff_size)
{
if (audio == NULL)
return;
if (audio->sampling_frequency == sampling_frequency && audio->max_buff_size == max_buff_size)
return;
HTS_Audio_clear(audio);
if (sampling_frequency == 0 || max_buff_size == 0)
return;
audio->audio_interface = HTS_AudioInterface_open(sampling_frequency, max_buff_size);
if (audio->audio_interface == NULL)
return;
audio->sampling_frequency = sampling_frequency;
audio->max_buff_size = max_buff_size;
audio->buff = (short *) HTS_calloc(max_buff_size, sizeof(short));
audio->buff_size = 0;
}
/* HTS_Audio_write: send data to audio device */
void HTS_Audio_write(HTS_Audio * audio, short data)
{
if (audio == NULL)
return;
audio->buff[audio->buff_size++] = data;
if (audio->buff_size >= audio->max_buff_size) {
if (audio->audio_interface != NULL)
HTS_AudioInterface_write((HTS_AudioInterface *) audio->audio_interface, audio->buff, audio->max_buff_size);
audio->buff_size = 0;
}
}
/* HTS_Audio_flush: flush remain data */
void HTS_Audio_flush(HTS_Audio * audio)
{
HTS_AudioInterface *audio_interface;
if (audio == NULL || audio->audio_interface == NULL)
return;
audio_interface = (HTS_AudioInterface *) audio->audio_interface;
if (audio->buff_size > 0) {
HTS_AudioInterface_write(audio_interface, audio->buff, audio->buff_size);
audio->buff_size = 0;
}
}
/* HTS_Audio_clear: free audio */
void HTS_Audio_clear(HTS_Audio * audio)
{
HTS_AudioInterface *audio_interface;
if (audio == NULL || audio->audio_interface == NULL)
return;
audio_interface = (HTS_AudioInterface *) audio->audio_interface;
HTS_Audio_flush(audio);
HTS_AudioInterface_close(audio_interface);
if (audio->buff != NULL)
HTS_free(audio->buff);
HTS_Audio_initialize(audio);
}
#endif /* AUDIO_PLAY_PORTAUDIO */
#ifdef AUDIO_PLAY_NONE
/* HTS_Audio_initialize: initialize audio */
void HTS_Audio_initialize(HTS_Audio * audio)
{
}
/* HTS_Audio_set_parameter: set parameters for audio */
void HTS_Audio_set_parameter(HTS_Audio * audio, size_t sampling_frequeny, size_t max_buff_size)
{
}
/* HTS_Audio_write: send data to audio */
void HTS_Audio_write(HTS_Audio * audio, short data)
{
}
/* HTS_Audio_flush: flush remain data */
void HTS_Audio_flush(HTS_Audio * audio)
{
}
/* HTS_Audio_clear: free audio */
void HTS_Audio_clear(HTS_Audio * audio)
{
}
#endif /* AUDIO_PLAY_NONE */
HTS_AUDIO_C_END;
#endif /* !HTS_AUDIO_C */

792
3rdparty/hts_engine_API/lib/HTS_engine.c vendored Normal file
View File

@@ -0,0 +1,792 @@
/* ----------------------------------------------------------------- */
/* The HMM-Based Speech Synthesis Engine "hts_engine API" */
/* developed by HTS Working Group */
/* http://hts-engine.sourceforge.net/ */
/* ----------------------------------------------------------------- */
/* */
/* Copyright (c) 2001-2015 Nagoya Institute of Technology */
/* Department of Computer Science */
/* */
/* 2001-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 HTS_ENGINE_C
#define HTS_ENGINE_C
#ifdef __cplusplus
#define HTS_ENGINE_C_START extern "C" {
#define HTS_ENGINE_C_END }
#else
#define HTS_ENGINE_C_START
#define HTS_ENGINE_C_END
#endif /* __CPLUSPLUS */
HTS_ENGINE_C_START;
#include <stdlib.h> /* for atof() */
#include <string.h> /* for strcpy() */
#include <math.h> /* for pow() */
/* hts_engine libraries */
#include "HTS_hidden.h"
/* HTS_Engine_initialize: initialize engine */
void HTS_Engine_initialize(HTS_Engine * engine)
{
/* global */
engine->condition.sampling_frequency = 0;
engine->condition.fperiod = 0;
engine->condition.audio_buff_size = 0;
engine->condition.stop = FALSE;
engine->condition.volume = 1.0;
engine->condition.msd_threshold = NULL;
engine->condition.gv_weight = NULL;
/* duration */
engine->condition.speed = 1.0;
engine->condition.phoneme_alignment_flag = FALSE;
/* spectrum */
engine->condition.stage = 0;
engine->condition.use_log_gain = FALSE;
engine->condition.alpha = 0.0;
engine->condition.beta = 0.0;
/* log F0 */
engine->condition.additional_half_tone = 0.0;
/* interpolation weights */
engine->condition.duration_iw = NULL;
engine->condition.parameter_iw = NULL;
engine->condition.gv_iw = NULL;
/* initialize audio */
HTS_Audio_initialize(&engine->audio);
/* initialize model set */
HTS_ModelSet_initialize(&engine->ms);
/* initialize label list */
HTS_Label_initialize(&engine->label);
/* initialize state sequence set */
HTS_SStreamSet_initialize(&engine->sss);
/* initialize pstream set */
HTS_PStreamSet_initialize(&engine->pss);
/* initialize gstream set */
HTS_GStreamSet_initialize(&engine->gss);
}
/* HTS_Engine_load: load HTS voices */
HTS_Boolean HTS_Engine_load(HTS_Engine * engine, char **voices, size_t num_voices)
{
size_t i, j;
size_t nstream;
double average_weight;
const char *option, *find;
/* reset engine */
HTS_Engine_clear(engine);
/* load voices */
if (HTS_ModelSet_load(&engine->ms, voices, num_voices) != TRUE) {
HTS_Engine_clear(engine);
return FALSE;
}
nstream = HTS_ModelSet_get_nstream(&engine->ms);
average_weight = 1.0 / num_voices;
/* global */
engine->condition.sampling_frequency = HTS_ModelSet_get_sampling_frequency(&engine->ms);
engine->condition.fperiod = HTS_ModelSet_get_fperiod(&engine->ms);
engine->condition.msd_threshold = (double *) HTS_calloc(nstream, sizeof(double));
for (i = 0; i < nstream; i++)
engine->condition.msd_threshold[i] = 0.5;
engine->condition.gv_weight = (double *) HTS_calloc(nstream, sizeof(double));
for (i = 0; i < nstream; i++)
engine->condition.gv_weight[i] = 1.0;
/* spectrum */
option = HTS_ModelSet_get_option(&engine->ms, 0);
find = strstr(option, "GAMMA=");
if (find != NULL)
engine->condition.stage = (size_t) atoi(&find[strlen("GAMMA=")]);
find = strstr(option, "LN_GAIN=");
if (find != NULL)
engine->condition.use_log_gain = atoi(&find[strlen("LN_GAIN=")]) == 1 ? TRUE : FALSE;
find = strstr(option, "ALPHA=");
if (find != NULL)
engine->condition.alpha = atof(&find[strlen("ALPHA=")]);
/* interpolation weights */
engine->condition.duration_iw = (double *) HTS_calloc(num_voices, sizeof(double));
for (i = 0; i < num_voices; i++)
engine->condition.duration_iw[i] = average_weight;
engine->condition.parameter_iw = (double **) HTS_calloc(num_voices, sizeof(double *));
for (i = 0; i < num_voices; i++) {
engine->condition.parameter_iw[i] = (double *) HTS_calloc(nstream, sizeof(double));
for (j = 0; j < nstream; j++)
engine->condition.parameter_iw[i][j] = average_weight;
}
engine->condition.gv_iw = (double **) HTS_calloc(num_voices, sizeof(double *));
for (i = 0; i < num_voices; i++) {
engine->condition.gv_iw[i] = (double *) HTS_calloc(nstream, sizeof(double));
for (j = 0; j < nstream; j++)
engine->condition.gv_iw[i][j] = average_weight;
}
return TRUE;
}
/* HTS_Engine_set_sampling_frequency: set sampling frequency */
void HTS_Engine_set_sampling_frequency(HTS_Engine * engine, size_t i)
{
if (i < 1)
i = 1;
engine->condition.sampling_frequency = i;
HTS_Audio_set_parameter(&engine->audio, engine->condition.sampling_frequency, engine->condition.audio_buff_size);
}
/* HTS_Engine_get_sampling_frequency: get sampling frequency */
size_t HTS_Engine_get_sampling_frequency(HTS_Engine * engine)
{
return engine->condition.sampling_frequency;
}
/* HTS_Engine_set_fperiod: set frame period */
void HTS_Engine_set_fperiod(HTS_Engine * engine, size_t i)
{
if (i < 1)
i = 1;
engine->condition.fperiod = i;
}
/* HTS_Engine_get_fperiod: get frame period */
size_t HTS_Engine_get_fperiod(HTS_Engine * engine)
{
return engine->condition.fperiod;
}
/* HTS_Engine_set_audio_buff_size: set audio buffer size */
void HTS_Engine_set_audio_buff_size(HTS_Engine * engine, size_t i)
{
engine->condition.audio_buff_size = i;
HTS_Audio_set_parameter(&engine->audio, engine->condition.sampling_frequency, engine->condition.audio_buff_size);
}
/* HTS_Engine_get_audio_buff_size: get audio buffer size */
size_t HTS_Engine_get_audio_buff_size(HTS_Engine * engine)
{
return engine->condition.audio_buff_size;
}
/* HTS_Engine_set_stop_flag: set stop flag */
void HTS_Engine_set_stop_flag(HTS_Engine * engine, HTS_Boolean b)
{
engine->condition.stop = b;
}
/* HTS_Engine_get_stop_flag: get stop flag */
HTS_Boolean HTS_Engine_get_stop_flag(HTS_Engine * engine)
{
return engine->condition.stop;
}
/* HTS_Engine_set_volume: set volume in db */
void HTS_Engine_set_volume(HTS_Engine * engine, double f)
{
engine->condition.volume = exp(f * DB);
}
/* HTS_Engine_get_volume: get volume in db */
double HTS_Engine_get_volume(HTS_Engine * engine)
{
return log(engine->condition.volume) / DB;
}
/* HTS_Egnine_set_msd_threshold: set MSD threshold */
void HTS_Engine_set_msd_threshold(HTS_Engine * engine, size_t stream_index, double f)
{
if (f < 0.0)
f = 0.0;
if (f > 1.0)
f = 1.0;
engine->condition.msd_threshold[stream_index] = f;
}
/* HTS_Engine_get_msd_threshold: get MSD threshold */
double HTS_Engine_get_msd_threshold(HTS_Engine * engine, size_t stream_index)
{
return engine->condition.msd_threshold[stream_index];
}
/* HTS_Engine_set_gv_weight: set GV weight */
void HTS_Engine_set_gv_weight(HTS_Engine * engine, size_t stream_index, double f)
{
if (f < 0.0)
f = 0.0;
engine->condition.gv_weight[stream_index] = f;
}
/* HTS_Engine_get_gv_weight: get GV weight */
double HTS_Engine_get_gv_weight(HTS_Engine * engine, size_t stream_index)
{
return engine->condition.gv_weight[stream_index];
}
/* HTS_Engine_set_speed: set speech speed */
void HTS_Engine_set_speed(HTS_Engine * engine, double f)
{
if (f < 1.0E-06)
f = 1.0E-06;
engine->condition.speed = f;
}
/* HTS_Engine_set_phoneme_alignment_flag: set flag for using phoneme alignment in label */
void HTS_Engine_set_phoneme_alignment_flag(HTS_Engine * engine, HTS_Boolean b)
{
engine->condition.phoneme_alignment_flag = b;
}
/* HTS_Engine_set_alpha: set alpha */
void HTS_Engine_set_alpha(HTS_Engine * engine, double f)
{
if (f < 0.0)
f = 0.0;
if (f > 1.0)
f = 1.0;
engine->condition.alpha = f;
}
/* HTS_Engine_get_alpha: get alpha */
double HTS_Engine_get_alpha(HTS_Engine * engine)
{
return engine->condition.alpha;
}
/* HTS_Engine_set_beta: set beta */
void HTS_Engine_set_beta(HTS_Engine * engine, double f)
{
if (f < 0.0)
f = 0.0;
if (f > 1.0)
f = 1.0;
engine->condition.beta = f;
}
/* HTS_Engine_get_beta: get beta */
double HTS_Engine_get_beta(HTS_Engine * engine)
{
return engine->condition.beta;
}
/* HTS_Engine_add_half_tone: add half tone */
void HTS_Engine_add_half_tone(HTS_Engine * engine, double f)
{
engine->condition.additional_half_tone = f;
}
/* HTS_Engine_set_duration_interpolation_weight: set interpolation weight for duration */
void HTS_Engine_set_duration_interpolation_weight(HTS_Engine * engine, size_t voice_index, double f)
{
engine->condition.duration_iw[voice_index] = f;
}
/* HTS_Engine_get_duration_interpolation_weight: get interpolation weight for duration */
double HTS_Engine_get_duration_interpolation_weight(HTS_Engine * engine, size_t voice_index)
{
return engine->condition.duration_iw[voice_index];
}
/* HTS_Engine_set_parameter_interpolation_weight: set interpolation weight for parameter */
void HTS_Engine_set_parameter_interpolation_weight(HTS_Engine * engine, size_t voice_index, size_t stream_index, double f)
{
engine->condition.parameter_iw[voice_index][stream_index] = f;
}
/* HTS_Engine_get_parameter_interpolation_weight: get interpolation weight for parameter */
double HTS_Engine_get_parameter_interpolation_weight(HTS_Engine * engine, size_t voice_index, size_t stream_index)
{
return engine->condition.parameter_iw[voice_index][stream_index];
}
/* HTS_Engine_set_gv_interpolation_weight: set interpolation weight for GV */
void HTS_Engine_set_gv_interpolation_weight(HTS_Engine * engine, size_t voice_index, size_t stream_index, double f)
{
engine->condition.gv_iw[voice_index][stream_index] = f;
}
/* HTS_Engine_get_gv_interpolation_weight: get interpolation weight for GV */
double HTS_Engine_get_gv_interpolation_weight(HTS_Engine * engine, size_t voice_index, size_t stream_index)
{
return engine->condition.gv_iw[voice_index][stream_index];
}
/* HTS_Engine_get_total_state: get total number of state */
size_t HTS_Engine_get_total_state(HTS_Engine * engine)
{
return HTS_SStreamSet_get_total_state(&engine->sss);
}
/* HTS_Engine_set_state_mean: set mean value of state */
void HTS_Engine_set_state_mean(HTS_Engine * engine, size_t stream_index, size_t state_index, size_t vector_index, double f)
{
HTS_SStreamSet_set_mean(&engine->sss, stream_index, state_index, vector_index, f);
}
/* HTS_Engine_get_state_mean: get mean value of state */
double HTS_Engine_get_state_mean(HTS_Engine * engine, size_t stream_index, size_t state_index, size_t vector_index)
{
return HTS_SStreamSet_get_mean(&engine->sss, stream_index, state_index, vector_index);
}
/* HTS_Engine_get_state_duration: get state duration */
size_t HTS_Engine_get_state_duration(HTS_Engine * engine, size_t state_index)
{
return HTS_SStreamSet_get_duration(&engine->sss, state_index);
}
/* HTS_Engine_get_nvoices: get number of voices */
size_t HTS_Engine_get_nvoices(HTS_Engine * engine)
{
return HTS_ModelSet_get_nvoices(&engine->ms);
}
/* HTS_Engine_get_nstream: get number of stream */
size_t HTS_Engine_get_nstream(HTS_Engine * engine)
{
return HTS_ModelSet_get_nstream(&engine->ms);
}
/* HTS_Engine_get_nstate: get number of state */
size_t HTS_Engine_get_nstate(HTS_Engine * engine)
{
return HTS_ModelSet_get_nstate(&engine->ms);
}
/* HTS_Engine_get_fullcontext_label_format: get full context label format */
const char *HTS_Engine_get_fullcontext_label_format(HTS_Engine * engine)
{
return HTS_ModelSet_get_fullcontext_label_format(&engine->ms);
}
/* HTS_Engine_get_fullcontext_label_version: get full context label version */
const char *HTS_Engine_get_fullcontext_label_version(HTS_Engine * engine)
{
return HTS_ModelSet_get_fullcontext_label_version(&engine->ms);
}
/* HTS_Engine_get_total_frame: get total number of frame */
size_t HTS_Engine_get_total_frame(HTS_Engine * engine)
{
return HTS_GStreamSet_get_total_frame(&engine->gss);
}
/* HTS_Engine_get_nsamples: get number of samples */
size_t HTS_Engine_get_nsamples(HTS_Engine * engine)
{
return HTS_GStreamSet_get_total_nsamples(&engine->gss);
}
/* HTS_Engine_get_generated_parameter: output generated parameter */
double HTS_Engine_get_generated_parameter(HTS_Engine * engine, size_t stream_index, size_t frame_index, size_t vector_index)
{
return HTS_GStreamSet_get_parameter(&engine->gss, stream_index, frame_index, vector_index);
}
/* HTS_Engine_get_generated_speech: output generated speech */
double HTS_Engine_get_generated_speech(HTS_Engine * engine, size_t index)
{
return HTS_GStreamSet_get_speech(&engine->gss, index);
}
/* HTS_Engine_generate_state_sequence: genereate state sequence (1st synthesis step) */
static HTS_Boolean HTS_Engine_generate_state_sequence(HTS_Engine * engine)
{
size_t i, state_index, model_index;
double f;
if (HTS_SStreamSet_create(&engine->sss, &engine->ms, &engine->label, engine->condition.phoneme_alignment_flag, engine->condition.speed, engine->condition.duration_iw, engine->condition.parameter_iw, engine->condition.gv_iw) != TRUE) {
HTS_Engine_refresh(engine);
return FALSE;
}
if (engine->condition.additional_half_tone != 0.0) {
state_index = 0;
model_index = 0;
for (i = 0; i < HTS_Engine_get_total_state(engine); i++) {
f = HTS_Engine_get_state_mean(engine, 1, i, 0);
f += engine->condition.additional_half_tone * HALF_TONE;
if (f < MIN_LF0)
f = MIN_LF0;
else if (f > MAX_LF0)
f = MAX_LF0;
HTS_Engine_set_state_mean(engine, 1, i, 0, f);
state_index++;
if (state_index >= HTS_Engine_get_nstate(engine)) {
state_index = 0;
model_index++;
}
}
}
return TRUE;
}
/* HTS_Engine_generate_state_sequence_from_fn: genereate state sequence from file name (1st synthesis step) */
HTS_Boolean HTS_Engine_generate_state_sequence_from_fn(HTS_Engine * engine, const char *fn)
{
HTS_Engine_refresh(engine);
HTS_Label_load_from_fn(&engine->label, engine->condition.sampling_frequency, engine->condition.fperiod, fn);
return HTS_Engine_generate_state_sequence(engine);
}
/* HTS_Engine_generate_state_sequence_from_strings: generate state sequence from strings (1st synthesis step) */
HTS_Boolean HTS_Engine_generate_state_sequence_from_strings(HTS_Engine * engine, char **lines, size_t num_lines)
{
HTS_Engine_refresh(engine);
HTS_Label_load_from_strings(&engine->label, engine->condition.sampling_frequency, engine->condition.fperiod, lines, num_lines);
return HTS_Engine_generate_state_sequence(engine);
}
/* HTS_Engine_generate_parameter_sequence: generate parameter sequence (2nd synthesis step) */
HTS_Boolean HTS_Engine_generate_parameter_sequence(HTS_Engine * engine)
{
return HTS_PStreamSet_create(&engine->pss, &engine->sss, engine->condition.msd_threshold, engine->condition.gv_weight);
}
/* HTS_Engine_generate_sample_sequence: generate sample sequence (3rd synthesis step) */
HTS_Boolean HTS_Engine_generate_sample_sequence(HTS_Engine * engine)
{
return HTS_GStreamSet_create(&engine->gss, &engine->pss, engine->condition.stage, engine->condition.use_log_gain, engine->condition.sampling_frequency, engine->condition.fperiod, engine->condition.alpha, engine->condition.beta, &engine->condition.stop, engine->condition.volume, engine->condition.audio_buff_size > 0 ? &engine->audio : NULL);
}
/* HTS_Engine_synthesize: synthesize speech */
static HTS_Boolean HTS_Engine_synthesize(HTS_Engine * engine)
{
if (HTS_Engine_generate_state_sequence(engine) != TRUE) {
HTS_Engine_refresh(engine);
return FALSE;
}
if (HTS_Engine_generate_parameter_sequence(engine) != TRUE) {
HTS_Engine_refresh(engine);
return FALSE;
}
if (HTS_Engine_generate_sample_sequence(engine) != TRUE) {
HTS_Engine_refresh(engine);
return FALSE;
}
return TRUE;
}
/* HTS_Engine_synthesize_from_fn: synthesize speech from file name */
HTS_Boolean HTS_Engine_synthesize_from_fn(HTS_Engine * engine, const char *fn)
{
HTS_Engine_refresh(engine);
HTS_Label_load_from_fn(&engine->label, engine->condition.sampling_frequency, engine->condition.fperiod, fn);
return HTS_Engine_synthesize(engine);
}
/* HTS_Engine_synthesize_from_strings: synthesize speech from strings */
HTS_Boolean HTS_Engine_synthesize_from_strings(HTS_Engine * engine, char **lines, size_t num_lines)
{
HTS_Engine_refresh(engine);
HTS_Label_load_from_strings(&engine->label, engine->condition.sampling_frequency, engine->condition.fperiod, lines, num_lines);
return HTS_Engine_synthesize(engine);
}
/* HTS_Engine_save_information: save trace information */
void HTS_Engine_save_information(HTS_Engine * engine, FILE * fp)
{
size_t i, j, k, l, m, n;
double temp;
HTS_Condition *condition = &engine->condition;
HTS_ModelSet *ms = &engine->ms;
HTS_Label *label = &engine->label;
HTS_SStreamSet *sss = &engine->sss;
HTS_PStreamSet *pss = &engine->pss;
/* global parameter */
fprintf(fp, "[Global parameter]\n");
fprintf(fp, "Sampring frequency -> %8lu(Hz)\n", (unsigned long) condition->sampling_frequency);
fprintf(fp, "Frame period -> %8lu(point)\n", (unsigned long) condition->fperiod);
fprintf(fp, " %8.5f(msec)\n", 1e+3 * condition->fperiod / condition->sampling_frequency);
fprintf(fp, "All-pass constant -> %8.5f\n", (float) condition->alpha);
fprintf(fp, "Gamma -> %8.5f\n", (float) (condition->stage == 0 ? 0.0 : -1.0 / condition->stage));
if (condition->stage != 0) {
if (condition->use_log_gain == TRUE)
fprintf(fp, "Log gain flag -> TRUE\n");
else
fprintf(fp, "Log gain flag -> FALSE\n");
}
fprintf(fp, "Postfiltering coefficient -> %8.5f\n", (float) condition->beta);
fprintf(fp, "Audio buffer size -> %8lu(sample)\n", (unsigned long) condition->audio_buff_size);
fprintf(fp, "\n");
/* duration parameter */
fprintf(fp, "[Duration parameter]\n");
fprintf(fp, "Number of states -> %8lu\n", (unsigned long) HTS_ModelSet_get_nstate(ms));
fprintf(fp, " Interpolation size -> %8lu\n", (unsigned long) HTS_ModelSet_get_nvoices(ms));
/* check interpolation */
for (i = 0, temp = 0.0; i < HTS_ModelSet_get_nvoices(ms); i++)
temp += condition->duration_iw[i];
for (i = 0; i < HTS_ModelSet_get_nvoices(ms); i++)
if (condition->duration_iw[i] != 0.0)
condition->duration_iw[i] /= temp;
for (i = 0; i < HTS_ModelSet_get_nvoices(ms); i++)
fprintf(fp, " Interpolation weight[%2lu] -> %8.0f(%%)\n", (unsigned long) i, (float) (100 * condition->duration_iw[i]));
fprintf(fp, "\n");
fprintf(fp, "[Stream parameter]\n");
for (i = 0; i < HTS_ModelSet_get_nstream(ms); i++) {
/* stream parameter */
fprintf(fp, "Stream[%2lu] vector length -> %8lu\n", (unsigned long) i, (unsigned long) HTS_ModelSet_get_vector_length(ms, i));
fprintf(fp, " Dynamic window size -> %8lu\n", (unsigned long) HTS_ModelSet_get_window_size(ms, i));
/* interpolation */
fprintf(fp, " Interpolation size -> %8lu\n", (unsigned long) HTS_ModelSet_get_nvoices(ms));
for (j = 0, temp = 0.0; j < HTS_ModelSet_get_nvoices(ms); j++)
temp += condition->parameter_iw[j][i];
for (j = 0; j < HTS_ModelSet_get_nvoices(ms); j++)
if (condition->parameter_iw[j][i] != 0.0)
condition->parameter_iw[j][i] /= temp;
for (j = 0; j < HTS_ModelSet_get_nvoices(ms); j++)
fprintf(fp, " Interpolation weight[%2lu] -> %8.0f(%%)\n", (unsigned long) j, (float) (100 * condition->parameter_iw[j][i]));
/* MSD */
if (HTS_ModelSet_is_msd(ms, i)) { /* for MSD */
fprintf(fp, " MSD flag -> TRUE\n");
fprintf(fp, " MSD threshold -> %8.5f\n", condition->msd_threshold[i]);
} else { /* for non MSD */
fprintf(fp, " MSD flag -> FALSE\n");
}
/* GV */
if (HTS_ModelSet_use_gv(ms, i)) {
fprintf(fp, " GV flag -> TRUE\n");
fprintf(fp, " GV weight -> %8.0f(%%)\n", (float) (100 * condition->gv_weight[i]));
fprintf(fp, " GV interpolation size -> %8lu\n", (unsigned long) HTS_ModelSet_get_nvoices(ms));
/* interpolation */
for (j = 0, temp = 0.0; j < HTS_ModelSet_get_nvoices(ms); j++)
temp += condition->gv_iw[j][i];
for (j = 0; j < HTS_ModelSet_get_nvoices(ms); j++)
if (condition->gv_iw[j][i] != 0.0)
condition->gv_iw[j][i] /= temp;
for (j = 0; j < HTS_ModelSet_get_nvoices(ms); j++)
fprintf(fp, " GV interpolation weight[%2lu] -> %8.0f(%%)\n", (unsigned long) j, (float) (100 * condition->gv_iw[j][i]));
} else {
fprintf(fp, " GV flag -> FALSE\n");
}
}
fprintf(fp, "\n");
/* generated sequence */
fprintf(fp, "[Generated sequence]\n");
fprintf(fp, "Number of HMMs -> %8lu\n", (unsigned long) HTS_Label_get_size(label));
fprintf(fp, "Number of stats -> %8lu\n", (unsigned long) HTS_Label_get_size(label) * HTS_ModelSet_get_nstate(ms));
fprintf(fp, "Length of this speech -> %8.3f(sec)\n", (float) ((double) HTS_PStreamSet_get_total_frame(pss) * condition->fperiod / condition->sampling_frequency));
fprintf(fp, " -> %8lu(frames)\n", (unsigned long) HTS_PStreamSet_get_total_frame(pss) * condition->fperiod);
for (i = 0; i < HTS_Label_get_size(label); i++) {
fprintf(fp, "HMM[%2lu]\n", (unsigned long) i);
fprintf(fp, " Name -> %s\n", HTS_Label_get_string(label, i));
fprintf(fp, " Duration\n");
for (j = 0; j < HTS_ModelSet_get_nvoices(ms); j++) {
fprintf(fp, " Interpolation[%2lu]\n", (unsigned long) j);
HTS_ModelSet_get_duration_index(ms, j, HTS_Label_get_string(label, i), &k, &l);
fprintf(fp, " Tree index -> %8lu\n", (unsigned long) k);
fprintf(fp, " PDF index -> %8lu\n", (unsigned long) l);
}
for (j = 0; j < HTS_ModelSet_get_nstate(ms); j++) {
fprintf(fp, " State[%2lu]\n", (unsigned long) j + 2);
fprintf(fp, " Length -> %8lu(frames)\n", (unsigned long) HTS_SStreamSet_get_duration(sss, i * HTS_ModelSet_get_nstate(ms) + j));
for (k = 0; k < HTS_ModelSet_get_nstream(ms); k++) {
fprintf(fp, " Stream[%2lu]\n", (unsigned long) k);
if (HTS_ModelSet_is_msd(ms, k)) {
if (HTS_SStreamSet_get_msd(sss, k, i * HTS_ModelSet_get_nstate(ms) + j) > condition->msd_threshold[k])
fprintf(fp, " MSD flag -> TRUE\n");
else
fprintf(fp, " MSD flag -> FALSE\n");
}
for (l = 0; l < HTS_ModelSet_get_nvoices(ms); l++) {
fprintf(fp, " Interpolation[%2lu]\n", (unsigned long) l);
HTS_ModelSet_get_parameter_index(ms, l, k, j + 2, HTS_Label_get_string(label, i), &m, &n);
fprintf(fp, " Tree index -> %8lu\n", (unsigned long) m);
fprintf(fp, " PDF index -> %8lu\n", (unsigned long) n);
}
}
}
}
}
/* HTS_Engine_save_label: save label with time */
void HTS_Engine_save_label(HTS_Engine * engine, FILE * fp)
{
size_t i, j;
size_t frame, state, duration;
HTS_Label *label = &engine->label;
HTS_SStreamSet *sss = &engine->sss;
size_t nstate = HTS_ModelSet_get_nstate(&engine->ms);
double rate = engine->condition.fperiod * 1.0e+07 / engine->condition.sampling_frequency;
for (i = 0, state = 0, frame = 0; i < HTS_Label_get_size(label); i++) {
for (j = 0, duration = 0; j < nstate; j++)
duration += HTS_SStreamSet_get_duration(sss, state++);
fprintf(fp, "%lu %lu %s\n", (unsigned long) (frame * rate), (unsigned long) ((frame + duration) * rate), HTS_Label_get_string(label, i));
frame += duration;
}
}
/* HTS_Engine_save_generated_parameter: save generated parameter */
void HTS_Engine_save_generated_parameter(HTS_Engine * engine, size_t stream_index, FILE * fp)
{
size_t i, j;
float temp;
HTS_GStreamSet *gss = &engine->gss;
for (i = 0; i < HTS_GStreamSet_get_total_frame(gss); i++)
for (j = 0; j < HTS_GStreamSet_get_vector_length(gss, stream_index); j++) {
temp = (float) HTS_GStreamSet_get_parameter(gss, stream_index, i, j);
fwrite(&temp, sizeof(float), 1, fp);
}
}
/* HTS_Engine_save_generated_speech: save generated speech */
void HTS_Engine_save_generated_speech(HTS_Engine * engine, FILE * fp)
{
size_t i;
double x;
short temp;
HTS_GStreamSet *gss = &engine->gss;
for (i = 0; i < HTS_GStreamSet_get_total_nsamples(gss); i++) {
x = HTS_GStreamSet_get_speech(gss, i);
if (x > 32767.0)
temp = 32767;
else if (x < -32768.0)
temp = -32768;
else
temp = (short) x;
fwrite(&temp, sizeof(short), 1, fp);
}
}
/* HTS_Engine_save_riff: save RIFF format file */
void HTS_Engine_save_riff(HTS_Engine * engine, FILE * fp)
{
size_t i;
double x;
short temp;
HTS_GStreamSet *gss = &engine->gss;
char data_01_04[] = { 'R', 'I', 'F', 'F' };
int data_05_08 = HTS_GStreamSet_get_total_nsamples(gss) * sizeof(short) + 36;
char data_09_12[] = { 'W', 'A', 'V', 'E' };
char data_13_16[] = { 'f', 'm', 't', ' ' };
int data_17_20 = 16;
short data_21_22 = 1; /* PCM */
short data_23_24 = 1; /* monoral */
int data_25_28 = engine->condition.sampling_frequency;
int data_29_32 = engine->condition.sampling_frequency * sizeof(short);
short data_33_34 = sizeof(short);
short data_35_36 = (short) (sizeof(short) * 8);
char data_37_40[] = { 'd', 'a', 't', 'a' };
int data_41_44 = HTS_GStreamSet_get_total_nsamples(gss) * sizeof(short);
/* write header */
HTS_fwrite_little_endian(data_01_04, sizeof(char), 4, fp);
HTS_fwrite_little_endian(&data_05_08, sizeof(int), 1, fp);
HTS_fwrite_little_endian(data_09_12, sizeof(char), 4, fp);
HTS_fwrite_little_endian(data_13_16, sizeof(char), 4, fp);
HTS_fwrite_little_endian(&data_17_20, sizeof(int), 1, fp);
HTS_fwrite_little_endian(&data_21_22, sizeof(short), 1, fp);
HTS_fwrite_little_endian(&data_23_24, sizeof(short), 1, fp);
HTS_fwrite_little_endian(&data_25_28, sizeof(int), 1, fp);
HTS_fwrite_little_endian(&data_29_32, sizeof(int), 1, fp);
HTS_fwrite_little_endian(&data_33_34, sizeof(short), 1, fp);
HTS_fwrite_little_endian(&data_35_36, sizeof(short), 1, fp);
HTS_fwrite_little_endian(data_37_40, sizeof(char), 4, fp);
HTS_fwrite_little_endian(&data_41_44, sizeof(int), 1, fp);
/* write data */
for (i = 0; i < HTS_GStreamSet_get_total_nsamples(gss); i++) {
x = HTS_GStreamSet_get_speech(gss, i);
if (x > 32767.0)
temp = 32767;
else if (x < -32768.0)
temp = -32768;
else
temp = (short) x;
HTS_fwrite_little_endian(&temp, sizeof(short), 1, fp);
}
}
/* HTS_Engine_refresh: free model per one time synthesis */
void HTS_Engine_refresh(HTS_Engine * engine)
{
/* free generated parameter stream set */
HTS_GStreamSet_clear(&engine->gss);
/* free parameter stream set */
HTS_PStreamSet_clear(&engine->pss);
/* free state stream set */
HTS_SStreamSet_clear(&engine->sss);
/* free label list */
HTS_Label_clear(&engine->label);
/* stop flag */
engine->condition.stop = FALSE;
}
/* HTS_Engine_clear: free engine */
void HTS_Engine_clear(HTS_Engine * engine)
{
size_t i;
if (engine->condition.msd_threshold != NULL)
HTS_free(engine->condition.msd_threshold);
if (engine->condition.duration_iw != NULL)
HTS_free(engine->condition.duration_iw);
if (engine->condition.gv_weight != NULL)
HTS_free(engine->condition.gv_weight);
if (engine->condition.parameter_iw != NULL) {
for (i = 0; i < HTS_ModelSet_get_nvoices(&engine->ms); i++)
HTS_free(engine->condition.parameter_iw[i]);
HTS_free(engine->condition.parameter_iw);
}
if (engine->condition.gv_iw != NULL) {
for (i = 0; i < HTS_ModelSet_get_nvoices(&engine->ms); i++)
HTS_free(engine->condition.gv_iw[i]);
HTS_free(engine->condition.gv_iw);
}
HTS_ModelSet_clear(&engine->ms);
HTS_Audio_clear(&engine->audio);
HTS_Engine_initialize(engine);
}
HTS_ENGINE_C_END;
#endif /* !HTS_ENGINE_C */

View File

@@ -0,0 +1,203 @@
/* ----------------------------------------------------------------- */
/* The HMM-Based Speech Synthesis Engine "hts_engine API" */
/* developed by HTS Working Group */
/* http://hts-engine.sourceforge.net/ */
/* ----------------------------------------------------------------- */
/* */
/* Copyright (c) 2001-2015 Nagoya Institute of Technology */
/* Department of Computer Science */
/* */
/* 2001-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 HTS_GSTREAM_C
#define HTS_GSTREAM_C
#ifdef __cplusplus
#define HTS_GSTREAM_C_START extern "C" {
#define HTS_GSTREAM_C_END }
#else
#define HTS_GSTREAM_C_START
#define HTS_GSTREAM_C_END
#endif /* __CPLUSPLUS */
HTS_GSTREAM_C_START;
/* hts_engine libraries */
#include "HTS_hidden.h"
/* HTS_GStreamSet_initialize: initialize generated parameter stream set */
void HTS_GStreamSet_initialize(HTS_GStreamSet * gss)
{
gss->nstream = 0;
gss->total_frame = 0;
gss->total_nsample = 0;
gss->gstream = NULL;
gss->gspeech = NULL;
}
/* HTS_GStreamSet_create: generate speech */
HTS_Boolean HTS_GStreamSet_create(HTS_GStreamSet * gss, HTS_PStreamSet * pss, size_t stage, HTS_Boolean use_log_gain, size_t sampling_rate, size_t fperiod, double alpha, double beta, HTS_Boolean * stop, double volume, HTS_Audio * audio)
{
size_t i, j, k;
size_t msd_frame;
HTS_Vocoder v;
size_t nlpf = 0;
double *lpf = NULL;
/* check */
if (gss->gstream || gss->gspeech) {
HTS_error(1, "HTS_GStreamSet_create: HTS_GStreamSet is not initialized.\n");
return FALSE;
}
/* initialize */
gss->nstream = HTS_PStreamSet_get_nstream(pss);
gss->total_frame = HTS_PStreamSet_get_total_frame(pss);
gss->total_nsample = fperiod * gss->total_frame;
gss->gstream = (HTS_GStream *) HTS_calloc(gss->nstream, sizeof(HTS_GStream));
for (i = 0; i < gss->nstream; i++) {
gss->gstream[i].vector_length = HTS_PStreamSet_get_vector_length(pss, i);
gss->gstream[i].par = (double **) HTS_calloc(gss->total_frame, sizeof(double *));
for (j = 0; j < gss->total_frame; j++)
gss->gstream[i].par[j] = (double *) HTS_calloc(gss->gstream[i].vector_length, sizeof(double));
}
gss->gspeech = (double *) HTS_calloc(gss->total_nsample, sizeof(double));
/* copy generated parameter */
for (i = 0; i < gss->nstream; i++) {
if (HTS_PStreamSet_is_msd(pss, i)) { /* for MSD */
for (j = 0, msd_frame = 0; j < gss->total_frame; j++)
if (HTS_PStreamSet_get_msd_flag(pss, i, j) == TRUE) {
for (k = 0; k < gss->gstream[i].vector_length; k++)
gss->gstream[i].par[j][k] = HTS_PStreamSet_get_parameter(pss, i, msd_frame, k);
msd_frame++;
} else
for (k = 0; k < gss->gstream[i].vector_length; k++)
gss->gstream[i].par[j][k] = HTS_NODATA;
} else { /* for non MSD */
for (j = 0; j < gss->total_frame; j++)
for (k = 0; k < gss->gstream[i].vector_length; k++)
gss->gstream[i].par[j][k] = HTS_PStreamSet_get_parameter(pss, i, j, k);
}
}
/* check */
if (gss->nstream != 2 && gss->nstream != 3) {
HTS_error(1, "HTS_GStreamSet_create: The number of streams should be 2 or 3.\n");
HTS_GStreamSet_clear(gss);
return FALSE;
}
if (HTS_PStreamSet_get_vector_length(pss, 1) != 1) {
HTS_error(1, "HTS_GStreamSet_create: The size of lf0 static vector should be 1.\n");
HTS_GStreamSet_clear(gss);
return FALSE;
}
if (gss->nstream >= 3 && gss->gstream[2].vector_length % 2 == 0) {
HTS_error(1, "HTS_GStreamSet_create: The number of low-pass filter coefficient should be odd numbers.");
HTS_GStreamSet_clear(gss);
return FALSE;
}
/* synthesize speech waveform */
HTS_Vocoder_initialize(&v, gss->gstream[0].vector_length - 1, stage, use_log_gain, sampling_rate, fperiod);
if (gss->nstream >= 3)
nlpf = gss->gstream[2].vector_length;
for (i = 0; i < gss->total_frame && (*stop) == FALSE; i++) {
j = i * fperiod;
if (gss->nstream >= 3)
lpf = &gss->gstream[2].par[i][0];
HTS_Vocoder_synthesize(&v, gss->gstream[0].vector_length - 1, gss->gstream[1].par[i][0], &gss->gstream[0].par[i][0], nlpf, lpf, alpha, beta, volume, &gss->gspeech[j], audio);
}
HTS_Vocoder_clear(&v);
if (audio)
HTS_Audio_flush(audio);
return TRUE;
}
/* HTS_GStreamSet_get_total_nsamples: get total number of sample */
size_t HTS_GStreamSet_get_total_nsamples(HTS_GStreamSet * gss)
{
return gss->total_nsample;
}
/* HTS_GStreamSet_get_total_frame: get total number of frame */
size_t HTS_GStreamSet_get_total_frame(HTS_GStreamSet * gss)
{
return gss->total_frame;
}
/* HTS_GStreamSet_get_vector_length: get features length */
size_t HTS_GStreamSet_get_vector_length(HTS_GStreamSet * gss, size_t stream_index)
{
return gss->gstream[stream_index].vector_length;
}
/* HTS_GStreamSet_get_speech: get synthesized speech parameter */
double HTS_GStreamSet_get_speech(HTS_GStreamSet * gss, size_t sample_index)
{
return gss->gspeech[sample_index];
}
/* HTS_GStreamSet_get_parameter: get generated parameter */
double HTS_GStreamSet_get_parameter(HTS_GStreamSet * gss, size_t stream_index, size_t frame_index, size_t vector_index)
{
return gss->gstream[stream_index].par[frame_index][vector_index];
}
/* HTS_GStreamSet_clear: free generated parameter stream set */
void HTS_GStreamSet_clear(HTS_GStreamSet * gss)
{
size_t i, j;
if (gss->gstream) {
for (i = 0; i < gss->nstream; i++) {
if (gss->gstream[i].par != NULL) {
for (j = 0; j < gss->total_frame; j++)
HTS_free(gss->gstream[i].par[j]);
HTS_free(gss->gstream[i].par);
}
}
HTS_free(gss->gstream);
}
if (gss->gspeech)
HTS_free(gss->gspeech);
HTS_GStreamSet_initialize(gss);
}
HTS_GSTREAM_C_END;
#endif /* !HTS_GSTREAM_C */

510
3rdparty/hts_engine_API/lib/HTS_hidden.h vendored Normal file
View File

@@ -0,0 +1,510 @@
/* ----------------------------------------------------------------- */
/* The HMM-Based Speech Synthesis Engine "hts_engine API" */
/* developed by HTS Working Group */
/* http://hts-engine.sourceforge.net/ */
/* ----------------------------------------------------------------- */
/* */
/* Copyright (c) 2001-2015 Nagoya Institute of Technology */
/* Department of Computer Science */
/* */
/* 2001-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 HTS_HIDDEN_H
#define HTS_HIDDEN_H
#ifdef __cplusplus
#define HTS_HIDDEN_H_START extern "C" {
#define HTS_HIDDEN_H_END }
#else
#define HTS_HIDDEN_H_START
#define HTS_HIDDEN_H_END
#endif /* __CPLUSPLUS */
HTS_HIDDEN_H_START;
/* hts_engine libraries */
#include "HTS_engine.h"
/* common ---------------------------------------------------------- */
#define HTS_MAXBUFLEN 1024
#if !defined(WORDS_BIGENDIAN) && !defined(WORDS_LITTLEENDIAN)
#define WORDS_LITTLEENDIAN
#endif /* !WORDS_BIGENDIAN && !WORDS_LITTLEENDIAN */
#if defined(WORDS_BIGENDIAN) && defined(WORDS_LITTLEENDIAN)
#undef WORDS_BIGENDIAN
#endif /* WORDS_BIGENDIAN && WORDS_LITTLEENDIAN */
#define MAX_F0 20000.0
#define MIN_F0 20.0
#define MAX_LF0 9.9034875525361280454891979401956 /* log(20000.0) */
#define MIN_LF0 2.9957322735539909934352235761425 /* log(20.0) */
#define HALF_TONE 0.05776226504666210911810267678818 /* log(2.0) / 12.0 */
#define DB 0.11512925464970228420089957273422 /* log(10.0) / 20.0 */
/* misc ------------------------------------------------------------ */
typedef struct _HTS_File {
unsigned char type;
void *pointer;
} HTS_File;
/* HTS_fopen: wrapper for fopen */
HTS_File *HTS_fopen_from_fn(const char *name, const char *opt);
/* HTS_fopen_from_fp: wrapper for fopen */
HTS_File *HTS_fopen_from_fp(HTS_File * fp, size_t size);
/* HTS_fopen_from_data: wrapper for fopen */
HTS_File *HTS_fopen_from_data(void *data, size_t size);
/* HTS_fclose: wrapper for fclose */
void HTS_fclose(HTS_File * fp);
/* HTS_fgetc: wrapper for fgetc */
int HTS_fgetc(HTS_File * fp);
/* HTS_feof: wrapper for feof */
int HTS_feof(HTS_File * fp);
/* HTS_fseek: wrapper for fseek */
int HTS_fseek(HTS_File * fp, long offset, int origin);
/* HTS_ftell: wrapper for ftell */
size_t HTS_ftell(HTS_File * fp);
/* HTS_fread_big_endian: fread with byteswap */
size_t HTS_fread_big_endian(void *buf, size_t size, size_t n, HTS_File * fp);
/* HTS_fread_little_endian: fread with byteswap */
size_t HTS_fread_little_endian(void *buf, size_t size, size_t n, HTS_File * fp);
/* HTS_fwrite_little_endian: fwrite with byteswap */
size_t HTS_fwrite_little_endian(const void *buf, size_t size, size_t n, FILE * fp);
/* HTS_get_pattern_token: get pattern token (single/double quote can be used) */
HTS_Boolean HTS_get_pattern_token(HTS_File * fp, char *buff);
/* HTS_get_token: get token from file pointer (separators are space,tab,line break) */
HTS_Boolean HTS_get_token_from_fp(HTS_File * fp, char *buff);
/* HTS_get_token: get token from file pointer with specified separator */
HTS_Boolean HTS_get_token_from_fp_with_separator(HTS_File * fp, char *buff, char separator);
/* HTS_get_token_from_string: get token from string (separator are space,tab,line break) */
HTS_Boolean HTS_get_token_from_string(const char *string, size_t * index, char *buff);
/* HTS_get_token_from_string_with_separator: get token from string with specified separator */
HTS_Boolean HTS_get_token_from_string_with_separator(const char *str, size_t * index, char *buff, char separator);
/* HTS_calloc: wrapper for calloc */
void *HTS_calloc(const size_t num, const size_t size);
/* HTS_strdup: wrapper for strdup */
char *HTS_strdup(const char *string);
/* HTS_calloc_matrix: allocate double matrix */
double **HTS_alloc_matrix(size_t x, size_t y);
/* HTS_free_matrix: free double matrix */
void HTS_free_matrix(double **p, size_t x);
/* HTS_Free: wrapper for free */
void HTS_free(void *p);
/* HTS_error: output error message */
void HTS_error(int error, const char *message, ...);
/* audio ----------------------------------------------------------- */
/* HTS_Audio_initialize: initialize audio */
void HTS_Audio_initialize(HTS_Audio * audio);
/* HTS_Audio_set_parameter: set parameters for audio */
void HTS_Audio_set_parameter(HTS_Audio * audio, size_t sampling_frequency, size_t max_buff_size);
/* HTS_Audio_write: send data to audio */
void HTS_Audio_write(HTS_Audio * audio, short data);
/* HTS_Audio_flush: flush remain data */
void HTS_Audio_flush(HTS_Audio * audio);
/* HTS_Audio_clear: free audio */
void HTS_Audio_clear(HTS_Audio * audio);
/* model ----------------------------------------------------------- */
/* HTS_ModelSet_initialize: initialize model set */
void HTS_ModelSet_initialize(HTS_ModelSet * ms);
/* HTS_ModelSet_load: load HTS voices */
HTS_Boolean HTS_ModelSet_load(HTS_ModelSet * ms, char **voices, size_t num_voices);
/* HTS_ModelSet_get_sampling_frequency: get sampling frequency of HTS voices */
size_t HTS_ModelSet_get_sampling_frequency(HTS_ModelSet * ms);
/* HTS_ModelSet_get_fperiod: get frame period of HTS voices */
size_t HTS_ModelSet_get_fperiod(HTS_ModelSet * ms);
/* HTS_ModelSet_get_fperiod: get stream option */
const char *HTS_ModelSet_get_option(HTS_ModelSet * ms, size_t stream_index);
/* HTS_ModelSet_get_gv_flag: get GV flag */
HTS_Boolean HTS_ModelSet_get_gv_flag(HTS_ModelSet * ms, const char *string);
/* HTS_ModelSet_get_nstate: get number of state */
size_t HTS_ModelSet_get_nstate(HTS_ModelSet * ms);
/* HTS_Engine_get_fullcontext_label_format: get full-context label format */
const char *HTS_ModelSet_get_fullcontext_label_format(HTS_ModelSet * ms);
/* HTS_Engine_get_fullcontext_label_version: get full-context label version */
const char *HTS_ModelSet_get_fullcontext_label_version(HTS_ModelSet * ms);
/* HTS_ModelSet_get_nstream: get number of stream */
size_t HTS_ModelSet_get_nstream(HTS_ModelSet * ms);
/* HTS_ModelSet_get_nvoices: get number of HTS voices */
size_t HTS_ModelSet_get_nvoices(HTS_ModelSet * ms);
/* HTS_ModelSet_get_vector_length: get vector length */
size_t HTS_ModelSet_get_vector_length(HTS_ModelSet * ms, size_t stream_index);
/* HTS_ModelSet_is_msd: get MSD flag */
HTS_Boolean HTS_ModelSet_is_msd(HTS_ModelSet * ms, size_t stream_index);
/* HTS_ModelSet_get_window_size: get dynamic window size */
size_t HTS_ModelSet_get_window_size(HTS_ModelSet * ms, size_t stream_index);
/* HTS_ModelSet_get_window_left_width: get left width of dynamic window */
int HTS_ModelSet_get_window_left_width(HTS_ModelSet * ms, size_t stream_index, size_t window_index);
/* HTS_ModelSet_get_window_right_width: get right width of dynamic window */
int HTS_ModelSet_get_window_right_width(HTS_ModelSet * ms, size_t stream_index, size_t window_index);
/* HTS_ModelSet_get_window_coefficient: get coefficient of dynamic window */
double HTS_ModelSet_get_window_coefficient(HTS_ModelSet * ms, size_t stream_index, size_t window_index, size_t coefficient_index);
/* HTS_ModelSet_get_window_max_width: get max width of dynamic window */
size_t HTS_ModelSet_get_window_max_width(HTS_ModelSet * ms, size_t stream_index);
/* HTS_ModelSet_use_gv: get GV flag */
HTS_Boolean HTS_ModelSet_use_gv(HTS_ModelSet * ms, size_t stream_index);
/* HTS_ModelSet_get_duration_index: get index of duration tree and PDF */
void HTS_ModelSet_get_duration_index(HTS_ModelSet * ms, size_t voice_index, const char *string, size_t * tree_index, size_t * pdf_index);
/* HTS_ModelSet_get_duration: get duration using interpolation weight */
void HTS_ModelSet_get_duration(HTS_ModelSet * ms, const char *string, const double *iw, double *mean, double *vari);
/* HTS_ModelSet_get_parameter_index: get index of parameter tree and PDF */
void HTS_ModelSet_get_parameter_index(HTS_ModelSet * ms, size_t voice_index, size_t stream_index, size_t state_index, const char *string, size_t * tree_index, size_t * pdf_index);
/* HTS_ModelSet_get_parameter: get parameter using interpolation weight */
void HTS_ModelSet_get_parameter(HTS_ModelSet * ms, size_t stream_index, size_t state_index, const char *string, const double *const *iw, double *mean, double *vari, double *msd);
void HTS_ModelSet_get_gv_index(HTS_ModelSet * ms, size_t voice_index, size_t stream_index, const char *string, size_t * tree_index, size_t * pdf_index);
/* HTS_ModelSet_get_gv: get GV using interpolation weight */
void HTS_ModelSet_get_gv(HTS_ModelSet * ms, size_t stream_index, const char *string, const double *const *iw, double *mean, double *vari);
/* HTS_ModelSet_clear: free model set */
void HTS_ModelSet_clear(HTS_ModelSet * ms);
/* label ----------------------------------------------------------- */
/* HTS_Label_initialize: initialize label */
void HTS_Label_initialize(HTS_Label * label);
/* HTS_Label_load_from_fn: load label from file name */
void HTS_Label_load_from_fn(HTS_Label * label, size_t sampling_rate, size_t fperiod, const char *fn);
/* HTS_Label_load_from_strings: load label list from string list */
void HTS_Label_load_from_strings(HTS_Label * label, size_t sampling_rate, size_t fperiod, char **lines, size_t num_lines);
/* HTS_Label_get_size: get number of label string */
size_t HTS_Label_get_size(HTS_Label * label);
/* HTS_Label_get_string: get label string */
const char *HTS_Label_get_string(HTS_Label * label, size_t index);
/* HTS_Label_get_start_frame: get start frame */
double HTS_Label_get_start_frame(HTS_Label * label, size_t index);
/* HTS_Label_get_end_frame: get end frame */
double HTS_Label_get_end_frame(HTS_Label * label, size_t index);
/* HTS_Label_clear: free label */
void HTS_Label_clear(HTS_Label * label);
/* sstream --------------------------------------------------------- */
/* HTS_SStreamSet_initialize: initialize state stream set */
void HTS_SStreamSet_initialize(HTS_SStreamSet * sss);
/* HTS_SStreamSet_create: parse label and determine state duration */
HTS_Boolean HTS_SStreamSet_create(HTS_SStreamSet * sss, HTS_ModelSet * ms, HTS_Label * label, HTS_Boolean phoneme_alignment_flag, double speed, double *duration_iw, double **parameter_iw, double **gv_iw);
/* HTS_SStreamSet_get_nstream: get number of stream */
size_t HTS_SStreamSet_get_nstream(HTS_SStreamSet * sss);
/* HTS_SStreamSet_get_vector_length: get vector length */
size_t HTS_SStreamSet_get_vector_length(HTS_SStreamSet * sss, size_t stream_index);
/* HTS_SStreamSet_is_msd: get MSD flag */
HTS_Boolean HTS_SStreamSet_is_msd(HTS_SStreamSet * sss, size_t stream_index);
/* HTS_SStreamSet_get_total_state: get total number of state */
size_t HTS_SStreamSet_get_total_state(HTS_SStreamSet * sss);
/* HTS_SStreamSet_get_total_frame: get total number of frame */
size_t HTS_SStreamSet_get_total_frame(HTS_SStreamSet * sss);
/* HTS_SStreamSet_get_msd: get msd parameter */
double HTS_SStreamSet_get_msd(HTS_SStreamSet * sss, size_t stream_index, size_t state_index);
/* HTS_SStreamSet_window_size: get dynamic window size */
size_t HTS_SStreamSet_get_window_size(HTS_SStreamSet * sss, size_t stream_index);
/* HTS_SStreamSet_get_window_left_width: get left width of dynamic window */
int HTS_SStreamSet_get_window_left_width(HTS_SStreamSet * sss, size_t stream_index, size_t window_index);
/* HTS_SStreamSet_get_window_right_width: get right width of dynamic window */
int HTS_SStreamSet_get_window_right_width(HTS_SStreamSet * sss, size_t stream_index, size_t window_index);
/* HTS_SStreamSet_get_window_coefficient: get coefficient of dynamic window */
double HTS_SStreamSet_get_window_coefficient(HTS_SStreamSet * sss, size_t stream_index, size_t window_index, int coefficient_index);
/* HTS_SStreamSet_get_window_max_width: get max width of dynamic window */
size_t HTS_SStreamSet_get_window_max_width(HTS_SStreamSet * sss, size_t stream_index);
/* HTS_SStreamSet_use_gv: get GV flag */
HTS_Boolean HTS_SStreamSet_use_gv(HTS_SStreamSet * sss, size_t stream_index);
/* HTS_SStreamSet_get_duration: get state duration */
size_t HTS_SStreamSet_get_duration(HTS_SStreamSet * sss, size_t state_index);
/* HTS_SStreamSet_get_mean: get mean parameter */
double HTS_SStreamSet_get_mean(HTS_SStreamSet * sss, size_t stream_index, size_t state_index, size_t vector_index);
/* HTS_SStreamSet_set_mean: set mean parameter */
void HTS_SStreamSet_set_mean(HTS_SStreamSet * sss, size_t stream_index, size_t state_index, size_t vector_index, double f);
/* HTS_SStreamSet_get_vari: get variance parameter */
double HTS_SStreamSet_get_vari(HTS_SStreamSet * sss, size_t stream_index, size_t state_index, size_t vector_index);
/* HTS_SStreamSet_set_vari: set variance parameter */
void HTS_SStreamSet_set_vari(HTS_SStreamSet * sss, size_t stream_index, size_t state_index, size_t vector_index, double f);
/* HTS_SStreamSet_get_gv_mean: get GV mean parameter */
double HTS_SStreamSet_get_gv_mean(HTS_SStreamSet * sss, size_t stream_index, size_t vector_index);
/* HTS_SStreamSet_get_gv_mean: get GV variance parameter */
double HTS_SStreamSet_get_gv_vari(HTS_SStreamSet * sss, size_t stream_index, size_t vector_index);
/* HTS_SStreamSet_set_gv_switch: set GV switch */
void HTS_SStreamSet_set_gv_switch(HTS_SStreamSet * sss, size_t stream_index, size_t state_index, HTS_Boolean i);
/* HTS_SStreamSet_get_gv_switch: get GV switch */
HTS_Boolean HTS_SStreamSet_get_gv_switch(HTS_SStreamSet * sss, size_t stream_index, size_t state_index);
/* HTS_SStreamSet_clear: free state stream set */
void HTS_SStreamSet_clear(HTS_SStreamSet * sss);
/* pstream --------------------------------------------------------- */
/* check variance in finv() */
#define INFTY ((double) 1.0e+38)
#define INFTY2 ((double) 1.0e+19)
#define INVINF ((double) 1.0e-38)
#define INVINF2 ((double) 1.0e-19)
/* GV */
#define STEPINIT 0.1
#define STEPDEC 0.5
#define STEPINC 1.2
#define W1 1.0
#define W2 1.0
#define GV_MAX_ITERATION 5
/* HTS_PStreamSet_initialize: initialize parameter stream set */
void HTS_PStreamSet_initialize(HTS_PStreamSet * pss);
/* HTS_PStreamSet_create: parameter generation using GV weight */
HTS_Boolean HTS_PStreamSet_create(HTS_PStreamSet * pss, HTS_SStreamSet * sss, double *msd_threshold, double *gv_weight);
/* HTS_PStreamSet_get_nstream: get number of stream */
size_t HTS_PStreamSet_get_nstream(HTS_PStreamSet * pss);
/* HTS_PStreamSet_get_static_length: get features length */
size_t HTS_PStreamSet_get_vector_length(HTS_PStreamSet * pss, size_t stream_index);
/* HTS_PStreamSet_get_total_frame: get total number of frame */
size_t HTS_PStreamSet_get_total_frame(HTS_PStreamSet * pss);
/* HTS_PStreamSet_get_parameter: get parameter */
double HTS_PStreamSet_get_parameter(HTS_PStreamSet * pss, size_t stream_index, size_t frame_index, size_t vector_index);
/* HTS_PStreamSet_get_parameter_vector: get parameter vector */
double *HTS_PStreamSet_get_parameter_vector(HTS_PStreamSet * pss, size_t stream_index, size_t frame_index);
/* HTS_PStreamSet_get_msd_flag: get generated MSD flag per frame */
HTS_Boolean HTS_PStreamSet_get_msd_flag(HTS_PStreamSet * pss, size_t stream_index, size_t frame_index);
/* HTS_PStreamSet_is_msd: get MSD flag */
HTS_Boolean HTS_PStreamSet_is_msd(HTS_PStreamSet * pss, size_t stream_index);
/* HTS_PStreamSet_clear: free parameter stream set */
void HTS_PStreamSet_clear(HTS_PStreamSet * pss);
/* gstream --------------------------------------------------------- */
/* HTS_GStreamSet_initialize: initialize generated parameter stream set */
void HTS_GStreamSet_initialize(HTS_GStreamSet * gss);
/* HTS_GStreamSet_create: generate speech */
HTS_Boolean HTS_GStreamSet_create(HTS_GStreamSet * gss, HTS_PStreamSet * pss, size_t stage, HTS_Boolean use_log_gain, size_t sampling_rate, size_t fperiod, double alpha, double beta, HTS_Boolean * stop, double volume, HTS_Audio * audio);
/* HTS_GStreamSet_get_total_nsamples: get total number of sample */
size_t HTS_GStreamSet_get_total_nsamples(HTS_GStreamSet * gss);
/* HTS_GStreamSet_get_total_frame: get total number of frame */
size_t HTS_GStreamSet_get_total_frame(HTS_GStreamSet * gss);
/* HTS_GStreamSet_get_static_length: get features length */
size_t HTS_GStreamSet_get_vector_length(HTS_GStreamSet * gss, size_t stream_index);
/* HTS_GStreamSet_get_speech: get synthesized speech parameter */
double HTS_GStreamSet_get_speech(HTS_GStreamSet * gss, size_t sample_index);
/* HTS_GStreamSet_get_parameter: get generated parameter */
double HTS_GStreamSet_get_parameter(HTS_GStreamSet * gss, size_t stream_index, size_t frame_index, size_t vector_index);
/* HTS_GStreamSet_clear: free generated parameter stream set */
void HTS_GStreamSet_clear(HTS_GStreamSet * gss);
/* vocoder --------------------------------------------------------- */
#ifndef LZERO
#define LZERO (-1.0e+10) /* ~log(0) */
#endif /* !LZERO */
#ifndef ZERO
#define ZERO (1.0e-10) /* ~(0) */
#endif /* !ZERO */
#ifndef PI
#define PI 3.14159265358979323846
#endif /* !PI */
#ifndef PI2
#define PI2 6.28318530717958647692
#endif /* !PI2 */
#define RANDMAX 32767
#define SEED 1
#define B0 0x00000001
#define B28 0x10000000
#define B31 0x80000000
#define B31_ 0x7fffffff
#define Z 0x00000000
#ifdef HTS_EMBEDDED
#define GAUSS FALSE
#define PADEORDER 4 /* pade order (for MLSA filter) */
#define IRLENG 384 /* length of impulse response */
#else
#define GAUSS TRUE
#define PADEORDER 5
#define IRLENG 576
#endif /* HTS_EMBEDDED */
#define CHECK_LSP_STABILITY_MIN 0.25
#define CHECK_LSP_STABILITY_NUM 4
/* for MGLSA filter */
#define NORMFLG1 TRUE
#define NORMFLG2 FALSE
#define MULGFLG1 TRUE
#define MULGFLG2 FALSE
#define NGAIN FALSE
/* HTS_Vocoder: structure for setting of vocoder */
typedef struct _HTS_Vocoder {
HTS_Boolean is_first;
size_t stage; /* Gamma=-1/stage: if stage=0 then Gamma=0 */
double gamma; /* Gamma */
HTS_Boolean use_log_gain; /* log gain flag (for LSP) */
size_t fprd; /* frame shift */
unsigned long next; /* temporary variable for random generator */
HTS_Boolean gauss; /* flag to use Gaussian noise */
double rate; /* sampling rate */
double pitch_of_curr_point; /* used in excitation generation */
double pitch_counter; /* used in excitation generation */
double pitch_inc_per_point; /* used in excitation generation */
double *excite_ring_buff; /* used in excitation generation */
size_t excite_buff_size; /* used in excitation generation */
size_t excite_buff_index; /* used in excitation generation */
unsigned char sw; /* switch used in random generator */
int x; /* excitation signal */
double *freqt_buff; /* used in freqt */
size_t freqt_size; /* buffer size for freqt */
double *spectrum2en_buff; /* used in spectrum2en */
size_t spectrum2en_size; /* buffer size for spectrum2en */
double r1, r2, s; /* used in random generator */
double *postfilter_buff; /* used in postfiltering */
size_t postfilter_size; /* buffer size for postfiltering */
double *c, *cc, *cinc, *d1; /* used in the MLSA/MGLSA filter */
double *lsp2lpc_buff; /* used in lsp2lpc */
size_t lsp2lpc_size; /* buffer size of lsp2lpc */
double *gc2gc_buff; /* used in gc2gc */
size_t gc2gc_size; /* buffer size for gc2gc */
} HTS_Vocoder;
/* HTS_Vocoder_initialize: initialize vocoder */
void HTS_Vocoder_initialize(HTS_Vocoder * v, size_t m, size_t stage, HTS_Boolean use_log_gain, size_t rate, size_t fperiod);
/* HTS_Vocoder_synthesize: pulse/noise excitation and MLSA/MGLSA filster based waveform synthesis */
void HTS_Vocoder_synthesize(HTS_Vocoder * v, size_t m, double lf0, double *spectrum, size_t nlpf, double *lpf, double alpha, double beta, double volume, double *rawdata, HTS_Audio * audio);
/* HTS_Vocoder_clear: clear vocoder */
void HTS_Vocoder_clear(HTS_Vocoder * v);
HTS_HIDDEN_H_END;
#endif /* !HTS_HIDDEN_H */

263
3rdparty/hts_engine_API/lib/HTS_label.c vendored Normal file
View File

@@ -0,0 +1,263 @@
/* ----------------------------------------------------------------- */
/* The HMM-Based Speech Synthesis Engine "hts_engine API" */
/* developed by HTS Working Group */
/* http://hts-engine.sourceforge.net/ */
/* ----------------------------------------------------------------- */
/* */
/* Copyright (c) 2001-2015 Nagoya Institute of Technology */
/* Department of Computer Science */
/* */
/* 2001-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 HTS_LABEL_C
#define HTS_LABEL_C
#ifdef __cplusplus
#define HTS_LABEL_C_START extern "C" {
#define HTS_LABEL_C_END }
#else
#define HTS_LABEL_C_START
#define HTS_LABEL_C_END
#endif /* __CPLUSPLUS */
HTS_LABEL_C_START;
#include <stdlib.h> /* for atof() */
#include <ctype.h> /* for isgraph(),isdigit() */
/* hts_engine libraries */
#include "HTS_hidden.h"
static HTS_Boolean isdigit_string(char *str)
{
int i;
if (sscanf(str, "%d", &i) == 1)
return TRUE;
else
return FALSE;
}
/* HTS_Label_initialize: initialize label */
void HTS_Label_initialize(HTS_Label * label)
{
label->head = NULL;
label->size = 0;
}
/* HTS_Label_check_time: check label */
static void HTS_Label_check_time(HTS_Label * label)
{
HTS_LabelString *lstring = label->head;
HTS_LabelString *next = NULL;
if (lstring)
lstring->start = 0.0;
while (lstring) {
next = lstring->next;
if (!next)
break;
if (lstring->end < 0.0 && next->start >= 0.0)
lstring->end = next->start;
else if (lstring->end >= 0.0 && next->start < 0.0)
next->start = lstring->end;
if (lstring->start < 0.0)
lstring->start = -1.0;
if (lstring->end < 0.0)
lstring->end = -1.0;
lstring = next;
}
}
/* HTS_Label_load: load label */
static void HTS_Label_load(HTS_Label * label, size_t sampling_rate, size_t fperiod, HTS_File * fp)
{
char buff[HTS_MAXBUFLEN];
HTS_LabelString *lstring = NULL;
double start, end;
const double rate = (double) sampling_rate / ((double) fperiod * 1e+7);
if (label->head || label->size != 0) {
HTS_error(1, "HTS_Label_load_from_fp: label is not initialized.\n");
return;
}
/* parse label file */
while (HTS_get_token_from_fp(fp, buff)) {
if (!isgraph((int) buff[0]))
break;
label->size++;
if (lstring) {
lstring->next = (HTS_LabelString *) HTS_calloc(1, sizeof(HTS_LabelString));
lstring = lstring->next;
} else { /* first time */
lstring = (HTS_LabelString *) HTS_calloc(1, sizeof(HTS_LabelString));
label->head = lstring;
}
if (isdigit_string(buff)) { /* has frame infomation */
start = atof(buff);
HTS_get_token_from_fp(fp, buff);
end = atof(buff);
HTS_get_token_from_fp(fp, buff);
lstring->start = rate * start;
lstring->end = rate * end;
} else {
lstring->start = -1.0;
lstring->end = -1.0;
}
lstring->next = NULL;
lstring->name = HTS_strdup(buff);
}
HTS_Label_check_time(label);
}
/* HTS_Label_load_from_fn: load label from file name */
void HTS_Label_load_from_fn(HTS_Label * label, size_t sampling_rate, size_t fperiod, const char *fn)
{
HTS_File *fp = HTS_fopen_from_fn(fn, "r");
HTS_Label_load(label, sampling_rate, fperiod, fp);
HTS_fclose(fp);
}
/* HTS_Label_load_from_strings: load label from strings */
void HTS_Label_load_from_strings(HTS_Label * label, size_t sampling_rate, size_t fperiod, char **lines, size_t num_lines)
{
char buff[HTS_MAXBUFLEN];
HTS_LabelString *lstring = NULL;
size_t i;
size_t data_index;
double start, end;
const double rate = (double) sampling_rate / ((double) fperiod * 1e+7);
if (label->head || label->size != 0) {
HTS_error(1, "HTS_Label_load_from_fp: label list is not initialized.\n");
return;
}
/* copy label */
for (i = 0; i < num_lines; i++) {
if (!isgraph((int) lines[i][0]))
break;
label->size++;
if (lstring) {
lstring->next = (HTS_LabelString *) HTS_calloc(1, sizeof(HTS_LabelString));
lstring = lstring->next;
} else { /* first time */
lstring = (HTS_LabelString *) HTS_calloc(1, sizeof(HTS_LabelString));
label->head = lstring;
}
data_index = 0;
if (isdigit_string(lines[i])) { /* has frame infomation */
HTS_get_token_from_string(lines[i], &data_index, buff);
start = atof(buff);
HTS_get_token_from_string(lines[i], &data_index, buff);
end = atof(buff);
HTS_get_token_from_string(lines[i], &data_index, buff);
lstring->name = HTS_strdup(buff);
lstring->start = rate * start;
lstring->end = rate * end;
} else {
lstring->start = -1.0;
lstring->end = -1.0;
lstring->name = HTS_strdup(lines[i]);
}
lstring->next = NULL;
}
HTS_Label_check_time(label);
}
/* HTS_Label_get_size: get number of label string */
size_t HTS_Label_get_size(HTS_Label * label)
{
return label->size;
}
/* HTS_Label_get_string: get label string */
const char *HTS_Label_get_string(HTS_Label * label, size_t index)
{
size_t i;
HTS_LabelString *lstring = label->head;
for (i = 0; i < index && lstring; i++)
lstring = lstring->next;
if (!lstring)
return NULL;
return lstring->name;
}
/* HTS_Label_get_start_frame: get start frame */
double HTS_Label_get_start_frame(HTS_Label * label, size_t index)
{
size_t i;
HTS_LabelString *lstring = label->head;
for (i = 0; i < index && lstring; i++)
lstring = lstring->next;
if (!lstring)
return -1.0;
return lstring->start;
}
/* HTS_Label_get_end_frame: get end frame */
double HTS_Label_get_end_frame(HTS_Label * label, size_t index)
{
size_t i;
HTS_LabelString *lstring = label->head;
for (i = 0; i < index && lstring; i++)
lstring = lstring->next;
if (!lstring)
return -1.0;
return lstring->end;
}
/* HTS_Label_clear: free label */
void HTS_Label_clear(HTS_Label * label)
{
HTS_LabelString *lstring, *next_lstring;
for (lstring = label->head; lstring; lstring = next_lstring) {
next_lstring = lstring->next;
HTS_free(lstring->name);
HTS_free(lstring);
}
HTS_Label_initialize(label);
}
HTS_LABEL_C_END;
#endif /* !HTS_LABEL_C */

649
3rdparty/hts_engine_API/lib/HTS_misc.c vendored Executable file
View File

@@ -0,0 +1,649 @@
/* ----------------------------------------------------------------- */
/* The HMM-Based Speech Synthesis Engine "hts_engine API" */
/* developed by HTS Working Group */
/* http://hts-engine.sourceforge.net/ */
/* ----------------------------------------------------------------- */
/* */
/* Copyright (c) 2001-2015 Nagoya Institute of Technology */
/* Department of Computer Science */
/* */
/* 2001-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 HTS_MISC_C
#define HTS_MISC_C
#ifdef __cplusplus
#define HTS_MISC_C_START extern "C" {
#define HTS_MISC_C_END }
#else
#define HTS_MISC_C_START
#define HTS_MISC_C_END
#endif /* __CPLUSPLUS */
HTS_MISC_C_START;
#include <stdlib.h> /* for exit(),calloc(),free() */
#include <stdarg.h> /* for va_list */
#include <string.h> /* for strcpy(),strlen() */
/* hts_engine libraries */
#include "HTS_hidden.h"
#ifdef FESTIVAL
#include "EST_walloc.h"
#endif /* FESTIVAL */
#define HTS_FILE 0
#define HTS_DATA 1
typedef struct _HTS_Data {
unsigned char *data;
size_t size;
size_t index;
} HTS_Data;
#if defined(_WIN32)
#include <windows.h>
#define MAX_PATH_SIZE 8192
#define ARRAY_SIZE(array) (sizeof(array) / sizeof(array[0]))
// Encode 'path' which is assumed UTF-8 string, into UNICODE string.
// wbuf and wbuf_len is a target buffer and its length.
static void to_wchar(const char *path, wchar_t *wbuf, size_t wbuf_len) {
char buf[MAX_PATH_SIZE * 2], buf2[MAX_PATH_SIZE * 2], *p;
strncpy(buf, path, sizeof(buf));
buf[sizeof(buf) - 1] = '\0';
// Trim trailing slashes. Leave backslash for paths like "X:\"
p = buf + strlen(buf) - 1;
while (p > buf && p[-1] != ':' && (p[0] == '\\' || p[0] == '/')) *p-- = '\0';
// Convert to Unicode and back. If doubly-converted string does not
// match the original, something is fishy, reject.
memset(wbuf, 0, wbuf_len * sizeof(wchar_t));
MultiByteToWideChar(CP_UTF8, 0, buf, -1, wbuf, (int) wbuf_len);
WideCharToMultiByte(CP_UTF8, 0, wbuf, (int) wbuf_len, buf2, sizeof(buf2),
NULL, NULL);
if (strcmp(buf, buf2) != 0) {
wbuf[0] = L'\0';
}
}
#endif
/* HTS_fopen_from_fn: wrapper for fopen */
HTS_File *HTS_fopen_from_fn(const char *name, const char *opt)
{
HTS_File *fp = (HTS_File *) HTS_calloc(1, sizeof(HTS_File));
fp->type = HTS_FILE;
#if defined(_WIN32)
wchar_t wpath[MAX_PATH_SIZE], wmode[10];
to_wchar(name, wpath, ARRAY_SIZE(wpath));
to_wchar(opt, wmode, ARRAY_SIZE(wmode));
fp->pointer = (void*) _wfopen(wpath, wmode);
#else
fp->pointer = (void *) fopen(name, opt);
#endif
if (fp->pointer == NULL) {
HTS_error(0, "HTS_fopen: Cannot open %s.\n", name);
HTS_free(fp);
return NULL;
}
return fp;
}
/* HTS_fopen_from_fp: wrapper for fopen */
HTS_File *HTS_fopen_from_fp(HTS_File * fp, size_t size)
{
if (fp == NULL || size == 0)
return NULL;
else if (fp->type == HTS_FILE) {
HTS_Data *d;
HTS_File *f;
d = (HTS_Data *) HTS_calloc(1, sizeof(HTS_Data));
d->data = (unsigned char *) HTS_calloc(size, sizeof(unsigned char));
d->size = size;
d->index = 0;
if (fread(d->data, sizeof(unsigned char), size, (FILE *) fp->pointer) != size) {
free(d->data);
free(d);
return NULL;
}
f = (HTS_File *) HTS_calloc(1, sizeof(HTS_File));
f->type = HTS_DATA;
f->pointer = (void *) d;
return f;
} else if (fp->type == HTS_DATA) {
HTS_File *f;
HTS_Data *tmp1, *tmp2;
tmp1 = (HTS_Data *) fp->pointer;
if (tmp1->index + size > tmp1->size)
return NULL;
tmp2 = (HTS_Data *) HTS_calloc(1, sizeof(HTS_Data));
tmp2->data = (unsigned char *) HTS_calloc(size, sizeof(unsigned char));
tmp2->size = size;
tmp2->index = 0;
memcpy(tmp2->data, &tmp1->data[tmp1->index], size);
tmp1->index += size;
f = (HTS_File *) HTS_calloc(1, sizeof(HTS_File));
f->type = HTS_DATA;
f->pointer = (void *) tmp2;
return f;
}
HTS_error(0, "HTS_fopen_from_fp: Unknown file type.\n");
return NULL;
}
/* HTS_fopen_from_data: wrapper for fopen */
HTS_File *HTS_fopen_from_data(void *data, size_t size)
{
HTS_Data *d;
HTS_File *f;
if (data == NULL || size == 0)
return NULL;
d = (HTS_Data *) HTS_calloc(1, sizeof(HTS_Data));
d->data = (unsigned char *) HTS_calloc(size, sizeof(unsigned char));
d->size = size;
d->index = 0;
memcpy(d->data, data, size);
f = (HTS_File *) HTS_calloc(1, sizeof(HTS_File));
f->type = HTS_DATA;
f->pointer = (void *) d;
return f;
}
/* HTS_fclose: wrapper for fclose */
void HTS_fclose(HTS_File * fp)
{
if (fp == NULL) {
return;
} else if (fp->type == HTS_FILE) {
if (fp->pointer != NULL)
fclose((FILE *) fp->pointer);
HTS_free(fp);
return;
} else if (fp->type == HTS_DATA) {
if (fp->pointer != NULL) {
HTS_Data *d = (HTS_Data *) fp->pointer;
if (d->data != NULL)
HTS_free(d->data);
HTS_free(d);
}
HTS_free(fp);
return;
}
HTS_error(0, "HTS_fclose: Unknown file type.\n");
}
/* HTS_fgetc: wrapper for fgetc */
int HTS_fgetc(HTS_File * fp)
{
if (fp == NULL) {
return EOF;
} else if (fp->type == HTS_FILE) {
return fgetc((FILE *) fp->pointer);
} else if (fp->type == HTS_DATA) {
HTS_Data *d = (HTS_Data *) fp->pointer;
if (d->size <= d->index)
return EOF;
return (int) d->data[d->index++];
}
HTS_error(0, "HTS_fgetc: Unknown file type.\n");
return EOF;
}
/* HTS_feof: wrapper for feof */
int HTS_feof(HTS_File * fp)
{
if (fp == NULL) {
return 1;
} else if (fp->type == HTS_FILE) {
return feof((FILE *) fp->pointer);
} else if (fp->type == HTS_DATA) {
HTS_Data *d = (HTS_Data *) fp->pointer;
return d->size <= d->index ? 1 : 0;
}
HTS_error(0, "HTS_feof: Unknown file type.\n");
return 1;
}
/* HTS_fseek: wrapper for fseek */
int HTS_fseek(HTS_File * fp, long offset, int origin)
{
if (fp == NULL) {
return 1;
} else if (fp->type == HTS_FILE) {
return fseek((FILE *) fp->pointer, offset, origin);
} else if (fp->type == HTS_DATA) {
HTS_Data *d = (HTS_Data *) fp->pointer;
if (origin == SEEK_SET) {
d->index = (size_t) offset;
} else if (origin == SEEK_CUR) {
d->index += offset;
} else if (origin == SEEK_END) {
d->index = d->size + offset;
} else {
return 1;
}
return 0;
}
HTS_error(0, "HTS_fseek: Unknown file type.\n");
return 1;
}
/* HTS_ftell: rapper for ftell */
size_t HTS_ftell(HTS_File * fp)
{
if (fp == NULL) {
return 0;
} else if (fp->type == HTS_FILE) {
fpos_t pos;
fgetpos((FILE *) fp->pointer, &pos);
#if defined(_WIN32) || defined(__CYGWIN__) || defined(__APPLE__) || defined(__FreeBSD__) || defined(__ANDROID__) || defined(__OpenBSD__)
return (size_t) pos;
#else
return (size_t) pos.__pos;
#endif /* _WIN32 || __CYGWIN__ || __APPLE__ || __ANDROID__ */
} else if (fp->type == HTS_DATA) {
HTS_Data *d = (HTS_Data *) fp->pointer;
return d->index;
}
HTS_error(0, "HTS_ftell: Unknown file type.\n");
return 0;
}
/* HTS_fread: wrapper for fread */
static size_t HTS_fread(void *buf, size_t size, size_t n, HTS_File * fp)
{
if (fp == NULL || size == 0 || n == 0) {
return 0;
}
if (fp->type == HTS_FILE) {
return fread(buf, size, n, (FILE *) fp->pointer);
} else if (fp->type == HTS_DATA) {
HTS_Data *d = (HTS_Data *) fp->pointer;
size_t i, length = size * n;
unsigned char *c = (unsigned char *) buf;
for (i = 0; i < length; i++) {
if (d->index < d->size)
c[i] = d->data[d->index++];
else
break;
}
if (i == 0)
return 0;
else
return i / size;
}
HTS_error(0, "HTS_fread: Unknown file type.\n");
return 0;
}
/* HTS_byte_swap: byte swap */
static void HTS_byte_swap(void *p, size_t size, size_t block)
{
char *q, tmp;
size_t i, j;
q = (char *) p;
for (i = 0; i < block; i++) {
for (j = 0; j < (size / 2); j++) {
tmp = *(q + j);
*(q + j) = *(q + (size - 1 - j));
*(q + (size - 1 - j)) = tmp;
}
q += size;
}
}
/* HTS_fread_big_endian: fread with byteswap */
size_t HTS_fread_big_endian(void *buf, size_t size, size_t n, HTS_File * fp)
{
size_t block = HTS_fread(buf, size, n, fp);
#ifdef WORDS_LITTLEENDIAN
HTS_byte_swap(buf, size, block);
#endif /* WORDS_LITTLEENDIAN */
return block;
}
/* HTS_fread_little_endian: fread with byteswap */
size_t HTS_fread_little_endian(void *buf, size_t size, size_t n, HTS_File * fp)
{
size_t block = HTS_fread(buf, size, n, fp);
#ifdef WORDS_BIGENDIAN
HTS_byte_swap(buf, size, block);
#endif /* WORDS_BIGENDIAN */
return block;
}
/* HTS_fwrite_little_endian: fwrite with byteswap */
size_t HTS_fwrite_little_endian(const void *buf, size_t size, size_t n, FILE * fp)
{
#ifdef WORDS_BIGENDIAN
HTS_byte_swap(buf, size, n * size);
#endif /* WORDS_BIGENDIAN */
return fwrite(buf, size, n, fp);
}
/* HTS_get_pattern_token: get pattern token (single/double quote can be used) */
HTS_Boolean HTS_get_pattern_token(HTS_File * fp, char *buff)
{
char c;
size_t i;
HTS_Boolean squote = FALSE, dquote = FALSE;
if (fp == NULL || HTS_feof(fp))
return FALSE;
c = HTS_fgetc(fp);
while (c == ' ' || c == '\n') {
if (HTS_feof(fp))
return FALSE;
c = HTS_fgetc(fp);
}
if (c == '\'') { /* single quote case */
if (HTS_feof(fp))
return FALSE;
c = HTS_fgetc(fp);
squote = TRUE;
}
if (c == '\"') { /*double quote case */
if (HTS_feof(fp))
return FALSE;
c = HTS_fgetc(fp);
dquote = TRUE;
}
if (c == ',') { /*special character ',' */
strcpy(buff, ",");
return TRUE;
}
i = 0;
while (1) {
buff[i++] = c;
c = HTS_fgetc(fp);
if (squote && c == '\'')
break;
if (dquote && c == '\"')
break;
if (!squote && !dquote) {
if (c == ' ')
break;
if (c == '\n')
break;
if (HTS_feof(fp))
break;
}
}
buff[i] = '\0';
return TRUE;
}
/* HTS_get_token: get token from file pointer (separators are space, tab, and line break) */
HTS_Boolean HTS_get_token_from_fp(HTS_File * fp, char *buff)
{
char c;
size_t i;
if (fp == NULL || HTS_feof(fp))
return FALSE;
c = HTS_fgetc(fp);
while (c == ' ' || c == '\n' || c == '\t') {
if (HTS_feof(fp))
return FALSE;
c = HTS_fgetc(fp);
if (c == EOF)
return FALSE;
}
for (i = 0; c != ' ' && c != '\n' && c != '\t';) {
buff[i++] = c;
if (HTS_feof(fp))
break;
c = HTS_fgetc(fp);
if (c == EOF)
break;
}
buff[i] = '\0';
return TRUE;
}
/* HTS_get_token_with_separator: get token from file pointer with specified separator */
HTS_Boolean HTS_get_token_from_fp_with_separator(HTS_File * fp, char *buff, char separator)
{
char c;
size_t i;
if (fp == NULL || HTS_feof(fp))
return FALSE;
c = HTS_fgetc(fp);
while (c == separator) {
if (HTS_feof(fp))
return FALSE;
c = HTS_fgetc(fp);
if (c == EOF)
return FALSE;
}
for (i = 0; c != separator;) {
buff[i++] = c;
if (HTS_feof(fp))
break;
c = HTS_fgetc(fp);
if (c == EOF)
break;
}
buff[i] = '\0';
return TRUE;
}
/* HTS_get_token_from_string: get token from string (separators are space, tab, and line break) */
HTS_Boolean HTS_get_token_from_string(const char *string, size_t * index, char *buff)
{
char c;
size_t i;
c = string[(*index)];
if (c == '\0')
return FALSE;
c = string[(*index)++];
if (c == '\0')
return FALSE;
while (c == ' ' || c == '\n' || c == '\t') {
if (c == '\0')
return FALSE;
c = string[(*index)++];
}
for (i = 0; c != ' ' && c != '\n' && c != '\t' && c != '\0'; i++) {
buff[i] = c;
c = string[(*index)++];
}
buff[i] = '\0';
return TRUE;
}
/* HTS_get_token_from_string_with_separator: get token from string with specified separator */
HTS_Boolean HTS_get_token_from_string_with_separator(const char *str, size_t * index, char *buff, char separator)
{
char c;
size_t len = 0;
if (str == NULL)
return FALSE;
c = str[(*index)];
if (c == '\0')
return FALSE;
while (c == separator) {
if (c == '\0')
return FALSE;
(*index)++;
c = str[(*index)];
}
while (c != separator && c != '\0') {
buff[len++] = c;
(*index)++;
c = str[(*index)];
}
if (c != '\0')
(*index)++;
buff[len] = '\0';
if (len > 0)
return TRUE;
else
return FALSE;
}
/* HTS_calloc: wrapper for calloc */
void *HTS_calloc(const size_t num, const size_t size)
{
size_t n = num * size;
void *mem;
if (n == 0)
return NULL;
#ifdef FESTIVAL
mem = (void *) safe_wcalloc(n);
#else
mem = (void *) malloc(n);
#endif /* FESTIVAL */
if (mem == NULL) {
HTS_error(1, "HTS_calloc: Cannot allocate memory.\n");
}
memset(mem, 0, n);
return mem;
}
/* HTS_Free: wrapper for free */
void HTS_free(void *ptr)
{
#ifdef FESTIVAL
wfree(ptr);
#else
free(ptr);
#endif /* FESTIVAL */
}
/* HTS_strdup: wrapper for strdup */
char *HTS_strdup(const char *string)
{
#ifdef FESTIVAL
return (wstrdup(string));
#else
char *buff = (char *) HTS_calloc(strlen(string) + 1, sizeof(char));
strcpy(buff, string);
return buff;
#endif /* FESTIVAL */
}
/* HTS_alloc_matrix: allocate double matrix */
double **HTS_alloc_matrix(size_t x, size_t y)
{
size_t i;
double **p;
if (x == 0 || y == 0)
return NULL;
p = (double **) HTS_calloc(x, sizeof(double *));
for (i = 0; i < x; i++)
p[i] = (double *) HTS_calloc(y, sizeof(double));
return p;
}
/* HTS_free_matrix: free double matrix */
void HTS_free_matrix(double **p, size_t x)
{
size_t i;
for (i = 0; i < x; i++)
HTS_free(p[i]);
HTS_free(p);
}
/* HTS_error: output error message */
void HTS_error(int error, const char *message, ...)
{
va_list arg;
fflush(stdout);
fflush(stderr);
if (error > 0)
fprintf(stderr, "\nError: ");
else
fprintf(stderr, "\nWarning: ");
va_start(arg, message);
vfprintf(stderr, message, arg);
va_end(arg);
fflush(stderr);
if (error > 0)
exit(error);
}
HTS_MISC_C_END;
#endif /* !HTS_MISC_C */

1695
3rdparty/hts_engine_API/lib/HTS_model.c vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,524 @@
/* ----------------------------------------------------------------- */
/* The HMM-Based Speech Synthesis Engine "hts_engine API" */
/* developed by HTS Working Group */
/* http://hts-engine.sourceforge.net/ */
/* ----------------------------------------------------------------- */
/* */
/* Copyright (c) 2001-2015 Nagoya Institute of Technology */
/* Department of Computer Science */
/* */
/* 2001-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 HTS_PSTREAM_C
#define HTS_PSTREAM_C
#ifdef __cplusplus
#define HTS_PSTREAM_C_START extern "C" {
#define HTS_PSTREAM_C_END }
#else
#define HTS_PSTREAM_C_START
#define HTS_PSTREAM_C_END
#endif /* __CPLUSPLUS */
HTS_PSTREAM_C_START;
#include <math.h> /* for sqrt() */
/* hts_engine libraries */
#include "HTS_hidden.h"
/* HTS_finv: calculate 1.0/variance function */
static double HTS_finv(const double x)
{
if (x >= INFTY2)
return 0.0;
if (x <= -INFTY2)
return 0.0;
if (x <= INVINF2 && x >= 0)
return INFTY;
if (x >= -INVINF2 && x < 0)
return -INFTY;
return (1.0 / x);
}
/* HTS_PStream_calc_wuw_and_wum: calcurate W'U^{-1}W and W'U^{-1}M */
static void HTS_PStream_calc_wuw_and_wum(HTS_PStream * pst, size_t m)
{
size_t t, i, j;
int shift;
double wu;
for (t = 0; t < pst->length; t++) {
/* initialize */
pst->sm.wum[t] = 0.0;
for (i = 0; i < pst->width; i++)
pst->sm.wuw[t][i] = 0.0;
/* calc WUW & WUM */
for (i = 0; i < pst->win_size; i++)
for (shift = pst->win_l_width[i]; shift <= pst->win_r_width[i]; shift++)
if (((int) t + shift >= 0) && ((int) t + shift < pst->length) && (pst->win_coefficient[i][-shift] != 0.0)) {
wu = pst->win_coefficient[i][-shift] * pst->sm.ivar[t + shift][i * pst->vector_length + m];
pst->sm.wum[t] += wu * pst->sm.mean[t + shift][i * pst->vector_length + m];
for (j = 0; (j < pst->width) && (t + j < pst->length); j++)
if (((int) j <= pst->win_r_width[i] + shift) && (pst->win_coefficient[i][j - shift] != 0.0))
pst->sm.wuw[t][j] += wu * pst->win_coefficient[i][j - shift];
}
}
}
/* HTS_PStream_ldl_factorization: Factorize W'*U^{-1}*W to L*D*L' (L: lower triangular, D: diagonal) */
static void HTS_PStream_ldl_factorization(HTS_PStream * pst)
{
size_t t, i, j;
for (t = 0; t < pst->length; t++) {
for (i = 1; (i < pst->width) && (t >= i); i++)
pst->sm.wuw[t][0] -= pst->sm.wuw[t - i][i] * pst->sm.wuw[t - i][i] * pst->sm.wuw[t - i][0];
for (i = 1; i < pst->width; i++) {
for (j = 1; (i + j < pst->width) && (t >= j); j++)
pst->sm.wuw[t][i] -= pst->sm.wuw[t - j][j] * pst->sm.wuw[t - j][i + j] * pst->sm.wuw[t - j][0];
pst->sm.wuw[t][i] /= pst->sm.wuw[t][0];
}
}
}
/* HTS_PStream_forward_substitution: forward subtitution for mlpg */
static void HTS_PStream_forward_substitution(HTS_PStream * pst)
{
size_t t, i;
for (t = 0; t < pst->length; t++) {
pst->sm.g[t] = pst->sm.wum[t];
for (i = 1; (i < pst->width) && (t >= i); i++)
pst->sm.g[t] -= pst->sm.wuw[t - i][i] * pst->sm.g[t - i];
}
}
/* HTS_PStream_backward_substitution: backward subtitution for mlpg */
static void HTS_PStream_backward_substitution(HTS_PStream * pst, size_t m)
{
size_t rev, t, i;
for (rev = 0; rev < pst->length; rev++) {
t = pst->length - 1 - rev;
pst->par[t][m] = pst->sm.g[t] / pst->sm.wuw[t][0];
for (i = 1; (i < pst->width) && (t + i < pst->length); i++)
pst->par[t][m] -= pst->sm.wuw[t][i] * pst->par[t + i][m];
}
}
/* HTS_PStream_calc_gv: subfunction for mlpg using GV */
static void HTS_PStream_calc_gv(HTS_PStream * pst, size_t m, double *mean, double *vari)
{
size_t t;
*mean = 0.0;
for (t = 0; t < pst->length; t++)
if (pst->gv_switch[t])
*mean += pst->par[t][m];
*mean /= pst->gv_length;
*vari = 0.0;
for (t = 0; t < pst->length; t++)
if (pst->gv_switch[t])
*vari += (pst->par[t][m] - *mean) * (pst->par[t][m] - *mean);
*vari /= pst->gv_length;
}
/* HTS_PStream_conv_gv: subfunction for mlpg using GV */
static void HTS_PStream_conv_gv(HTS_PStream * pst, size_t m)
{
size_t t;
double ratio;
double mean;
double vari;
HTS_PStream_calc_gv(pst, m, &mean, &vari);
ratio = sqrt(pst->gv_mean[m] / vari);
for (t = 0; t < pst->length; t++)
if (pst->gv_switch[t])
pst->par[t][m] = ratio * (pst->par[t][m] - mean) + mean;
}
/* HTS_PStream_calc_derivative: subfunction for mlpg using GV */
static double HTS_PStream_calc_derivative(HTS_PStream * pst, size_t m)
{
size_t t, i;
double mean;
double vari;
double dv;
double h;
double gvobj;
double hmmobj;
double w = 1.0 / (pst->win_size * pst->length);
HTS_PStream_calc_gv(pst, m, &mean, &vari);
gvobj = -0.5 * W2 * vari * pst->gv_vari[m] * (vari - 2.0 * pst->gv_mean[m]);
dv = -2.0 * pst->gv_vari[m] * (vari - pst->gv_mean[m]) / pst->length;
for (t = 0; t < pst->length; t++) {
pst->sm.g[t] = pst->sm.wuw[t][0] * pst->par[t][m];
for (i = 1; i < pst->width; i++) {
if (t + i < pst->length)
pst->sm.g[t] += pst->sm.wuw[t][i] * pst->par[t + i][m];
if (t + 1 > i)
pst->sm.g[t] += pst->sm.wuw[t - i][i] * pst->par[t - i][m];
}
}
for (t = 0, hmmobj = 0.0; t < pst->length; t++) {
hmmobj += W1 * w * pst->par[t][m] * (pst->sm.wum[t] - 0.5 * pst->sm.g[t]);
h = -W1 * w * pst->sm.wuw[t][1 - 1] - W2 * 2.0 / (pst->length * pst->length) * ((pst->length - 1) * pst->gv_vari[m] * (vari - pst->gv_mean[m]) + 2.0 * pst->gv_vari[m] * (pst->par[t][m] - mean) * (pst->par[t][m] - mean));
if (pst->gv_switch[t])
pst->sm.g[t] = 1.0 / h * (W1 * w * (-pst->sm.g[t] + pst->sm.wum[t]) + W2 * dv * (pst->par[t][m] - mean));
else
pst->sm.g[t] = 1.0 / h * (W1 * w * (-pst->sm.g[t] + pst->sm.wum[t]));
}
return (-(hmmobj + gvobj));
}
/* HTS_PStream_gv_parmgen: function for mlpg using GV */
static void HTS_PStream_gv_parmgen(HTS_PStream * pst, size_t m)
{
size_t t, i;
double step = STEPINIT;
double prev = 0.0;
double obj;
if (pst->gv_length == 0)
return;
HTS_PStream_conv_gv(pst, m);
if (GV_MAX_ITERATION > 0) {
HTS_PStream_calc_wuw_and_wum(pst, m);
for (i = 1; i <= GV_MAX_ITERATION; i++) {
obj = HTS_PStream_calc_derivative(pst, m);
if (i > 1) {
if (obj > prev)
step *= STEPDEC;
if (obj < prev)
step *= STEPINC;
}
for (t = 0; t < pst->length; t++) {
if (pst->gv_switch[t])
pst->par[t][m] += step * pst->sm.g[t];
}
prev = obj;
}
}
}
/* HTS_PStream_mlpg: generate sequence of speech parameter vector maximizing its output probability for given pdf sequence */
static void HTS_PStream_mlpg(HTS_PStream * pst)
{
size_t m;
if (pst->length == 0)
return;
for (m = 0; m < pst->vector_length; m++) {
HTS_PStream_calc_wuw_and_wum(pst, m);
HTS_PStream_ldl_factorization(pst); /* LDL factorization */
HTS_PStream_forward_substitution(pst); /* forward substitution */
HTS_PStream_backward_substitution(pst, m); /* backward substitution */
if (pst->gv_length > 0)
HTS_PStream_gv_parmgen(pst, m);
}
}
/* HTS_PStreamSet_initialize: initialize parameter stream set */
void HTS_PStreamSet_initialize(HTS_PStreamSet * pss)
{
pss->pstream = NULL;
pss->nstream = 0;
pss->total_frame = 0;
}
/* HTS_PStreamSet_create: parameter generation using GV weight */
HTS_Boolean HTS_PStreamSet_create(HTS_PStreamSet * pss, HTS_SStreamSet * sss, double *msd_threshold, double *gv_weight)
{
size_t i, j, k, l, m;
int shift;
size_t frame, msd_frame, state;
HTS_PStream *pst;
HTS_Boolean not_bound;
if (pss->nstream != 0) {
HTS_error(1, "HTS_PstreamSet_create: HTS_PStreamSet should be clear.\n");
return FALSE;
}
/* initialize */
pss->nstream = HTS_SStreamSet_get_nstream(sss);
pss->pstream = (HTS_PStream *) HTS_calloc(pss->nstream, sizeof(HTS_PStream));
pss->total_frame = HTS_SStreamSet_get_total_frame(sss);
/* create */
for (i = 0; i < pss->nstream; i++) {
pst = &pss->pstream[i];
if (HTS_SStreamSet_is_msd(sss, i) == TRUE) { /* for MSD */
pst->length = 0;
for (state = 0; state < HTS_SStreamSet_get_total_state(sss); state++)
if (HTS_SStreamSet_get_msd(sss, i, state) > msd_threshold[i])
pst->length += HTS_SStreamSet_get_duration(sss, state);
pst->msd_flag = (HTS_Boolean *) HTS_calloc(pss->total_frame, sizeof(HTS_Boolean));
for (state = 0, frame = 0; state < HTS_SStreamSet_get_total_state(sss); state++) {
if (HTS_SStreamSet_get_msd(sss, i, state) > msd_threshold[i]) {
for (j = 0; j < HTS_SStreamSet_get_duration(sss, state); j++) {
pst->msd_flag[frame] = TRUE;
frame++;
}
} else {
for (j = 0; j < HTS_SStreamSet_get_duration(sss, state); j++) {
pst->msd_flag[frame] = FALSE;
frame++;
}
}
}
} else { /* for non MSD */
pst->length = pss->total_frame;
pst->msd_flag = NULL;
}
pst->vector_length = HTS_SStreamSet_get_vector_length(sss, i);
pst->width = HTS_SStreamSet_get_window_max_width(sss, i) * 2 + 1; /* band width of R */
pst->win_size = HTS_SStreamSet_get_window_size(sss, i);
if (pst->length > 0) {
pst->sm.mean = HTS_alloc_matrix(pst->length, pst->vector_length * pst->win_size);
pst->sm.ivar = HTS_alloc_matrix(pst->length, pst->vector_length * pst->win_size);
pst->sm.wum = (double *) HTS_calloc(pst->length, sizeof(double));
pst->sm.wuw = HTS_alloc_matrix(pst->length, pst->width);
pst->sm.g = (double *) HTS_calloc(pst->length, sizeof(double));
pst->par = HTS_alloc_matrix(pst->length, pst->vector_length);
}
/* copy dynamic window */
pst->win_l_width = (int *) HTS_calloc(pst->win_size, sizeof(int));
pst->win_r_width = (int *) HTS_calloc(pst->win_size, sizeof(int));
pst->win_coefficient = (double **) HTS_calloc(pst->win_size, sizeof(double));
for (j = 0; j < pst->win_size; j++) {
pst->win_l_width[j] = HTS_SStreamSet_get_window_left_width(sss, i, j);
pst->win_r_width[j] = HTS_SStreamSet_get_window_right_width(sss, i, j);
if (pst->win_l_width[j] + pst->win_r_width[j] == 0)
pst->win_coefficient[j] = (double *)
HTS_calloc(-2 * pst->win_l_width[j] + 1, sizeof(double));
else
pst->win_coefficient[j] = (double *)
HTS_calloc(-2 * pst->win_l_width[j], sizeof(double));
pst->win_coefficient[j] -= pst->win_l_width[j];
for (shift = pst->win_l_width[j]; shift <= pst->win_r_width[j]; shift++)
pst->win_coefficient[j][shift] = HTS_SStreamSet_get_window_coefficient(sss, i, j, shift);
}
/* copy GV */
if (HTS_SStreamSet_use_gv(sss, i)) {
pst->gv_mean = (double *) HTS_calloc(pst->vector_length, sizeof(double));
pst->gv_vari = (double *) HTS_calloc(pst->vector_length, sizeof(double));
for (j = 0; j < pst->vector_length; j++) {
pst->gv_mean[j] = HTS_SStreamSet_get_gv_mean(sss, i, j) * gv_weight[i];
pst->gv_vari[j] = HTS_SStreamSet_get_gv_vari(sss, i, j);
}
pst->gv_switch = (HTS_Boolean *) HTS_calloc(pst->length, sizeof(HTS_Boolean));
if (HTS_SStreamSet_is_msd(sss, i) == TRUE) { /* for MSD */
for (state = 0, frame = 0, msd_frame = 0; state < HTS_SStreamSet_get_total_state(sss); state++)
for (j = 0; j < HTS_SStreamSet_get_duration(sss, state); j++, frame++)
if (pst->msd_flag[frame] == TRUE)
pst->gv_switch[msd_frame++] = HTS_SStreamSet_get_gv_switch(sss, i, state);
} else { /* for non MSD */
for (state = 0, frame = 0; state < HTS_SStreamSet_get_total_state(sss); state++)
for (j = 0; j < HTS_SStreamSet_get_duration(sss, state); j++)
pst->gv_switch[frame++] = HTS_SStreamSet_get_gv_switch(sss, i, state);
}
for (j = 0, pst->gv_length = 0; j < pst->length; j++)
if (pst->gv_switch[j])
pst->gv_length++;
} else {
pst->gv_switch = NULL;
pst->gv_length = 0;
pst->gv_mean = NULL;
pst->gv_vari = NULL;
}
/* copy pdfs */
if (HTS_SStreamSet_is_msd(sss, i) == TRUE) { /* for MSD */
for (state = 0, frame = 0, msd_frame = 0; state < HTS_SStreamSet_get_total_state(sss); state++) {
for (j = 0; j < HTS_SStreamSet_get_duration(sss, state); j++) {
if (pst->msd_flag[frame] == TRUE) {
/* check current frame is MSD boundary or not */
for (k = 0; k < pst->win_size; k++) {
not_bound = TRUE;
for (shift = pst->win_l_width[k]; shift <= pst->win_r_width[k]; shift++)
if ((int) frame + shift < 0 || (int) pss->total_frame <= (int) frame + shift || pst->msd_flag[frame + shift] != TRUE) {
not_bound = FALSE;
break;
}
for (l = 0; l < pst->vector_length; l++) {
m = pst->vector_length * k + l;
pst->sm.mean[msd_frame][m] = HTS_SStreamSet_get_mean(sss, i, state, m);
if (not_bound || k == 0)
pst->sm.ivar[msd_frame][m] = HTS_finv(HTS_SStreamSet_get_vari(sss, i, state, m));
else
pst->sm.ivar[msd_frame][m] = 0.0;
}
}
msd_frame++;
}
frame++;
}
}
} else { /* for non MSD */
for (state = 0, frame = 0; state < HTS_SStreamSet_get_total_state(sss); state++) {
for (j = 0; j < HTS_SStreamSet_get_duration(sss, state); j++) {
for (k = 0; k < pst->win_size; k++) {
not_bound = TRUE;
for (shift = pst->win_l_width[k]; shift <= pst->win_r_width[k]; shift++)
if ((int) frame + shift < 0 || (int) pss->total_frame <= (int) frame + shift) {
not_bound = FALSE;
break;
}
for (l = 0; l < pst->vector_length; l++) {
m = pst->vector_length * k + l;
pst->sm.mean[frame][m] = HTS_SStreamSet_get_mean(sss, i, state, m);
if (not_bound || k == 0)
pst->sm.ivar[frame][m] = HTS_finv(HTS_SStreamSet_get_vari(sss, i, state, m));
else
pst->sm.ivar[frame][m] = 0.0;
}
}
frame++;
}
}
}
/* parameter generation */
HTS_PStream_mlpg(pst);
}
return TRUE;
}
/* HTS_PStreamSet_get_nstream: get number of stream */
size_t HTS_PStreamSet_get_nstream(HTS_PStreamSet * pss)
{
return pss->nstream;
}
/* HTS_PStreamSet_get_vector_length: get feature length */
size_t HTS_PStreamSet_get_vector_length(HTS_PStreamSet * pss, size_t stream_index)
{
return pss->pstream[stream_index].vector_length;
}
/* HTS_PStreamSet_get_total_frame: get total number of frame */
size_t HTS_PStreamSet_get_total_frame(HTS_PStreamSet * pss)
{
return pss->total_frame;
}
/* HTS_PStreamSet_get_parameter: get parameter */
double HTS_PStreamSet_get_parameter(HTS_PStreamSet * pss, size_t stream_index, size_t frame_index, size_t vector_index)
{
return pss->pstream[stream_index].par[frame_index][vector_index];
}
/* HTS_PStreamSet_get_parameter_vector: get parameter vector*/
double *HTS_PStreamSet_get_parameter_vector(HTS_PStreamSet * pss, size_t stream_index, size_t frame_index)
{
return pss->pstream[stream_index].par[frame_index];
}
/* HTS_PStreamSet_get_msd_flag: get generated MSD flag per frame */
HTS_Boolean HTS_PStreamSet_get_msd_flag(HTS_PStreamSet * pss, size_t stream_index, size_t frame_index)
{
return pss->pstream[stream_index].msd_flag[frame_index];
}
/* HTS_PStreamSet_is_msd: get MSD flag */
HTS_Boolean HTS_PStreamSet_is_msd(HTS_PStreamSet * pss, size_t stream_index)
{
return pss->pstream[stream_index].msd_flag ? TRUE : FALSE;
}
/* HTS_PStreamSet_clear: free parameter stream set */
void HTS_PStreamSet_clear(HTS_PStreamSet * pss)
{
size_t i, j;
HTS_PStream *pstream;
if (pss->pstream) {
for (i = 0; i < pss->nstream; i++) {
pstream = &pss->pstream[i];
if (pstream->sm.wum)
HTS_free(pstream->sm.wum);
if (pstream->sm.g)
HTS_free(pstream->sm.g);
if (pstream->sm.wuw)
HTS_free_matrix(pstream->sm.wuw, pstream->length);
if (pstream->sm.ivar)
HTS_free_matrix(pstream->sm.ivar, pstream->length);
if (pstream->sm.mean)
HTS_free_matrix(pstream->sm.mean, pstream->length);
if (pstream->par)
HTS_free_matrix(pstream->par, pstream->length);
if (pstream->msd_flag)
HTS_free(pstream->msd_flag);
if (pstream->win_coefficient) {
for (j = 0; j < pstream->win_size; j++) {
pstream->win_coefficient[j] += pstream->win_l_width[j];
HTS_free(pstream->win_coefficient[j]);
}
}
if (pstream->gv_mean)
HTS_free(pstream->gv_mean);
if (pstream->gv_vari)
HTS_free(pstream->gv_vari);
if (pstream->win_coefficient)
HTS_free(pstream->win_coefficient);
if (pstream->win_l_width)
HTS_free(pstream->win_l_width);
if (pstream->win_r_width)
HTS_free(pstream->win_r_width);
if (pstream->gv_switch)
HTS_free(pstream->gv_switch);
}
HTS_free(pss->pstream);
}
HTS_PStreamSet_initialize(pss);
}
HTS_PSTREAM_C_END;
#endif /* !HTS_PSTREAM_C */

View File

@@ -0,0 +1,512 @@
/* ----------------------------------------------------------------- */
/* The HMM-Based Speech Synthesis Engine "hts_engine API" */
/* developed by HTS Working Group */
/* http://hts-engine.sourceforge.net/ */
/* ----------------------------------------------------------------- */
/* */
/* Copyright (c) 2001-2015 Nagoya Institute of Technology */
/* Department of Computer Science */
/* */
/* 2001-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 HTS_SSTREAM_C
#define HTS_SSTREAM_C
#ifdef __cplusplus
#define HTS_SSTREAM_C_START extern "C" {
#define HTS_SSTREAM_C_END }
#else
#define HTS_SSTREAM_C_START
#define HTS_SSTREAM_C_END
#endif /* __CPLUSPLUS */
HTS_SSTREAM_C_START;
#include <stdlib.h>
#include <math.h>
/* hts_engine libraries */
#include "HTS_hidden.h"
/* HTS_set_default_duration: set default duration from state duration probability distribution */
static double HTS_set_default_duration(size_t * duration, double *mean, double *vari, size_t size)
{
size_t i;
double temp;
size_t sum = 0;
for (i = 0; i < size; i++) {
temp = mean[i] + 0.5;
if (temp < 1.0)
duration[i] = 1;
else
duration[i] = (size_t) temp;
sum += duration[i];
}
return (double) sum;
}
/* HTS_set_specified_duration: set duration from state duration probability distribution and specified frame length */
static double HTS_set_specified_duration(size_t * duration, double *mean, double *vari, size_t size, double frame_length)
{
size_t i;
int j;
double temp1, temp2;
double rho = 0.0;
size_t sum = 0;
size_t target_length;
/* get the target frame length */
if (frame_length + 0.5 < 1.0)
target_length = 1;
else
target_length = (size_t) (frame_length + 0.5);
/* check the specified duration */
if (target_length <= size) {
if (target_length < size)
HTS_error(-1, "HTS_set_specified_duration: Specified frame length is too short.\n");
for (i = 0; i < size; i++)
duration[i] = 1;
return (double) size;
}
/* RHO calculation */
temp1 = 0.0;
temp2 = 0.0;
for (i = 0; i < size; i++) {
temp1 += mean[i];
temp2 += vari[i];
}
rho = ((double) target_length - temp1) / temp2;
/* first estimation */
for (i = 0; i < size; i++) {
temp1 = mean[i] + rho * vari[i] + 0.5;
if (temp1 < 1.0)
duration[i] = 1;
else
duration[i] = (size_t) temp1;
sum += duration[i];
}
/* loop estimation */
while (target_length != sum) {
/* sarch flexible state and modify its duration */
if (target_length > sum) {
j = -1;
for (i = 0; i < size; i++) {
temp2 = fabs(rho - ((double) duration[i] + 1 - mean[i]) / vari[i]);
if (j < 0 || temp1 > temp2) {
j = i;
temp1 = temp2;
}
}
sum++;
duration[j]++;
} else {
j = -1;
for (i = 0; i < size; i++) {
if (duration[i] > 1) {
temp2 = fabs(rho - ((double) duration[i] - 1 - mean[i]) / vari[i]);
if (j < 0 || temp1 > temp2) {
j = i;
temp1 = temp2;
}
}
}
sum--;
duration[j]--;
}
}
return (double) target_length;
}
/* HTS_SStreamSet_initialize: initialize state stream set */
void HTS_SStreamSet_initialize(HTS_SStreamSet * sss)
{
sss->nstream = 0;
sss->nstate = 0;
sss->sstream = NULL;
sss->duration = NULL;
sss->total_state = 0;
sss->total_frame = 0;
}
/* HTS_SStreamSet_create: parse label and determine state duration */
HTS_Boolean HTS_SStreamSet_create(HTS_SStreamSet * sss, HTS_ModelSet * ms, HTS_Label * label, HTS_Boolean phoneme_alignment_flag, double speed, double *duration_iw, double **parameter_iw, double **gv_iw)
{
size_t i, j, k;
double temp;
int shift;
size_t state;
HTS_SStream *sst;
double *duration_mean, *duration_vari;
double frame_length;
size_t next_time;
size_t next_state;
if (HTS_Label_get_size(label) == 0)
return FALSE;
/* check interpolation weights */
for (i = 0, temp = 0.0; i < HTS_ModelSet_get_nvoices(ms); i++)
temp += duration_iw[i];
if (temp == 0.0) {
return FALSE;
} else if (temp != 1.0) {
for (i = 0; i < HTS_ModelSet_get_nvoices(ms); i++)
if (duration_iw[i] != 0.0)
duration_iw[i] /= temp;
}
for (i = 0; i < HTS_ModelSet_get_nstream(ms); i++) {
for (j = 0, temp = 0.0; j < HTS_ModelSet_get_nvoices(ms); j++)
temp += parameter_iw[j][i];
if (temp == 0.0) {
return FALSE;
} else if (temp != 1.0) {
for (j = 0; j < HTS_ModelSet_get_nvoices(ms); j++)
if (parameter_iw[j][i] != 0.0)
parameter_iw[j][i] /= temp;
}
if (HTS_ModelSet_use_gv(ms, i)) {
for (j = 0, temp = 0.0; j < HTS_ModelSet_get_nvoices(ms); j++)
temp += gv_iw[j][i];
if (temp == 0.0)
return FALSE;
else if (temp != 1.0)
for (j = 0; j < HTS_ModelSet_get_nvoices(ms); j++)
if (gv_iw[j][i] != 0.0)
gv_iw[j][i] /= temp;
}
}
/* initialize state sequence */
sss->nstate = HTS_ModelSet_get_nstate(ms);
sss->nstream = HTS_ModelSet_get_nstream(ms);
sss->total_frame = 0;
sss->total_state = HTS_Label_get_size(label) * sss->nstate;
sss->duration = (size_t *) HTS_calloc(sss->total_state, sizeof(size_t));
sss->sstream = (HTS_SStream *) HTS_calloc(sss->nstream, sizeof(HTS_SStream));
for (i = 0; i < sss->nstream; i++) {
sst = &sss->sstream[i];
sst->vector_length = HTS_ModelSet_get_vector_length(ms, i);
sst->mean = (double **) HTS_calloc(sss->total_state, sizeof(double *));
sst->vari = (double **) HTS_calloc(sss->total_state, sizeof(double *));
if (HTS_ModelSet_is_msd(ms, i))
sst->msd = (double *) HTS_calloc(sss->total_state, sizeof(double));
else
sst->msd = NULL;
for (j = 0; j < sss->total_state; j++) {
sst->mean[j] = (double *) HTS_calloc(sst->vector_length * HTS_ModelSet_get_window_size(ms, i), sizeof(double));
sst->vari[j] = (double *) HTS_calloc(sst->vector_length * HTS_ModelSet_get_window_size(ms, i), sizeof(double));
}
if (HTS_ModelSet_use_gv(ms, i)) {
sst->gv_switch = (HTS_Boolean *) HTS_calloc(sss->total_state, sizeof(HTS_Boolean));
for (j = 0; j < sss->total_state; j++)
sst->gv_switch[j] = TRUE;
} else {
sst->gv_switch = NULL;
}
}
/* determine state duration */
duration_mean = (double *) HTS_calloc(sss->total_state, sizeof(double));
duration_vari = (double *) HTS_calloc(sss->total_state, sizeof(double));
for (i = 0; i < HTS_Label_get_size(label); i++)
HTS_ModelSet_get_duration(ms, HTS_Label_get_string(label, i), duration_iw, &duration_mean[i * sss->nstate], &duration_vari[i * sss->nstate]);
if (phoneme_alignment_flag == TRUE) {
/* use duration set by user */
next_time = 0;
next_state = 0;
state = 0;
for (i = 0; i < HTS_Label_get_size(label); i++) {
temp = HTS_Label_get_end_frame(label, i);
if (temp >= 0) {
next_time += (size_t) HTS_set_specified_duration(&sss->duration[next_state], &duration_mean[next_state], &duration_vari[next_state], state + sss->nstate - next_state, temp - next_time);
next_state = state + sss->nstate;
} else if (i + 1 == HTS_Label_get_size(label)) {
HTS_error(-1, "HTS_SStreamSet_create: The time of final label is not specified.\n");
HTS_set_default_duration(&sss->duration[next_state], &duration_mean[next_state], &duration_vari[next_state], state + sss->nstate - next_state);
}
state += sss->nstate;
}
} else {
/* determine frame length */
if (speed != 1.0) {
temp = 0.0;
for (i = 0; i < sss->total_state; i++) {
temp += duration_mean[i];
}
frame_length = temp / speed;
HTS_set_specified_duration(sss->duration, duration_mean, duration_vari, sss->total_state, frame_length);
} else {
HTS_set_default_duration(sss->duration, duration_mean, duration_vari, sss->total_state);
}
}
HTS_free(duration_mean);
HTS_free(duration_vari);
/* get parameter */
for (i = 0, state = 0; i < HTS_Label_get_size(label); i++) {
for (j = 2; j <= sss->nstate + 1; j++) {
sss->total_frame += sss->duration[state];
for (k = 0; k < sss->nstream; k++) {
sst = &sss->sstream[k];
if (sst->msd)
HTS_ModelSet_get_parameter(ms, k, j, HTS_Label_get_string(label, i), (const double *const *) parameter_iw, sst->mean[state], sst->vari[state], &sst->msd[state]);
else
HTS_ModelSet_get_parameter(ms, k, j, HTS_Label_get_string(label, i), (const double *const *) parameter_iw, sst->mean[state], sst->vari[state], NULL);
}
state++;
}
}
/* copy dynamic window */
for (i = 0; i < sss->nstream; i++) {
sst = &sss->sstream[i];
sst->win_size = HTS_ModelSet_get_window_size(ms, i);
sst->win_max_width = HTS_ModelSet_get_window_max_width(ms, i);
sst->win_l_width = (int *) HTS_calloc(sst->win_size, sizeof(int));
sst->win_r_width = (int *) HTS_calloc(sst->win_size, sizeof(int));
sst->win_coefficient = (double **) HTS_calloc(sst->win_size, sizeof(double));
for (j = 0; j < sst->win_size; j++) {
sst->win_l_width[j] = HTS_ModelSet_get_window_left_width(ms, i, j);
sst->win_r_width[j] = HTS_ModelSet_get_window_right_width(ms, i, j);
if (sst->win_l_width[j] + sst->win_r_width[j] == 0)
sst->win_coefficient[j] = (double *) HTS_calloc(-2 * sst->win_l_width[j] + 1, sizeof(double));
else
sst->win_coefficient[j] = (double *) HTS_calloc(-2 * sst->win_l_width[j], sizeof(double));
sst->win_coefficient[j] -= sst->win_l_width[j];
for (shift = sst->win_l_width[j]; shift <= sst->win_r_width[j]; shift++)
sst->win_coefficient[j][shift] = HTS_ModelSet_get_window_coefficient(ms, i, j, shift);
}
}
/* determine GV */
for (i = 0; i < sss->nstream; i++) {
sst = &sss->sstream[i];
if (HTS_ModelSet_use_gv(ms, i)) {
sst->gv_mean = (double *) HTS_calloc(sst->vector_length, sizeof(double));
sst->gv_vari = (double *) HTS_calloc(sst->vector_length, sizeof(double));
HTS_ModelSet_get_gv(ms, i, HTS_Label_get_string(label, 0), (const double *const *) gv_iw, sst->gv_mean, sst->gv_vari);
} else {
sst->gv_mean = NULL;
sst->gv_vari = NULL;
}
}
for (i = 0; i < HTS_Label_get_size(label); i++)
if (HTS_ModelSet_get_gv_flag(ms, HTS_Label_get_string(label, i)) == FALSE)
for (j = 0; j < sss->nstream; j++)
if (HTS_ModelSet_use_gv(ms, j) == TRUE)
for (k = 0; k < sss->nstate; k++)
sss->sstream[j].gv_switch[i * sss->nstate + k] = FALSE;
return TRUE;
}
/* HTS_SStreamSet_get_nstream: get number of stream */
size_t HTS_SStreamSet_get_nstream(HTS_SStreamSet * sss)
{
return sss->nstream;
}
/* HTS_SStreamSet_get_vector_length: get vector length */
size_t HTS_SStreamSet_get_vector_length(HTS_SStreamSet * sss, size_t stream_index)
{
return sss->sstream[stream_index].vector_length;
}
/* HTS_SStreamSet_is_msd: get MSD flag */
HTS_Boolean HTS_SStreamSet_is_msd(HTS_SStreamSet * sss, size_t stream_index)
{
return sss->sstream[stream_index].msd ? TRUE : FALSE;
}
/* HTS_SStreamSet_get_total_state: get total number of state */
size_t HTS_SStreamSet_get_total_state(HTS_SStreamSet * sss)
{
return sss->total_state;
}
/* HTS_SStreamSet_get_total_frame: get total number of frame */
size_t HTS_SStreamSet_get_total_frame(HTS_SStreamSet * sss)
{
return sss->total_frame;
}
/* HTS_SStreamSet_get_msd: get MSD parameter */
double HTS_SStreamSet_get_msd(HTS_SStreamSet * sss, size_t stream_index, size_t state_index)
{
return sss->sstream[stream_index].msd[state_index];
}
/* HTS_SStreamSet_window_size: get dynamic window size */
size_t HTS_SStreamSet_get_window_size(HTS_SStreamSet * sss, size_t stream_index)
{
return sss->sstream[stream_index].win_size;
}
/* HTS_SStreamSet_get_window_left_width: get left width of dynamic window */
int HTS_SStreamSet_get_window_left_width(HTS_SStreamSet * sss, size_t stream_index, size_t window_index)
{
return sss->sstream[stream_index].win_l_width[window_index];
}
/* HTS_SStreamSet_get_winodow_right_width: get right width of dynamic window */
int HTS_SStreamSet_get_window_right_width(HTS_SStreamSet * sss, size_t stream_index, size_t window_index)
{
return sss->sstream[stream_index].win_r_width[window_index];
}
/* HTS_SStreamSet_get_window_coefficient: get coefficient of dynamic window */
double HTS_SStreamSet_get_window_coefficient(HTS_SStreamSet * sss, size_t stream_index, size_t window_index, int coefficient_index)
{
return sss->sstream[stream_index].win_coefficient[window_index][coefficient_index];
}
/* HTS_SStreamSet_get_window_max_width: get max width of dynamic window */
size_t HTS_SStreamSet_get_window_max_width(HTS_SStreamSet * sss, size_t stream_index)
{
return sss->sstream[stream_index].win_max_width;
}
/* HTS_SStreamSet_use_gv: get GV flag */
HTS_Boolean HTS_SStreamSet_use_gv(HTS_SStreamSet * sss, size_t stream_index)
{
return sss->sstream[stream_index].gv_mean ? TRUE : FALSE;
}
/* HTS_SStreamSet_get_duration: get state duration */
size_t HTS_SStreamSet_get_duration(HTS_SStreamSet * sss, size_t state_index)
{
return sss->duration[state_index];
}
/* HTS_SStreamSet_get_mean: get mean parameter */
double HTS_SStreamSet_get_mean(HTS_SStreamSet * sss, size_t stream_index, size_t state_index, size_t vector_index)
{
return sss->sstream[stream_index].mean[state_index][vector_index];
}
/* HTS_SStreamSet_set_mean: set mean parameter */
void HTS_SStreamSet_set_mean(HTS_SStreamSet * sss, size_t stream_index, size_t state_index, size_t vector_index, double f)
{
sss->sstream[stream_index].mean[state_index][vector_index] = f;
}
/* HTS_SStreamSet_get_vari: get variance parameter */
double HTS_SStreamSet_get_vari(HTS_SStreamSet * sss, size_t stream_index, size_t state_index, size_t vector_index)
{
return sss->sstream[stream_index].vari[state_index][vector_index];
}
/* HTS_SStreamSet_set_vari: set variance parameter */
void HTS_SStreamSet_set_vari(HTS_SStreamSet * sss, size_t stream_index, size_t state_index, size_t vector_index, double f)
{
sss->sstream[stream_index].vari[state_index][vector_index] = f;
}
/* HTS_SStreamSet_get_gv_mean: get GV mean parameter */
double HTS_SStreamSet_get_gv_mean(HTS_SStreamSet * sss, size_t stream_index, size_t vector_index)
{
return sss->sstream[stream_index].gv_mean[vector_index];
}
/* HTS_SStreamSet_get_gv_mean: get GV variance parameter */
double HTS_SStreamSet_get_gv_vari(HTS_SStreamSet * sss, size_t stream_index, size_t vector_index)
{
return sss->sstream[stream_index].gv_vari[vector_index];
}
/* HTS_SStreamSet_set_gv_switch: set GV switch */
void HTS_SStreamSet_set_gv_switch(HTS_SStreamSet * sss, size_t stream_index, size_t state_index, HTS_Boolean i)
{
sss->sstream[stream_index].gv_switch[state_index] = i;
}
/* HTS_SStreamSet_get_gv_switch: get GV switch */
HTS_Boolean HTS_SStreamSet_get_gv_switch(HTS_SStreamSet * sss, size_t stream_index, size_t state_index)
{
return sss->sstream[stream_index].gv_switch[state_index];
}
/* HTS_SStreamSet_clear: free state stream set */
void HTS_SStreamSet_clear(HTS_SStreamSet * sss)
{
size_t i, j;
HTS_SStream *sst;
if (sss->sstream) {
for (i = 0; i < sss->nstream; i++) {
sst = &sss->sstream[i];
for (j = 0; j < sss->total_state; j++) {
HTS_free(sst->mean[j]);
HTS_free(sst->vari[j]);
}
if (sst->msd)
HTS_free(sst->msd);
HTS_free(sst->mean);
HTS_free(sst->vari);
for (j = 0; j < sst->win_size; j++) {
sst->win_coefficient[j] += sst->win_l_width[j];
HTS_free(sst->win_coefficient[j]);
}
HTS_free(sst->win_coefficient);
HTS_free(sst->win_l_width);
HTS_free(sst->win_r_width);
if (sst->gv_mean)
HTS_free(sst->gv_mean);
if (sst->gv_vari)
HTS_free(sst->gv_vari);
if (sst->gv_switch)
HTS_free(sst->gv_switch);
}
HTS_free(sss->sstream);
}
if (sss->duration)
HTS_free(sss->duration);
HTS_SStreamSet_initialize(sss);
}
HTS_SSTREAM_C_END;
#endif /* !HTS_SSTREAM_C */

View File

@@ -0,0 +1,997 @@
/* ----------------------------------------------------------------- */
/* The HMM-Based Speech Synthesis Engine "hts_engine API" */
/* developed by HTS Working Group */
/* http://hts-engine.sourceforge.net/ */
/* ----------------------------------------------------------------- */
/* */
/* Copyright (c) 2001-2015 Nagoya Institute of Technology */
/* Department of Computer Science */
/* */
/* 2001-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 HTS_VOCODER_C
#define HTS_VOCODER_C
#ifdef __cplusplus
#define HTS_VOCODER_C_START extern "C" {
#define HTS_VOCODER_C_END }
#else
#define HTS_VOCODER_C_START
#define HTS_VOCODER_C_END
#endif /* __CPLUSPLUS */
HTS_VOCODER_C_START;
#include <math.h> /* for sqrt(),log(),exp(),pow(),cos() */
/* hts_engine libraries */
#include "HTS_hidden.h"
static const double HTS_pade[21] = {
1.00000000000,
1.00000000000,
0.00000000000,
1.00000000000,
0.00000000000,
0.00000000000,
1.00000000000,
0.00000000000,
0.00000000000,
0.00000000000,
1.00000000000,
0.49992730000,
0.10670050000,
0.01170221000,
0.00056562790,
1.00000000000,
0.49993910000,
0.11070980000,
0.01369984000,
0.00095648530,
0.00003041721
};
/* HTS_movem: move memory */
static void HTS_movem(double *a, double *b, const int nitem)
{
long i = (long) nitem;
if (a > b)
while (i--)
*b++ = *a++;
else {
a += i;
b += i;
while (i--)
*--b = *--a;
}
}
/* HTS_mlsafir: sub functions for MLSA filter */
static double HTS_mlsafir(const double x, const double *b, const int m, const double a, const double aa, double *d)
{
double y = 0.0;
int i;
d[0] = x;
d[1] = aa * d[0] + a * d[1];
for (i = 2; i <= m; i++)
d[i] += a * (d[i + 1] - d[i - 1]);
for (i = 2; i <= m; i++)
y += d[i] * b[i];
for (i = m + 1; i > 1; i--)
d[i] = d[i - 1];
return (y);
}
/* HTS_mlsadf1: sub functions for MLSA filter */
static double HTS_mlsadf1(double x, const double *b, const int m, const double a, const double aa, const int pd, double *d, const double *ppade)
{
double v, out = 0.0, *pt;
int i;
pt = &d[pd + 1];
for (i = pd; i >= 1; i--) {
d[i] = aa * pt[i - 1] + a * d[i];
pt[i] = d[i] * b[1];
v = pt[i] * ppade[i];
x += (1 & i) ? v : -v;
out += v;
}
pt[0] = x;
out += x;
return (out);
}
/* HTS_mlsadf2: sub functions for MLSA filter */
static double HTS_mlsadf2(double x, const double *b, const int m, const double a, const double aa, const int pd, double *d, const double *ppade)
{
double v, out = 0.0, *pt;
int i;
pt = &d[pd * (m + 2)];
for (i = pd; i >= 1; i--) {
pt[i] = HTS_mlsafir(pt[i - 1], b, m, a, aa, &d[(i - 1) * (m + 2)]);
v = pt[i] * ppade[i];
x += (1 & i) ? v : -v;
out += v;
}
pt[0] = x;
out += x;
return (out);
}
/* HTS_mlsadf: functions for MLSA filter */
static double HTS_mlsadf(double x, const double *b, const int m, const double a, const int pd, double *d)
{
const double aa = 1 - a * a;
const double *ppade = &(HTS_pade[pd * (pd + 1) / 2]);
x = HTS_mlsadf1(x, b, m, a, aa, pd, d, ppade);
x = HTS_mlsadf2(x, b, m, a, aa, pd, &d[2 * (pd + 1)], ppade);
return (x);
}
/* HTS_rnd: functions for random noise generation */
static double HTS_rnd(unsigned long *next)
{
double r;
*next = *next * 1103515245L + 12345;
r = (*next / 65536L) % 32768L;
return (r / RANDMAX);
}
/* HTS_nrandom: functions for gaussian random noise generation */
static double HTS_nrandom(HTS_Vocoder * v)
{
if (v->sw == 0) {
v->sw = 1;
do {
v->r1 = 2 * HTS_rnd(&v->next) - 1;
v->r2 = 2 * HTS_rnd(&v->next) - 1;
v->s = v->r1 * v->r1 + v->r2 * v->r2;
} while (v->s > 1 || v->s == 0);
v->s = sqrt(-2 * log(v->s) / v->s);
return (v->r1 * v->s);
} else {
v->sw = 0;
return (v->r2 * v->s);
}
}
/* HTS_mceq: function for M-sequence random noise generation */
static int HTS_mseq(HTS_Vocoder * v)
{
int x0, x28;
v->x >>= 1;
if (v->x & B0)
x0 = 1;
else
x0 = -1;
if (v->x & B28)
x28 = 1;
else
x28 = -1;
if (x0 + x28)
v->x &= B31_;
else
v->x |= B31;
return (x0);
}
/* HTS_mc2b: transform mel-cepstrum to MLSA digital fillter coefficients */
static void HTS_mc2b(double *mc, double *b, int m, const double a)
{
if (mc != b) {
if (a != 0.0) {
b[m] = mc[m];
for (m--; m >= 0; m--)
b[m] = mc[m] - a * b[m + 1];
} else
HTS_movem(mc, b, m + 1);
} else if (a != 0.0)
for (m--; m >= 0; m--)
b[m] -= a * b[m + 1];
}
/* HTS_b2bc: transform MLSA digital filter coefficients to mel-cepstrum */
static void HTS_b2mc(const double *b, double *mc, int m, const double a)
{
double d, o;
d = mc[m] = b[m];
for (m--; m >= 0; m--) {
o = b[m] + a * d;
d = b[m];
mc[m] = o;
}
}
/* HTS_freqt: frequency transformation */
static void HTS_freqt(HTS_Vocoder * v, const double *c1, const int m1, double *c2, const int m2, const double a)
{
int i, j;
const double b = 1 - a * a;
double *g;
if (m2 > v->freqt_size) {
if (v->freqt_buff != NULL)
HTS_free(v->freqt_buff);
v->freqt_buff = (double *) HTS_calloc(m2 + m2 + 2, sizeof(double));
v->freqt_size = m2;
}
g = v->freqt_buff + v->freqt_size + 1;
for (i = 0; i < m2 + 1; i++)
g[i] = 0.0;
for (i = -m1; i <= 0; i++) {
if (0 <= m2)
g[0] = c1[-i] + a * (v->freqt_buff[0] = g[0]);
if (1 <= m2)
g[1] = b * v->freqt_buff[0] + a * (v->freqt_buff[1] = g[1]);
for (j = 2; j <= m2; j++)
g[j] = v->freqt_buff[j - 1] + a * ((v->freqt_buff[j] = g[j]) - g[j - 1]);
}
HTS_movem(g, c2, m2 + 1);
}
/* HTS_c2ir: The minimum phase impulse response is evaluated from the minimum phase cepstrum */
static void HTS_c2ir(const double *c, const int nc, double *h, const int leng)
{
int n, k, upl;
double d;
h[0] = exp(c[0]);
for (n = 1; n < leng; n++) {
d = 0;
upl = (n >= nc) ? nc - 1 : n;
for (k = 1; k <= upl; k++)
d += k * c[k] * h[n - k];
h[n] = d / n;
}
}
/* HTS_b2en: calculate frame energy */
static double HTS_b2en(HTS_Vocoder * v, const double *b, const int m, const double a)
{
int i;
double en = 0.0;
double *cep;
double *ir;
if (v->spectrum2en_size < m) {
if (v->spectrum2en_buff != NULL)
HTS_free(v->spectrum2en_buff);
v->spectrum2en_buff = (double *) HTS_calloc((m + 1) + 2 * IRLENG, sizeof(double));
v->spectrum2en_size = m;
}
cep = v->spectrum2en_buff + m + 1;
ir = cep + IRLENG;
HTS_b2mc(b, v->spectrum2en_buff, m, a);
HTS_freqt(v, v->spectrum2en_buff, m, cep, IRLENG - 1, -a);
HTS_c2ir(cep, IRLENG, ir, IRLENG);
for (i = 0; i < IRLENG; i++)
en += ir[i] * ir[i];
return (en);
}
/* HTS_ignorm: inverse gain normalization */
static void HTS_ignorm(double *c1, double *c2, int m, const double g)
{
double k;
if (g != 0.0) {
k = pow(c1[0], g);
for (; m >= 1; m--)
c2[m] = k * c1[m];
c2[0] = (k - 1.0) / g;
} else {
HTS_movem(&c1[1], &c2[1], m);
c2[0] = log(c1[0]);
}
}
/* HTS_gnorm: gain normalization */
static void HTS_gnorm(double *c1, double *c2, int m, const double g)
{
double k;
if (g != 0.0) {
k = 1.0 + g * c1[0];
for (; m >= 1; m--)
c2[m] = c1[m] / k;
c2[0] = pow(k, 1.0 / g);
} else {
HTS_movem(&c1[1], &c2[1], m);
c2[0] = exp(c1[0]);
}
}
/* HTS_lsp2lpc: transform LSP to LPC */
static void HTS_lsp2lpc(HTS_Vocoder * v, double *lsp, double *a, const int m)
{
int i, k, mh1, mh2, flag_odd;
double xx, xf, xff;
double *p, *q;
double *a0, *a1, *a2, *b0, *b1, *b2;
flag_odd = 0;
if (m % 2 == 0)
mh1 = mh2 = m / 2;
else {
mh1 = (m + 1) / 2;
mh2 = (m - 1) / 2;
flag_odd = 1;
}
if (m > v->lsp2lpc_size) {
if (v->lsp2lpc_buff != NULL)
HTS_free(v->lsp2lpc_buff);
v->lsp2lpc_buff = (double *) HTS_calloc(5 * m + 6, sizeof(double));
v->lsp2lpc_size = m;
}
p = v->lsp2lpc_buff + m;
q = p + mh1;
a0 = q + mh2;
a1 = a0 + (mh1 + 1);
a2 = a1 + (mh1 + 1);
b0 = a2 + (mh1 + 1);
b1 = b0 + (mh2 + 1);
b2 = b1 + (mh2 + 1);
HTS_movem(lsp, v->lsp2lpc_buff, m);
for (i = 0; i < mh1 + 1; i++)
a0[i] = 0.0;
for (i = 0; i < mh1 + 1; i++)
a1[i] = 0.0;
for (i = 0; i < mh1 + 1; i++)
a2[i] = 0.0;
for (i = 0; i < mh2 + 1; i++)
b0[i] = 0.0;
for (i = 0; i < mh2 + 1; i++)
b1[i] = 0.0;
for (i = 0; i < mh2 + 1; i++)
b2[i] = 0.0;
/* lsp filter parameters */
for (i = k = 0; i < mh1; i++, k += 2)
p[i] = -2.0 * cos(v->lsp2lpc_buff[k]);
for (i = k = 0; i < mh2; i++, k += 2)
q[i] = -2.0 * cos(v->lsp2lpc_buff[k + 1]);
/* impulse response of analysis filter */
xx = 1.0;
xf = xff = 0.0;
for (k = 0; k <= m; k++) {
if (flag_odd) {
a0[0] = xx;
b0[0] = xx - xff;
xff = xf;
xf = xx;
} else {
a0[0] = xx + xf;
b0[0] = xx - xf;
xf = xx;
}
for (i = 0; i < mh1; i++) {
a0[i + 1] = a0[i] + p[i] * a1[i] + a2[i];
a2[i] = a1[i];
a1[i] = a0[i];
}
for (i = 0; i < mh2; i++) {
b0[i + 1] = b0[i] + q[i] * b1[i] + b2[i];
b2[i] = b1[i];
b1[i] = b0[i];
}
if (k != 0)
a[k - 1] = -0.5 * (a0[mh1] + b0[mh2]);
xx = 0.0;
}
for (i = m - 1; i >= 0; i--)
a[i + 1] = -a[i];
a[0] = 1.0;
}
/* HTS_gc2gc: generalized cepstral transformation */
static void HTS_gc2gc(HTS_Vocoder * v, double *c1, const int m1, const double g1, double *c2, const int m2, const double g2)
{
int i, min, k, mk;
double ss1, ss2, cc;
if (m1 > v->gc2gc_size) {
if (v->gc2gc_buff != NULL)
HTS_free(v->gc2gc_buff);
v->gc2gc_buff = (double *) HTS_calloc(m1 + 1, sizeof(double));
v->gc2gc_size = m1;
}
HTS_movem(c1, v->gc2gc_buff, m1 + 1);
c2[0] = v->gc2gc_buff[0];
for (i = 1; i <= m2; i++) {
ss1 = ss2 = 0.0;
min = m1 < i ? m1 : i - 1;
for (k = 1; k <= min; k++) {
mk = i - k;
cc = v->gc2gc_buff[k] * c2[mk];
ss2 += k * cc;
ss1 += mk * cc;
}
if (i <= m1)
c2[i] = v->gc2gc_buff[i] + (g2 * ss2 - g1 * ss1) / i;
else
c2[i] = (g2 * ss2 - g1 * ss1) / i;
}
}
/* HTS_mgc2mgc: frequency and generalized cepstral transformation */
static void HTS_mgc2mgc(HTS_Vocoder * v, double *c1, const int m1, const double a1, const double g1, double *c2, const int m2, const double a2, const double g2)
{
double a;
if (a1 == a2) {
HTS_gnorm(c1, c1, m1, g1);
HTS_gc2gc(v, c1, m1, g1, c2, m2, g2);
HTS_ignorm(c2, c2, m2, g2);
} else {
a = (a2 - a1) / (1 - a1 * a2);
HTS_freqt(v, c1, m1, c2, m2, a);
HTS_gnorm(c2, c2, m2, g1);
HTS_gc2gc(v, c2, m2, g1, c2, m2, g2);
HTS_ignorm(c2, c2, m2, g2);
}
}
/* HTS_lsp2mgc: transform LSP to MGC */
static void HTS_lsp2mgc(HTS_Vocoder * v, double *lsp, double *mgc, const int m, const double alpha)
{
int i;
/* lsp2lpc */
HTS_lsp2lpc(v, lsp + 1, mgc, m);
if (v->use_log_gain)
mgc[0] = exp(lsp[0]);
else
mgc[0] = lsp[0];
/* mgc2mgc */
if (NORMFLG1)
HTS_ignorm(mgc, mgc, m, v->gamma);
else if (MULGFLG1)
mgc[0] = (1.0 - mgc[0]) * ((double) v->stage);
if (MULGFLG1)
for (i = m; i >= 1; i--)
mgc[i] *= -((double) v->stage);
HTS_mgc2mgc(v, mgc, m, alpha, v->gamma, mgc, m, alpha, v->gamma);
if (NORMFLG2)
HTS_gnorm(mgc, mgc, m, v->gamma);
else if (MULGFLG2)
mgc[0] = mgc[0] * v->gamma + 1.0;
if (MULGFLG2)
for (i = m; i >= 1; i--)
mgc[i] *= v->gamma;
}
/* HTS_mglsadff: sub functions for MGLSA filter */
static double HTS_mglsadff(double x, const double *b, const int m, const double a, double *d)
{
int i;
double y;
y = d[0] * b[1];
for (i = 1; i < m; i++) {
d[i] += a * (d[i + 1] - d[i - 1]);
y += d[i] * b[i + 1];
}
x -= y;
for (i = m; i > 0; i--)
d[i] = d[i - 1];
d[0] = a * d[0] + (1 - a * a) * x;
return x;
}
/* HTS_mglsadf: sub functions for MGLSA filter */
static double HTS_mglsadf(double x, const double *b, const int m, const double a, const int n, double *d)
{
int i;
for (i = 0; i < n; i++)
x = HTS_mglsadff(x, b, m, a, &d[i * (m + 1)]);
return x;
}
/* THS_check_lsp_stability: check LSP stability */
static void HTS_check_lsp_stability(double *lsp, size_t m)
{
size_t i, j;
double tmp;
double min = (CHECK_LSP_STABILITY_MIN * PI) / (m + 1);
HTS_Boolean find;
for (i = 0; i < CHECK_LSP_STABILITY_NUM; i++) {
find = FALSE;
for (j = 1; j < m; j++) {
tmp = lsp[j + 1] - lsp[j];
if (tmp < min) {
lsp[j] -= 0.5 * (min - tmp);
lsp[j + 1] += 0.5 * (min - tmp);
find = TRUE;
}
}
if (lsp[1] < min) {
lsp[1] = min;
find = TRUE;
}
if (lsp[m] > PI - min) {
lsp[m] = PI - min;
find = TRUE;
}
if (find == FALSE)
break;
}
}
/* HTS_lsp2en: calculate frame energy */
static double HTS_lsp2en(HTS_Vocoder * v, double *lsp, size_t m, double alpha)
{
size_t i;
double en = 0.0;
double *buff;
if (v->spectrum2en_size < m) {
if (v->spectrum2en_buff != NULL)
HTS_free(v->spectrum2en_buff);
v->spectrum2en_buff = (double *) HTS_calloc(m + 1 + IRLENG, sizeof(double));
v->spectrum2en_size = m;
}
buff = v->spectrum2en_buff + m + 1;
/* lsp2lpc */
HTS_lsp2lpc(v, lsp + 1, v->spectrum2en_buff, m);
if (v->use_log_gain)
v->spectrum2en_buff[0] = exp(lsp[0]);
else
v->spectrum2en_buff[0] = lsp[0];
/* mgc2mgc */
if (NORMFLG1)
HTS_ignorm(v->spectrum2en_buff, v->spectrum2en_buff, m, v->gamma);
else if (MULGFLG1)
v->spectrum2en_buff[0] = (1.0 - v->spectrum2en_buff[0]) * ((double) v->stage);
if (MULGFLG1)
for (i = 1; i <= m; i++)
v->spectrum2en_buff[i] *= -((double) v->stage);
HTS_mgc2mgc(v, v->spectrum2en_buff, m, alpha, v->gamma, buff, IRLENG - 1, 0.0, 1);
for (i = 0; i < IRLENG; i++)
en += buff[i] * buff[i];
return en;
}
/* HTS_white_noise: return white noise */
static double HTS_white_noise(HTS_Vocoder * v)
{
if (v->gauss)
return (double) HTS_nrandom(v);
else
return (double) HTS_mseq(v);
}
/* HTS_Vocoder_initialize_excitation: initialize excitation */
static void HTS_Vocoder_initialize_excitation(HTS_Vocoder * v, double pitch, size_t nlpf)
{
size_t i;
v->pitch_of_curr_point = pitch;
v->pitch_counter = pitch;
v->pitch_inc_per_point = 0.0;
if (nlpf > 0) {
v->excite_buff_size = nlpf;
v->excite_ring_buff = (double *) HTS_calloc(v->excite_buff_size, sizeof(double));
for (i = 0; i < v->excite_buff_size; i++)
v->excite_ring_buff[i] = 0.0;
v->excite_buff_index = 0;
} else {
v->excite_buff_size = 0;
v->excite_ring_buff = NULL;
v->excite_buff_index = 0;
}
}
/* HTS_Vocoder_start_excitation: start excitation of each frame */
static void HTS_Vocoder_start_excitation(HTS_Vocoder * v, double pitch)
{
if (v->pitch_of_curr_point != 0.0 && pitch != 0.0) {
v->pitch_inc_per_point = (pitch - v->pitch_of_curr_point) / v->fprd;
} else {
v->pitch_inc_per_point = 0.0;
v->pitch_of_curr_point = pitch;
v->pitch_counter = pitch;
}
}
/* HTS_Vocoder_excite_unvoiced_frame: ping noise to ring buffer */
static void HTS_Vocoder_excite_unvoiced_frame(HTS_Vocoder * v, double noise)
{
size_t center = (v->excite_buff_size - 1) / 2;
v->excite_ring_buff[(v->excite_buff_index + center) % v->excite_buff_size] += noise;
}
/* HTS_Vocoder_excite_vooiced_frame: ping noise and pulse to ring buffer */
static void HTS_Vocoder_excite_voiced_frame(HTS_Vocoder * v, double noise, double pulse, const double *lpf)
{
size_t i;
size_t center = (v->excite_buff_size - 1) / 2;
if (noise != 0.0) {
for (i = 0; i < v->excite_buff_size; i++) {
if (i == center)
v->excite_ring_buff[(v->excite_buff_index + i) % v->excite_buff_size] += noise * (1.0 - lpf[i]);
else
v->excite_ring_buff[(v->excite_buff_index + i) % v->excite_buff_size] += noise * (0.0 - lpf[i]);
}
}
if (pulse != 0.0) {
for (i = 0; i < v->excite_buff_size; i++)
v->excite_ring_buff[(v->excite_buff_index + i) % v->excite_buff_size] += pulse * lpf[i];
}
}
/* HTS_Vocoder_get_excitation: get excitation of each sample */
static double HTS_Vocoder_get_excitation(HTS_Vocoder * v, const double *lpf)
{
double x;
double noise, pulse = 0.0;
if (v->excite_buff_size > 0) {
noise = HTS_white_noise(v);
pulse = 0.0;
if (v->pitch_of_curr_point == 0.0) {
HTS_Vocoder_excite_unvoiced_frame(v, noise);
} else {
v->pitch_counter += 1.0;
if (v->pitch_counter >= v->pitch_of_curr_point) {
pulse = sqrt(v->pitch_of_curr_point);
v->pitch_counter -= v->pitch_of_curr_point;
}
HTS_Vocoder_excite_voiced_frame(v, noise, pulse, lpf);
v->pitch_of_curr_point += v->pitch_inc_per_point;
}
x = v->excite_ring_buff[v->excite_buff_index];
v->excite_ring_buff[v->excite_buff_index] = 0.0;
v->excite_buff_index++;
if (v->excite_buff_index >= v->excite_buff_size)
v->excite_buff_index = 0;
} else {
if (v->pitch_of_curr_point == 0.0) {
x = HTS_white_noise(v);
} else {
v->pitch_counter += 1.0;
if (v->pitch_counter >= v->pitch_of_curr_point) {
x = sqrt(v->pitch_of_curr_point);
v->pitch_counter -= v->pitch_of_curr_point;
} else {
x = 0.0;
}
v->pitch_of_curr_point += v->pitch_inc_per_point;
}
}
return x;
}
/* HTS_Vocoder_end_excitation: end excitation of each frame */
static void HTS_Vocoder_end_excitation(HTS_Vocoder * v, double pitch)
{
v->pitch_of_curr_point = pitch;
}
/* HTS_Vocoder_postfilter_mcp: postfilter for MCP */
static void HTS_Vocoder_postfilter_mcp(HTS_Vocoder * v, double *mcp, const int m, double alpha, double beta)
{
double e1, e2;
int k;
if (beta > 0.0 && m > 1) {
if (v->postfilter_size < m) {
if (v->postfilter_buff != NULL)
HTS_free(v->postfilter_buff);
v->postfilter_buff = (double *) HTS_calloc(m + 1, sizeof(double));
v->postfilter_size = m;
}
HTS_mc2b(mcp, v->postfilter_buff, m, alpha);
e1 = HTS_b2en(v, v->postfilter_buff, m, alpha);
v->postfilter_buff[1] -= beta * alpha * v->postfilter_buff[2];
for (k = 2; k <= m; k++)
v->postfilter_buff[k] *= (1.0 + beta);
e2 = HTS_b2en(v, v->postfilter_buff, m, alpha);
v->postfilter_buff[0] += log(e1 / e2) / 2;
HTS_b2mc(v->postfilter_buff, mcp, m, alpha);
}
}
/* HTS_Vocoder_postfilter_lsp: postfilter for LSP */
static void HTS_Vocoder_postfilter_lsp(HTS_Vocoder * v, double *lsp, size_t m, double alpha, double beta)
{
double e1, e2;
size_t i;
double d1, d2;
if (beta > 0.0 && m > 1) {
if (v->postfilter_size < m) {
if (v->postfilter_buff != NULL)
HTS_free(v->postfilter_buff);
v->postfilter_buff = (double *) HTS_calloc(m + 1, sizeof(double));
v->postfilter_size = m;
}
e1 = HTS_lsp2en(v, lsp, m, alpha);
/* postfiltering */
for (i = 0; i <= m; i++) {
if (i > 1 && i < m) {
d1 = beta * (lsp[i + 1] - lsp[i]);
d2 = beta * (lsp[i] - lsp[i - 1]);
v->postfilter_buff[i] = lsp[i - 1] + d2 + (d2 * d2 * ((lsp[i + 1] - lsp[i - 1]) - (d1 + d2))) / ((d2 * d2) + (d1 * d1));
} else {
v->postfilter_buff[i] = lsp[i];
}
}
HTS_movem(v->postfilter_buff, lsp, m + 1);
e2 = HTS_lsp2en(v, lsp, m, alpha);
if (e1 != e2) {
if (v->use_log_gain)
lsp[0] += 0.5 * log(e1 / e2);
else
lsp[0] *= sqrt(e1 / e2);
}
}
}
/* HTS_Vocoder_initialize: initialize vocoder */
void HTS_Vocoder_initialize(HTS_Vocoder * v, size_t m, size_t stage, HTS_Boolean use_log_gain, size_t rate, size_t fperiod)
{
/* set parameter */
v->is_first = TRUE;
v->stage = stage;
if (stage != 0)
v->gamma = -1.0 / v->stage;
else
v->gamma = 0.0;
v->use_log_gain = use_log_gain;
v->fprd = fperiod;
v->next = SEED;
v->gauss = GAUSS;
v->rate = rate;
v->pitch_of_curr_point = 0.0;
v->pitch_counter = 0.0;
v->pitch_inc_per_point = 0.0;
v->excite_ring_buff = NULL;
v->excite_buff_size = 0;
v->excite_buff_index = 0;
v->sw = 0;
v->x = 0x55555555;
/* init buffer */
v->freqt_buff = NULL;
v->freqt_size = 0;
v->gc2gc_buff = NULL;
v->gc2gc_size = 0;
v->lsp2lpc_buff = NULL;
v->lsp2lpc_size = 0;
v->postfilter_buff = NULL;
v->postfilter_size = 0;
v->spectrum2en_buff = NULL;
v->spectrum2en_size = 0;
if (v->stage == 0) { /* for MCP */
v->c = (double *) HTS_calloc(m * (3 + PADEORDER) + 5 * PADEORDER + 6, sizeof(double));
v->cc = v->c + m + 1;
v->cinc = v->cc + m + 1;
v->d1 = v->cinc + m + 1;
} else { /* for LSP */
v->c = (double *) HTS_calloc((m + 1) * (v->stage + 3), sizeof(double));
v->cc = v->c + m + 1;
v->cinc = v->cc + m + 1;
v->d1 = v->cinc + m + 1;
}
}
/* HTS_Vocoder_synthesize: pulse/noise excitation and MLSA/MGLSA filster based waveform synthesis */
void HTS_Vocoder_synthesize(HTS_Vocoder * v, size_t m, double lf0, double *spectrum, size_t nlpf, double *lpf, double alpha, double beta, double volume, double *rawdata, HTS_Audio * audio)
{
double x;
int i, j;
short xs;
int rawidx = 0;
double p;
/* lf0 -> pitch */
if (lf0 == LZERO)
p = 0.0;
else if (lf0 <= MIN_LF0)
p = v->rate / MIN_F0;
else if (lf0 >= MAX_LF0)
p = v->rate / MAX_F0;
else
p = v->rate / exp(lf0);
/* first time */
if (v->is_first == TRUE) {
HTS_Vocoder_initialize_excitation(v, p, nlpf);
if (v->stage == 0) { /* for MCP */
HTS_mc2b(spectrum, v->c, m, alpha);
} else { /* for LSP */
HTS_movem(spectrum, v->c, m + 1);
HTS_lsp2mgc(v, v->c, v->c, m, alpha);
HTS_mc2b(v->c, v->c, m, alpha);
HTS_gnorm(v->c, v->c, m, v->gamma);
for (i = 1; i <= m; i++)
v->c[i] *= v->gamma;
}
v->is_first = FALSE;
}
HTS_Vocoder_start_excitation(v, p);
if (v->stage == 0) { /* for MCP */
HTS_Vocoder_postfilter_mcp(v, spectrum, m, alpha, beta);
HTS_mc2b(spectrum, v->cc, m, alpha);
for (i = 0; i <= m; i++)
v->cinc[i] = (v->cc[i] - v->c[i]) / v->fprd;
} else { /* for LSP */
HTS_Vocoder_postfilter_lsp(v, spectrum, m, alpha, beta);
HTS_check_lsp_stability(spectrum, m);
HTS_lsp2mgc(v, spectrum, v->cc, m, alpha);
HTS_mc2b(v->cc, v->cc, m, alpha);
HTS_gnorm(v->cc, v->cc, m, v->gamma);
for (i = 1; i <= m; i++)
v->cc[i] *= v->gamma;
for (i = 0; i <= m; i++)
v->cinc[i] = (v->cc[i] - v->c[i]) / v->fprd;
}
for (j = 0; j < v->fprd; j++) {
x = HTS_Vocoder_get_excitation(v, lpf);
if (v->stage == 0) { /* for MCP */
if (x != 0.0)
x *= exp(v->c[0]);
x = HTS_mlsadf(x, v->c, m, alpha, PADEORDER, v->d1);
} else { /* for LSP */
if (!NGAIN)
x *= v->c[0];
x = HTS_mglsadf(x, v->c, m, alpha, v->stage, v->d1);
}
x *= volume;
/* output */
if (rawdata)
rawdata[rawidx++] = x;
if (audio) {
if (x > 32767.0)
xs = 32767;
else if (x < -32768.0)
xs = -32768;
else
xs = (short) x;
HTS_Audio_write(audio, xs);
}
for (i = 0; i <= m; i++)
v->c[i] += v->cinc[i];
}
HTS_Vocoder_end_excitation(v, p);
HTS_movem(v->cc, v->c, m + 1);
}
/* HTS_Vocoder_clear: clear vocoder */
void HTS_Vocoder_clear(HTS_Vocoder * v)
{
if (v != NULL) {
/* free buffer */
if (v->freqt_buff != NULL) {
HTS_free(v->freqt_buff);
v->freqt_buff = NULL;
}
v->freqt_size = 0;
if (v->gc2gc_buff != NULL) {
HTS_free(v->gc2gc_buff);
v->gc2gc_buff = NULL;
}
v->gc2gc_size = 0;
if (v->lsp2lpc_buff != NULL) {
HTS_free(v->lsp2lpc_buff);
v->lsp2lpc_buff = NULL;
}
v->lsp2lpc_size = 0;
if (v->postfilter_buff != NULL) {
HTS_free(v->postfilter_buff);
v->postfilter_buff = NULL;
}
v->postfilter_size = 0;
if (v->spectrum2en_buff != NULL) {
HTS_free(v->spectrum2en_buff);
v->spectrum2en_buff = NULL;
}
v->spectrum2en_size = 0;
if (v->c != NULL) {
HTS_free(v->c);
v->c = NULL;
}
v->excite_buff_size = 0;
v->excite_buff_index = 0;
if (v->excite_ring_buff != NULL) {
HTS_free(v->excite_ring_buff);
v->excite_ring_buff = NULL;
}
}
}
HTS_VOCODER_C_END;
#endif /* !HTS_VOCODER_C */

14
3rdparty/hts_engine_API/lib/Makefile.am vendored Normal file
View File

@@ -0,0 +1,14 @@
EXTRA_DIST = Makefile.mak
AM_CPPFLAGS = -I @top_srcdir@/include
lib_LIBRARIES = libHTSEngine.a
libHTSEngine_a_SOURCES = HTS_audio.c HTS_engine.c HTS_hidden.h HTS_misc.c \
HTS_pstream.c HTS_sstream.c HTS_model.c HTS_vocoder.c \
HTS_gstream.c HTS_label.c
DISTCLEANFILES = *.log *.out *~
MAINTAINERCLEANFILES = Makefile.in

613
3rdparty/hts_engine_API/lib/Makefile.in vendored Normal file
View File

@@ -0,0 +1,613 @@
# Makefile.in generated by automake 1.15 from Makefile.am.
# @configure_input@
# Copyright (C) 1994-2014 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
@SET_MAKE@
VPATH = @srcdir@
am__is_gnu_make = { \
if test -z '$(MAKELEVEL)'; then \
false; \
elif test -n '$(MAKE_HOST)'; then \
true; \
elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
true; \
else \
false; \
fi; \
}
am__make_running_with_option = \
case $${target_option-} in \
?) ;; \
*) echo "am__make_running_with_option: internal error: invalid" \
"target option '$${target_option-}' specified" >&2; \
exit 1;; \
esac; \
has_opt=no; \
sane_makeflags=$$MAKEFLAGS; \
if $(am__is_gnu_make); then \
sane_makeflags=$$MFLAGS; \
else \
case $$MAKEFLAGS in \
*\\[\ \ ]*) \
bs=\\; \
sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
| sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \
esac; \
fi; \
skip_next=no; \
strip_trailopt () \
{ \
flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
}; \
for flg in $$sane_makeflags; do \
test $$skip_next = yes && { skip_next=no; continue; }; \
case $$flg in \
*=*|--*) continue;; \
-*I) strip_trailopt 'I'; skip_next=yes;; \
-*I?*) strip_trailopt 'I';; \
-*O) strip_trailopt 'O'; skip_next=yes;; \
-*O?*) strip_trailopt 'O';; \
-*l) strip_trailopt 'l'; skip_next=yes;; \
-*l?*) strip_trailopt 'l';; \
-[dEDm]) skip_next=yes;; \
-[JT]) skip_next=yes;; \
esac; \
case $$flg in \
*$$target_option*) has_opt=yes; break;; \
esac; \
done; \
test $$has_opt = yes
am__make_dryrun = (target_option=n; $(am__make_running_with_option))
am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
pkgdatadir = $(datadir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkglibexecdir = $(libexecdir)/@PACKAGE@
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
install_sh_DATA = $(install_sh) -c -m 644
install_sh_PROGRAM = $(install_sh) -c
install_sh_SCRIPT = $(install_sh) -c
INSTALL_HEADER = $(INSTALL_DATA)
transform = $(program_transform_name)
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
subdir = lib
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
mkinstalldirs = $(install_sh) -d
CONFIG_CLEAN_FILES =
CONFIG_CLEAN_VPATH_FILES =
am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
am__vpath_adj = case $$p in \
$(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
*) f=$$p;; \
esac;
am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
am__install_max = 40
am__nobase_strip_setup = \
srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
am__nobase_strip = \
for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
am__nobase_list = $(am__nobase_strip_setup); \
for p in $$list; do echo "$$p $$p"; done | \
sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
$(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
if (++n[$$2] == $(am__install_max)) \
{ print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
END { for (dir in files) print dir, files[dir] }'
am__base_list = \
sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
am__uninstall_files_from_dir = { \
test -z "$$files" \
|| { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \
|| { echo " ( cd '$$dir' && rm -f" $$files ")"; \
$(am__cd) "$$dir" && rm -f $$files; }; \
}
am__installdirs = "$(DESTDIR)$(libdir)"
LIBRARIES = $(lib_LIBRARIES)
ARFLAGS = cru
AM_V_AR = $(am__v_AR_@AM_V@)
am__v_AR_ = $(am__v_AR_@AM_DEFAULT_V@)
am__v_AR_0 = @echo " AR " $@;
am__v_AR_1 =
libHTSEngine_a_AR = $(AR) $(ARFLAGS)
libHTSEngine_a_LIBADD =
am_libHTSEngine_a_OBJECTS = HTS_audio.$(OBJEXT) HTS_engine.$(OBJEXT) \
HTS_misc.$(OBJEXT) HTS_pstream.$(OBJEXT) HTS_sstream.$(OBJEXT) \
HTS_model.$(OBJEXT) HTS_vocoder.$(OBJEXT) \
HTS_gstream.$(OBJEXT) HTS_label.$(OBJEXT)
libHTSEngine_a_OBJECTS = $(am_libHTSEngine_a_OBJECTS)
AM_V_P = $(am__v_P_@AM_V@)
am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
am__v_P_0 = false
am__v_P_1 = :
AM_V_GEN = $(am__v_GEN_@AM_V@)
am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
am__v_GEN_0 = @echo " GEN " $@;
am__v_GEN_1 =
AM_V_at = $(am__v_at_@AM_V@)
am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
am__v_at_0 = @
am__v_at_1 =
DEFAULT_INCLUDES = -I.@am__isrc@
depcomp = $(SHELL) $(top_srcdir)/config/depcomp
am__depfiles_maybe = depfiles
am__mv = mv -f
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
AM_V_CC = $(am__v_CC_@AM_V@)
am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@)
am__v_CC_0 = @echo " CC " $@;
am__v_CC_1 =
CCLD = $(CC)
LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
AM_V_CCLD = $(am__v_CCLD_@AM_V@)
am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
am__v_CCLD_0 = @echo " CCLD " $@;
am__v_CCLD_1 =
SOURCES = $(libHTSEngine_a_SOURCES)
DIST_SOURCES = $(libHTSEngine_a_SOURCES)
am__can_run_installinfo = \
case $$AM_UPDATE_INFO_DIR in \
n|no|NO) false;; \
*) (install-info --version) >/dev/null 2>&1;; \
esac
am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
# Read a list of newline-separated strings from the standard input,
# and print each of them once, without duplicates. Input order is
# *not* preserved.
am__uniquify_input = $(AWK) '\
BEGIN { nonempty = 0; } \
{ items[$$0] = 1; nonempty = 1; } \
END { if (nonempty) { for (i in items) print i; }; } \
'
# Make sure the list of sources is unique. This is necessary because,
# e.g., the same source file might be shared among _SOURCES variables
# for different programs/libraries.
am__define_uniq_tagged_files = \
list='$(am__tagged_files)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | $(am__uniquify_input)`
ETAGS = etags
CTAGS = ctags
am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/config/depcomp
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
ACLOCAL = @ACLOCAL@
AMTAR = @AMTAR@
AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
AR = @AR@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
AWK = @AWK@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
GREP = @GREP@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LDFLAGS = @LDFLAGS@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
LTLIBOBJS = @LTLIBOBJS@
MAKEINFO = @MAKEINFO@
MKDIR_P = @MKDIR_P@
OBJEXT = @OBJEXT@
PACKAGE = @PACKAGE@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_URL = @PACKAGE_URL@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
RANLIB = @RANLIB@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
VERSION = @VERSION@
abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
abs_top_builddir = @abs_top_builddir@
abs_top_srcdir = @abs_top_srcdir@
ac_ct_CC = @ac_ct_CC@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
am__quote = @am__quote@
am__tar = @am__tar@
am__untar = @am__untar@
bindir = @bindir@
build = @build@
build_alias = @build_alias@
build_cpu = @build_cpu@
build_os = @build_os@
build_vendor = @build_vendor@
builddir = @builddir@
datadir = @datadir@
datarootdir = @datarootdir@
docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
host_os = @host_os@
host_vendor = @host_vendor@
htmldir = @htmldir@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
libdir = @libdir@
libexecdir = @libexecdir@
localedir = @localedir@
localstatedir = @localstatedir@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
sysconfdir = @sysconfdir@
target_alias = @target_alias@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
EXTRA_DIST = Makefile.mak
AM_CPPFLAGS = -I @top_srcdir@/include
lib_LIBRARIES = libHTSEngine.a
libHTSEngine_a_SOURCES = HTS_audio.c HTS_engine.c HTS_hidden.h HTS_misc.c \
HTS_pstream.c HTS_sstream.c HTS_model.c HTS_vocoder.c \
HTS_gstream.c HTS_label.c
DISTCLEANFILES = *.log *.out *~
MAINTAINERCLEANFILES = Makefile.in
all: all-am
.SUFFIXES:
.SUFFIXES: .c .o .obj
$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
&& { if test -f $@; then exit 0; else break; fi; }; \
exit 1;; \
esac; \
done; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu lib/Makefile'; \
$(am__cd) $(top_srcdir) && \
$(AUTOMAKE) --gnu lib/Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
*config.status*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
*) \
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
esac;
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(top_srcdir)/configure: $(am__configure_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(ACLOCAL_M4): $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(am__aclocal_m4_deps):
install-libLIBRARIES: $(lib_LIBRARIES)
@$(NORMAL_INSTALL)
@list='$(lib_LIBRARIES)'; test -n "$(libdir)" || list=; \
list2=; for p in $$list; do \
if test -f $$p; then \
list2="$$list2 $$p"; \
else :; fi; \
done; \
test -z "$$list2" || { \
echo " $(MKDIR_P) '$(DESTDIR)$(libdir)'"; \
$(MKDIR_P) "$(DESTDIR)$(libdir)" || exit 1; \
echo " $(INSTALL_DATA) $$list2 '$(DESTDIR)$(libdir)'"; \
$(INSTALL_DATA) $$list2 "$(DESTDIR)$(libdir)" || exit $$?; }
@$(POST_INSTALL)
@list='$(lib_LIBRARIES)'; test -n "$(libdir)" || list=; \
for p in $$list; do \
if test -f $$p; then \
$(am__strip_dir) \
echo " ( cd '$(DESTDIR)$(libdir)' && $(RANLIB) $$f )"; \
( cd "$(DESTDIR)$(libdir)" && $(RANLIB) $$f ) || exit $$?; \
else :; fi; \
done
uninstall-libLIBRARIES:
@$(NORMAL_UNINSTALL)
@list='$(lib_LIBRARIES)'; test -n "$(libdir)" || list=; \
files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
dir='$(DESTDIR)$(libdir)'; $(am__uninstall_files_from_dir)
clean-libLIBRARIES:
-test -z "$(lib_LIBRARIES)" || rm -f $(lib_LIBRARIES)
libHTSEngine.a: $(libHTSEngine_a_OBJECTS) $(libHTSEngine_a_DEPENDENCIES) $(EXTRA_libHTSEngine_a_DEPENDENCIES)
$(AM_V_at)-rm -f libHTSEngine.a
$(AM_V_AR)$(libHTSEngine_a_AR) libHTSEngine.a $(libHTSEngine_a_OBJECTS) $(libHTSEngine_a_LIBADD)
$(AM_V_at)$(RANLIB) libHTSEngine.a
mostlyclean-compile:
-rm -f *.$(OBJEXT)
distclean-compile:
-rm -f *.tab.c
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/HTS_audio.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/HTS_engine.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/HTS_gstream.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/HTS_label.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/HTS_misc.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/HTS_model.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/HTS_pstream.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/HTS_sstream.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/HTS_vocoder.Po@am__quote@
.c.o:
@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $<
.c.obj:
@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
ID: $(am__tagged_files)
$(am__define_uniq_tagged_files); mkid -fID $$unique
tags: tags-am
TAGS: tags
tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
set x; \
here=`pwd`; \
$(am__define_uniq_tagged_files); \
shift; \
if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
test -n "$$unique" || unique=$$empty_fix; \
if test $$# -gt 0; then \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
"$$@" $$unique; \
else \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
$$unique; \
fi; \
fi
ctags: ctags-am
CTAGS: ctags
ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
$(am__define_uniq_tagged_files); \
test -z "$(CTAGS_ARGS)$$unique" \
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
$$unique
GTAGS:
here=`$(am__cd) $(top_builddir) && pwd` \
&& $(am__cd) $(top_srcdir) \
&& gtags -i $(GTAGS_ARGS) "$$here"
cscopelist: cscopelist-am
cscopelist-am: $(am__tagged_files)
list='$(am__tagged_files)'; \
case "$(srcdir)" in \
[\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
*) sdir=$(subdir)/$(srcdir) ;; \
esac; \
for i in $$list; do \
if test -f "$$i"; then \
echo "$(subdir)/$$i"; \
else \
echo "$$sdir/$$i"; \
fi; \
done >> $(top_builddir)/cscope.files
distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
distdir: $(DISTFILES)
@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
list='$(DISTFILES)'; \
dist_files=`for file in $$list; do echo $$file; done | \
sed -e "s|^$$srcdirstrip/||;t" \
-e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
case $$dist_files in \
*/*) $(MKDIR_P) `echo "$$dist_files" | \
sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
sort -u` ;; \
esac; \
for file in $$dist_files; do \
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
if test -d $$d/$$file; then \
dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
if test -d "$(distdir)/$$file"; then \
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
fi; \
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
fi; \
cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
else \
test -f "$(distdir)/$$file" \
|| cp -p $$d/$$file "$(distdir)/$$file" \
|| exit 1; \
fi; \
done
check-am: all-am
check: check-am
all-am: Makefile $(LIBRARIES)
installdirs:
for dir in "$(DESTDIR)$(libdir)"; do \
test -z "$$dir" || $(MKDIR_P) "$$dir"; \
done
install: install-am
install-exec: install-exec-am
install-data: install-data-am
uninstall: uninstall-am
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
installcheck: installcheck-am
install-strip:
if test -z '$(STRIP)'; then \
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
install; \
else \
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
"INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
fi
mostlyclean-generic:
clean-generic:
distclean-generic:
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
-test -z "$(DISTCLEANFILES)" || rm -f $(DISTCLEANFILES)
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@echo "it deletes files that may require special tools to rebuild."
-test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES)
clean: clean-am
clean-am: clean-generic clean-libLIBRARIES mostlyclean-am
distclean: distclean-am
-rm -rf ./$(DEPDIR)
-rm -f Makefile
distclean-am: clean-am distclean-compile distclean-generic \
distclean-tags
dvi: dvi-am
dvi-am:
html: html-am
html-am:
info: info-am
info-am:
install-data-am:
install-dvi: install-dvi-am
install-dvi-am:
install-exec-am: install-libLIBRARIES
install-html: install-html-am
install-html-am:
install-info: install-info-am
install-info-am:
install-man:
install-pdf: install-pdf-am
install-pdf-am:
install-ps: install-ps-am
install-ps-am:
installcheck-am:
maintainer-clean: maintainer-clean-am
-rm -rf ./$(DEPDIR)
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-am
mostlyclean-am: mostlyclean-compile mostlyclean-generic
pdf: pdf-am
pdf-am:
ps: ps-am
ps-am:
uninstall-am: uninstall-libLIBRARIES
.MAKE: install-am install-strip
.PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \
clean-libLIBRARIES cscopelist-am ctags ctags-am distclean \
distclean-compile distclean-generic distclean-tags distdir dvi \
dvi-am html html-am info info-am install install-am \
install-data install-data-am install-dvi install-dvi-am \
install-exec install-exec-am install-html install-html-am \
install-info install-info-am install-libLIBRARIES install-man \
install-pdf install-pdf-am install-ps install-ps-am \
install-strip installcheck installcheck-am installdirs \
maintainer-clean maintainer-clean-generic mostlyclean \
mostlyclean-compile mostlyclean-generic pdf pdf-am ps ps-am \
tags tags-am uninstall uninstall-am uninstall-libLIBRARIES
.PRECIOUS: Makefile
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:

View File

@@ -0,0 +1,19 @@
CC = cl
CFLAGS = /O2 /Ob2 /Oi /Ot /Oy /GT /GL /TC /I ..\include
LFLAGS = /LTCG
CORES = HTS_audio.obj HTS_engine.obj HTS_gstream.obj HTS_label.obj HTS_misc.obj HTS_model.obj HTS_pstream.obj HTS_sstream.obj HTS_vocoder.obj
all: hts_engine_API.lib
hts_engine_API.lib: $(CORES)
lib $(LFLAGS) /OUT:$@ $(CORES)
.c.obj:
$(CC) $(CFLAGS) /c $<
clean:
del *.lib
del *.obj