From sumomo @ users.sourceforge.jp Tue Jul 1 13:29:45 2008 From: sumomo @ users.sourceforge.jp (sumomo @ users.sourceforge.jp) Date: Tue, 01 Jul 2008 13:29:45 +0900 Subject: [Julius-cvs 190] CVS update: julius4/libjulius/include/julius Message-ID: <1214886585.674862.28938.nullmailer@users.sourceforge.jp> Index: julius4/libjulius/include/julius/jconf.h diff -u julius4/libjulius/include/julius/jconf.h:1.3 julius4/libjulius/include/julius/jconf.h:1.4 --- julius4/libjulius/include/julius/jconf.h:1.3 Sun Apr 27 22:06:55 2008 +++ julius4/libjulius/include/julius/jconf.h Tue Jul 1 13:29:45 2008 @@ -23,7 +23,7 @@ * @author Akinobu Lee * @date Fri Feb 16 13:42:28 2007 * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * */ /* @@ -768,6 +768,11 @@ */ int speech_input; /** + * Input device. + * + */ + int device; + /** * Sampling frequency * */ From sumomo @ users.sourceforge.jp Tue Jul 1 13:29:45 2008 From: sumomo @ users.sourceforge.jp (sumomo @ users.sourceforge.jp) Date: Tue, 01 Jul 2008 13:29:45 +0900 Subject: [Julius-cvs 191] CVS update: julius4/libjulius/src Message-ID: <1214886585.920692.28954.nullmailer@users.sourceforge.jp> Index: julius4/libjulius/src/default.c diff -u julius4/libjulius/src/default.c:1.4 julius4/libjulius/src/default.c:1.5 --- julius4/libjulius/src/default.c:1.4 Sun Apr 27 22:06:55 2008 +++ julius4/libjulius/src/default.c Tue Jul 1 13:29:45 2008 @@ -17,7 +17,7 @@ * @author Akinobu Lee * @date Fri Feb 16 15:05:43 2007 * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * */ /* @@ -57,6 +57,7 @@ jconf_set_default_values(Jconf *j) { j->input.speech_input = SP_MFCFILE; + j->input.device = SP_INPUT_DEFAULT; j->input.sfreq = 16000; j->input.period = 625; j->input.framesize = DEF_FRAMESIZE; Index: julius4/libjulius/src/m_adin.c diff -u julius4/libjulius/src/m_adin.c:1.4 julius4/libjulius/src/m_adin.c:1.5 --- julius4/libjulius/src/m_adin.c:1.4 Thu May 8 14:45:03 2008 +++ julius4/libjulius/src/m_adin.c Tue Jul 1 13:29:45 2008 @@ -12,7 +12,7 @@ * @author Akinobu LEE * @date Fri Mar 18 16:17:23 2005 * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * */ /* @@ -34,7 +34,7 @@ * @return TRUE on success, FALSE if @a source is not available. */ static boolean -adin_select(ADIn *a, int source) +adin_select(ADIn *a, int source, int dev) { switch(source) { case SP_RAWFILE: @@ -63,14 +63,36 @@ #ifdef USE_MIC case SP_MIC: /* microphone input */ - a->ad_standby = adin_mic_standby; - a->ad_begin = adin_mic_begin; - a->ad_end = adin_mic_end; a->ad_resume = NULL; a->ad_pause = NULL; - a->ad_read = adin_mic_read; a->silence_cut_default = TRUE; a->enable_thread = TRUE; + switch(dev) { + case SP_INPUT_DEFAULT: + a->ad_standby = adin_mic_standby; + a->ad_begin = adin_mic_begin; + a->ad_end = adin_mic_end; + a->ad_read = adin_mic_read; + break; + case SP_INPUT_ALSA: + a->ad_standby = adin_alsa_standby; + a->ad_begin = adin_alsa_begin; + a->ad_end = adin_alsa_end; + a->ad_read = adin_alsa_read; + break; + case SP_INPUT_OSS: + a->ad_standby = adin_oss_standby; + a->ad_begin = adin_oss_begin; + a->ad_end = adin_oss_end; + a->ad_read = adin_oss_read; + break; + case SP_INPUT_ESD: + a->ad_standby = adin_esd_standby; + a->ad_begin = adin_esd_begin; + a->ad_end = adin_esd_end; + a->ad_read = adin_esd_read; + break; + } break; #endif #ifdef USE_NETAUDIO @@ -203,7 +225,7 @@ jlog("STAT: ###### initialize input device\n"); /* select input device: file, mic, netaudio, etc... */ - if (adin_select(adin, jconf->input.speech_input) == FALSE) { + if (adin_select(adin, jconf->input.speech_input, jconf->input.device) == FALSE) { jlog("ERROR: m_adin: failed to select input device\n"); return FALSE; } Index: julius4/libjulius/src/m_info.c diff -u julius4/libjulius/src/m_info.c:1.6 julius4/libjulius/src/m_info.c:1.7 --- julius4/libjulius/src/m_info.c:1.6 Tue Jun 17 10:20:50 2008 +++ julius4/libjulius/src/m_info.c Tue Jul 1 13:29:45 2008 @@ -12,7 +12,7 @@ * @author Akinobu Lee * @date Thu May 12 14:14:01 2005 * - * $Revision: 1.6 $ + * $Revision: 1.7 $ * */ /* @@ -799,6 +799,13 @@ #endif } else if (jconf->input.speech_input == SP_MIC) { jlog("microphone\n"); + jlog("\t device API = "); + switch(jconf->input.device) { + case SP_INPUT_DEFAULT: jlog("default"); break; + case SP_INPUT_ALSA: jlog("alsa"); break; + case SP_INPUT_OSS: jlog("oss"); break; + case SP_INPUT_ESD: jlog("esd"); break; + } } if (jconf->input.speech_input != SP_MFCFILE) { if (jconf->input.speech_input == SP_RAWFILE || jconf->input.speech_input == SP_STDIN || jconf->input.speech_input == SP_ADINNET) { Index: julius4/libjulius/src/m_options.c diff -u julius4/libjulius/src/m_options.c:1.9 julius4/libjulius/src/m_options.c:1.10 --- julius4/libjulius/src/m_options.c:1.9 Tue Jun 17 10:20:50 2008 +++ julius4/libjulius/src/m_options.c Tue Jul 1 13:29:45 2008 @@ -18,7 +18,7 @@ * @author Akinobu Lee * @date Thu May 12 18:52:07 2005 * - * $Revision: 1.9 $ + * $Revision: 1.10 $ * */ /* @@ -283,6 +283,19 @@ #ifdef USE_MIC } else if (strmatch(tmparg,"mic")) { jconf->input.speech_input = SP_MIC; + jconf->input.device = SP_INPUT_DEFAULT; + jconf->decodeopt.realtime_flag = TRUE; + } else if (strmatch(tmparg,"alsa")) { + jconf->input.speech_input = SP_MIC; + jconf->input.device = SP_INPUT_ALSA; + jconf->decodeopt.realtime_flag = TRUE; + } else if (strmatch(tmparg,"oss")) { + jconf->input.speech_input = SP_MIC; + jconf->input.device = SP_INPUT_OSS; + jconf->decodeopt.realtime_flag = TRUE; + } else if (strmatch(tmparg,"esd")) { + jconf->input.speech_input = SP_MIC; + jconf->input.device = SP_INPUT_ESD; jconf->decodeopt.realtime_flag = TRUE; #endif } else if (strmatch(tmparg,"file")) { /* for 1.1 compat */ Index: julius4/libjulius/src/m_usage.c diff -u julius4/libjulius/src/m_usage.c:1.7 julius4/libjulius/src/m_usage.c:1.8 --- julius4/libjulius/src/m_usage.c:1.7 Tue Jun 17 10:20:50 2008 +++ julius4/libjulius/src/m_usage.c Tue Jul 1 13:29:45 2008 @@ -12,7 +12,7 @@ * @author Akinobu Lee * @date Fri May 13 15:04:34 2005 * - * $Revision: 1.7 $ + * $Revision: 1.8 $ * */ /* @@ -63,6 +63,15 @@ fprintf(fp, " (format: %s)\n", SUPPORTED_WAVEFILE_FORMAT); #ifdef USE_MIC fprintf(fp, " mic microphone device\n"); +# ifdef HAS_ALSA + fprintf(fp, " alsa use ALSA interface\n"); +# endif +# ifdef HAS_OSS + fprintf(fp, " oss use OSS interface\n"); +# endif +# ifdef HAS_ESD + fprintf(fp, " esd use ESounD interface\n"); +# endif #endif #ifdef USE_NETAUDIO fprintf(fp, " netaudio DatLink/NetAudio server\n"); From sumomo @ users.sourceforge.jp Tue Jul 1 13:29:46 2008 From: sumomo @ users.sourceforge.jp (sumomo @ users.sourceforge.jp) Date: Tue, 01 Jul 2008 13:29:46 +0900 Subject: [Julius-cvs 192] CVS update: julius4/libsent Message-ID: <1214886586.104293.28965.nullmailer@users.sourceforge.jp> Index: julius4/libsent/configure diff -u julius4/libsent/configure:1.6 julius4/libsent/configure:1.7 --- julius4/libsent/configure:1.6 Tue May 27 18:16:39 2008 +++ julius4/libsent/configure Tue Jul 1 13:29:45 2008 @@ -1826,122 +1826,252 @@ ;; esac -if test "$with_mictype" = auto; then - echo $ac_n "checking for input device type""... $ac_c" 1>&6 -echo "configure:1832: checking for input device type" >&5 - altype=no - case "$host_os" in - linux*) - # ALSA - cat > conftest.$ac_ext <&6 +echo "configure:1836: checking for $ac_hdr" >&5 +if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +#include <$ac_hdr> EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1843: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:1846: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* - altype=alsa + eval "ac_cv_header_$ac_safe=yes" else echo "$ac_err" >&5 echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_header_$ac_safe=no" fi rm -f conftest* - if test "$altype" = no; then - cat > conftest.$ac_ext <&6 + ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'` + cat >> confdefs.h <&6 +for ac_hdr in sys/asoundlib.h +do +ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` +echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 +echo "configure:1873: checking for $ac_hdr" >&5 +if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +#include <$ac_hdr> EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1861: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:1883: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* - altype=alsa + eval "ac_cv_header_$ac_safe=yes" else echo "$ac_err" >&5 echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_header_$ac_safe=no" fi rm -f conftest* - if test "$altype" = no; then - # OSS - cat > conftest.$ac_ext <&6 + ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'` + cat >> confdefs.h <&6 +has_alsa=no + +fi +done + +fi +done + +# OSS +has_oss=yes +for ac_hdr in sys/soundcard.h +do +ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` +echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 +echo "configure:1920: checking for $ac_hdr" >&5 +if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +#include <$ac_hdr> EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1880: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:1930: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* - altype=oss + eval "ac_cv_header_$ac_safe=yes" else echo "$ac_err" >&5 echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_header_$ac_safe=no" fi rm -f conftest* - if test "$altype" = no; then - { echo "configure: error: no audio header file!" 1>&2; exit 1; } - fi - echo "configure: warning: no ALSA header, use OSS instead" 1>&2 - fi - fi - ;; - freebsd*) - # FreeBSD (snd driver) - cat > conftest.$ac_ext <&6 + ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'` + cat >> confdefs.h <&6 +for ac_hdr in machine/soundcard.h +do +ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` +echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 +echo "configure:1957: checking for $ac_hdr" >&5 +if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +#include <$ac_hdr> EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1906: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:1967: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* - altype=freebsd + eval "ac_cv_header_$ac_safe=yes" else echo "$ac_err" >&5 echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_header_$ac_safe=no" fi rm -f conftest* - if test "$altype" = no; then - cat > conftest.$ac_ext <&6 + ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'` + cat >> confdefs.h <&6 +has_oss=no + +fi +done + +fi +done + +# ESounD +has_esd=yes +for ac_hdr in esd.h +do +ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` +echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 +echo "configure:2004: checking for $ac_hdr" >&5 +if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +#include <$ac_hdr> EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1924: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:2014: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* - altype=freebsd + eval "ac_cv_header_$ac_safe=yes" else echo "$ac_err" >&5 echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_header_$ac_safe=no" fi rm -f conftest* +fi +if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then + echo "$ac_t""yes" 1>&6 + ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'` + cat >> confdefs.h <&6 +has_esd=no +fi +done + + +if test "$with_mictype" = auto; then + echo $ac_n "checking for input device type""... $ac_c" 1>&6 +echo "configure:2044: checking for input device type" >&5 + altype=no + case "$host_os" in + linux*) + # Linux - availability already checked, set default + if test "$has_alsa" = yes; then + altype=alsa + elif test "$has_oss" = yes; then + altype=oss + elif test "$has_esd" = yes; then + altype=esd + else + { echo "configure: error: no audio io avaiable!" 1>&2; exit 1; } + fi + ;; + freebsd*) + # FreeBSD (snd driver) + if test "$has_oss" = yes; then + altype=freebsd + else + { echo "configure: error: no soundcard.h found" 1>&2; exit 1; } fi ;; darwin*) # MacOSX (CoreAudio) cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1945: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:2075: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -1956,12 +2086,12 @@ solaris2*) # Solaris2.x Built-in Audio cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1965: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:2095: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -1976,12 +2106,12 @@ sunos4*) # SunOS4 Audio cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1985: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:2115: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -1996,12 +2126,12 @@ irix6*) # O2 (SGI IRIX6.3) cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:2005: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:2135: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -2039,7 +2169,7 @@ ;; cygwin*|mingw*) echo $ac_n "checking for main in -ldsound""... $ac_c" 1>&6 -echo "configure:2043: checking for main in -ldsound" >&5 +echo "configure:2173: checking for main in -ldsound" >&5 ac_lib_var=`echo dsound'_'main | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -2047,14 +2177,14 @@ ac_save_LIBS="$LIBS" LIBS="-ldsound $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2188: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -2073,17 +2203,17 @@ do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:2077: checking for $ac_hdr" >&5 +echo "configure:2207: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:2087: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:2217: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -2136,7 +2266,7 @@ case "$host_os" in linux*) echo $ac_n "checking for spInitAudio in -lspa.linux""... $ac_c" 1>&6 -echo "configure:2140: checking for spInitAudio in -lspa.linux" >&5 +echo "configure:2270: checking for spInitAudio in -lspa.linux" >&5 ac_lib_var=`echo spa.linux'_'spInitAudio | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -2144,7 +2274,7 @@ ac_save_LIBS="$LIBS" LIBS="-lspa.linux -lspb.linux -lm $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2289: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -2174,7 +2304,7 @@ else echo "$ac_t""no" 1>&6 echo $ac_n "checking for spInitAudio in -lspa.linux-glibc""... $ac_c" 1>&6 -echo "configure:2178: checking for spInitAudio in -lspa.linux-glibc" >&5 +echo "configure:2308: checking for spInitAudio in -lspa.linux-glibc" >&5 ac_lib_var=`echo spa.linux-glibc'_'spInitAudio | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -2182,7 +2312,7 @@ ac_save_LIBS="$LIBS" LIBS="-lspa.linux-glibc -lspb.linux-glibc -lm $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2327: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -2266,203 +2396,70 @@ ADINOBJ="$ADINOBJ src/adin/adin_portaudio.o" ;; oss) - aldesc="Open Sound System compatible" - ADINOBJ=src/adin/adin_mic_linux_oss.o - cat >> confdefs.h <<\EOF + if test "$has_oss" = no; then + { echo "configure: error: no OSS header!" 1>&2; exit 1; } + fi + aldesc="Open Sound System compatible" + cat >> confdefs.h <<\EOF #define USE_MIC 1 EOF - SOUNDLIB="" - ;; + SOUNDLIB="" + if test "$has_alsa" = yes; then + SOUNDLIB="$SOUNDLIB -lasound" + fi + if test "$has_esd" = yes; then + SOUNDLIB="$SOUNDLIB -lesd" + fi + ADINOBJ="src/adin/adin_mic_linux.o src/adin/adin_mic_linux_alsa.o src/adin/adin_mic_linux_oss.o src/adin/adin_esd.o" + ;; alsa) - aldesc="Advanced Linux Sound Architecture" - ADINOBJ=src/adin/adin_mic_linux_alsa.o - cat >> confdefs.h <<\EOF + if test "$has_alsa" = no; then + { echo "configure: error: no ALSA header!" 1>&2; exit 1; } + fi + aldesc="Advanced Linux Sound Architecture" + cat >> confdefs.h <<\EOF #define USE_MIC 1 EOF - SOUNDLIB="-lasound" - for ac_hdr in alsa/asoundlib.h -do -ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` -echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:2290: checking for $ac_hdr" >&5 -if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.$ac_ext < -EOF -ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:2300: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } -ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` -if test -z "$ac_err"; then - rm -rf conftest* - eval "ac_cv_header_$ac_safe=yes" -else - echo "$ac_err" >&5 - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_header_$ac_safe=no" -fi -rm -f conftest* -fi -if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then - echo "$ac_t""yes" 1>&6 - ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'` - cat >> confdefs.h <&6 -for ac_hdr in sys/asoundlib.h -do -ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` -echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:2327: checking for $ac_hdr" >&5 -if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.$ac_ext < -EOF -ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:2337: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } -ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` -if test -z "$ac_err"; then - rm -rf conftest* - eval "ac_cv_header_$ac_safe=yes" -else - echo "$ac_err" >&5 - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_header_$ac_safe=no" -fi -rm -f conftest* -fi -if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then - echo "$ac_t""yes" 1>&6 - ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'` - cat >> confdefs.h <&6 -{ echo "configure: error: neither alsa/asoundlib.h nor sys/asoundlib.h exist" 1>&2; exit 1; } - -fi -done - -fi -done - - ;; + SOUNDLIB="" + if test "$has_alsa" = yes; then + SOUNDLIB="$SOUNDLIB -lasound" + fi + if test "$has_esd" = yes; then + SOUNDLIB="$SOUNDLIB -lesd" + fi + ADINOBJ="src/adin/adin_mic_linux.o src/adin/adin_mic_linux_alsa.o src/adin/adin_mic_linux_oss.o src/adin/adin_esd.o" + ;; esd) - aldesc="EsoundD - The Enlightened Sound Daemon" - ADINOBJ=src/adin/adin_esd.o - cat >> confdefs.h <<\EOF + if test "$has_esd" = no; then + { echo "configure: error: no ESounD header!" 1>&2; exit 1; } + fi + aldesc="EsoundD - The Enlightened Sound Daemon" + cat >> confdefs.h <<\EOF #define USE_MIC 1 EOF - SOUNDLIB="-lesd" - ;; + SOUNDLIB="" + if test "$has_alsa" = yes; then + SOUNDLIB="$SOUNDLIB -lasound" + fi + if test "$has_esd" = yes; then + SOUNDLIB="$SOUNDLIB -lesd" + fi + ADINOBJ="src/adin/adin_mic_linux.o src/adin/adin_mic_linux_alsa.o src/adin/adin_mic_linux_oss.o src/adin/adin_esd.o" + ;; + freebsd) + if test "$has_oss" = no; then + { echo "configure: error: neither sys/soundcard.h nor machine/soundcard.h exist" 1>&2; exit 1; } + fi aldesc="FreeBSD snd driver" ADINOBJ=src/adin/adin_mic_freebsd.o cat >> confdefs.h <<\EOF #define USE_MIC 1 EOF - for ac_hdr in sys/soundcard.h -do -ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` -echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:2389: checking for $ac_hdr" >&5 -if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.$ac_ext < -EOF -ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:2399: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } -ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` -if test -z "$ac_err"; then - rm -rf conftest* - eval "ac_cv_header_$ac_safe=yes" -else - echo "$ac_err" >&5 - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_header_$ac_safe=no" -fi -rm -f conftest* -fi -if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then - echo "$ac_t""yes" 1>&6 - ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'` - cat >> confdefs.h <&6 -for ac_hdr in machine/soundcard.h -do -ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` -echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:2426: checking for $ac_hdr" >&5 -if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.$ac_ext < -EOF -ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:2436: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } -ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` -if test -z "$ac_err"; then - rm -rf conftest* - eval "ac_cv_header_$ac_safe=yes" -else - echo "$ac_err" >&5 - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_header_$ac_safe=no" -fi -rm -f conftest* -fi -if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then - echo "$ac_t""yes" 1>&6 - ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'` - cat >> confdefs.h <&6 -{ echo "configure: error: neither sys/soundcard.h nor machine/soundcard.h exist" 1>&2; exit 1; } - -fi -done - -fi -done - SOUNDLIB="" ;; coreaudio) @@ -2514,21 +2511,21 @@ if test "$with_netaudio_dir" = auto ; then echo $ac_n "checking for DatLink/NetAudio support""... $ac_c" 1>&6 -echo "configure:2518: checking for DatLink/NetAudio support" >&5 +echo "configure:2515: checking for DatLink/NetAudio support" >&5 else echo $ac_n "checking for DatLink/NetAudio support on ${with_netaudio_dir}""... $ac_c" 1>&6 -echo "configure:2521: checking for DatLink/NetAudio support on ${with_netaudio_dir}" >&5 +echo "configure:2518: checking for DatLink/NetAudio support on ${with_netaudio_dir}" >&5 fi TMPCPPFLAGS="$CPPFLAGS" CPPFLAGS="$CPPFLAGS -I${with_netaudio_dir}/include" use_netaudio=no cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:2532: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:2529: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -2553,7 +2550,7 @@ have_zlib=no; if test "$use_zlib" = yes; then echo $ac_n "checking for deflate in -lz""... $ac_c" 1>&6 -echo "configure:2557: checking for deflate in -lz" >&5 +echo "configure:2554: checking for deflate in -lz" >&5 ac_lib_var=`echo z'_'deflate | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -2561,7 +2558,7 @@ ac_save_LIBS="$LIBS" LIBS="-lz $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2573: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -2591,17 +2588,17 @@ do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:2595: checking for $ac_hdr" >&5 +echo "configure:2592: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:2605: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:2602: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -2646,7 +2643,7 @@ # Extract the first word of "gzip", so it can be a program name with args. set dummy gzip; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:2650: checking for $ac_word" >&5 +echo "configure:2647: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_GZIP'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -2689,7 +2686,7 @@ wavefile_support="RAW and WAV only" have_libsndfile=no echo $ac_n "checking for sf_open in -lsndfile""... $ac_c" 1>&6 -echo "configure:2693: checking for sf_open in -lsndfile" >&5 +echo "configure:2690: checking for sf_open in -lsndfile" >&5 ac_lib_var=`echo sndfile'_'sf_open | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -2697,7 +2694,7 @@ ac_save_LIBS="$LIBS" LIBS="-lsndfile $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2709: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -2727,17 +2724,17 @@ do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:2731: checking for $ac_hdr" >&5 +echo "configure:2728: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:2741: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:2738: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -2779,7 +2776,7 @@ if test "$have_libsndfile" = no; then echo $ac_n "checking for sf_open_read in -lsndfile""... $ac_c" 1>&6 -echo "configure:2783: checking for sf_open_read in -lsndfile" >&5 +echo "configure:2780: checking for sf_open_read in -lsndfile" >&5 ac_lib_var=`echo sndfile'_'sf_open_read | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -2787,7 +2784,7 @@ ac_save_LIBS="$LIBS" LIBS="-lsndfile $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2799: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -2817,17 +2814,17 @@ do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:2821: checking for $ac_hdr" >&5 +echo "configure:2818: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:2831: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:2828: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* Index: julius4/libsent/configure.in diff -u julius4/libsent/configure.in:1.6 julius4/libsent/configure.in:1.7 --- julius4/libsent/configure.in:1.6 Tue May 27 18:16:39 2008 +++ julius4/libsent/configure.in Tue Jul 1 13:29:45 2008 @@ -3,7 +3,7 @@ dnl Copyright (c) 2005-2007 Julius project team, Nagoya Institute of Technology dnl All rights reserved dnl -dnl $Id: configure.in,v 1.6 2008/05/27 09:16:39 sumomo Exp $ +dnl $Id: configure.in,v 1.7 2008/07/01 04:29:45 sumomo Exp $ dnl dnl Process this file with autoconf to produce a configure script. @@ -138,31 +138,46 @@ ;; esac +dnl Check for avaiable common adin files +# ALSA +has_alsa=yes +AC_CHECK_HEADERS(alsa/asoundlib.h,, + AC_CHECK_HEADERS(sys/asoundlib.h,, + has_alsa=no +)) +# OSS +has_oss=yes +AC_CHECK_HEADERS(sys/soundcard.h,, + AC_CHECK_HEADERS(machine/soundcard.h,, + has_oss=no +)) +# ESounD +has_esd=yes +AC_CHECK_HEADERS(esd.h,,has_esd=no) + dnl Checks for default audio input API (order is important) if test "$with_mictype" = auto; then AC_MSG_CHECKING(for input device type) altype=no case "$host_os" in linux*) - # ALSA - AC_TRY_CPP([#include ],altype=alsa) - if test "$altype" = no; then - AC_TRY_CPP([#include ],altype=alsa) - if test "$altype" = no; then - # OSS - AC_TRY_CPP([#include ],altype=oss) - if test "$altype" = no; then - AC_MSG_ERROR([no audio header file!]) - fi - AC_MSG_WARN([no ALSA header, use OSS instead]) - fi + # Linux - availability already checked, set default + if test "$has_alsa" = yes; then + altype=alsa + elif test "$has_oss" = yes; then + altype=oss + elif test "$has_esd" = yes; then + altype=esd + else + AC_MSG_ERROR([no audio io avaiable!]) fi ;; freebsd*) # FreeBSD (snd driver) - AC_TRY_CPP([#include ],altype=freebsd) - if test "$altype" = no; then - AC_TRY_CPP([#include ],altype=freebsd) + if test "$has_oss" = yes; then + altype=freebsd + else + AC_MSG_ERROR([no soundcard.h found]) fi ;; darwin*) @@ -279,35 +294,58 @@ ADINOBJ="$ADINOBJ src/adin/adin_portaudio.o" ;; oss) - aldesc="Open Sound System compatible" - ADINOBJ=src/adin/adin_mic_linux_oss.o - AC_DEFINE(USE_MIC) - SOUNDLIB="" - ;; + if test "$has_oss" = no; then + AC_MSG_ERROR([no OSS header!]) + fi + aldesc="Open Sound System compatible" + AC_DEFINE(USE_MIC) + SOUNDLIB="" + if test "$has_alsa" = yes; then + SOUNDLIB="$SOUNDLIB -lasound" + fi + if test "$has_esd" = yes; then + SOUNDLIB="$SOUNDLIB -lesd" + fi + ADINOBJ="src/adin/adin_mic_linux.o src/adin/adin_mic_linux_alsa.o src/adin/adin_mic_linux_oss.o src/adin/adin_esd.o" + ;; alsa) - aldesc="Advanced Linux Sound Architecture" - ADINOBJ=src/adin/adin_mic_linux_alsa.o - AC_DEFINE(USE_MIC) - SOUNDLIB="-lasound" - AC_CHECK_HEADERS(alsa/asoundlib.h,, - AC_CHECK_HEADERS(sys/asoundlib.h,, - AC_MSG_ERROR([neither alsa/asoundlib.h nor sys/asoundlib.h exist]) - )) - ;; + if test "$has_alsa" = no; then + AC_MSG_ERROR([no ALSA header!]) + fi + aldesc="Advanced Linux Sound Architecture" + AC_DEFINE(USE_MIC) + SOUNDLIB="" + if test "$has_alsa" = yes; then + SOUNDLIB="$SOUNDLIB -lasound" + fi + if test "$has_esd" = yes; then + SOUNDLIB="$SOUNDLIB -lesd" + fi + ADINOBJ="src/adin/adin_mic_linux.o src/adin/adin_mic_linux_alsa.o src/adin/adin_mic_linux_oss.o src/adin/adin_esd.o" + ;; esd) - aldesc="EsoundD - The Enlightened Sound Daemon" - ADINOBJ=src/adin/adin_esd.o - AC_DEFINE(USE_MIC) - SOUNDLIB="-lesd" - ;; + if test "$has_esd" = no; then + AC_MSG_ERROR([no ESounD header!]) + fi + aldesc="EsoundD - The Enlightened Sound Daemon" + AC_DEFINE(USE_MIC) + SOUNDLIB="" + if test "$has_alsa" = yes; then + SOUNDLIB="$SOUNDLIB -lasound" + fi + if test "$has_esd" = yes; then + SOUNDLIB="$SOUNDLIB -lesd" + fi + ADINOBJ="src/adin/adin_mic_linux.o src/adin/adin_mic_linux_alsa.o src/adin/adin_mic_linux_oss.o src/adin/adin_esd.o" + ;; + freebsd) + if test "$has_oss" = no; then + AC_MSG_ERROR([neither sys/soundcard.h nor machine/soundcard.h exist]) + fi aldesc="FreeBSD snd driver" ADINOBJ=src/adin/adin_mic_freebsd.o AC_DEFINE(USE_MIC) - AC_CHECK_HEADERS(sys/soundcard.h,, - AC_CHECK_HEADERS(machine/soundcard.h,, - AC_MSG_ERROR([neither sys/soundcard.h nor machine/soundcard.h exist]) - )) SOUNDLIB="" ;; coreaudio) Index: julius4/libsent/libsent-config.in diff -u julius4/libsent/libsent-config.in:1.2 julius4/libsent/libsent-config.in:1.3 --- julius4/libsent/libsent-config.in:1.2 Tue Dec 18 17:45:50 2007 +++ julius4/libsent/libsent-config.in Tue Jul 1 13:29:45 2008 @@ -12,7 +12,7 @@ # # ripped from gtk's gtk-config.in # -# $Id: libsent-config.in,v 1.2 2007/12/18 08:45:50 sumomo Exp $ +# $Id: libsent-config.in,v 1.3 2008/07/01 04:29:45 sumomo Exp $ # # @@ -28,7 +28,7 @@ Julius/Julian libsent library rev. @ LIBSENT_VERSION@: - Audio I/O - mic device API : @altype@ (@aldesc@) + primary mic device API : @altype@ (@aldesc@) supported audio format : @wavefile_support@ NetAudio support : @use_netaudio@ - Language Modeling From sumomo @ users.sourceforge.jp Tue Jul 1 13:29:46 2008 From: sumomo @ users.sourceforge.jp (sumomo @ users.sourceforge.jp) Date: Tue, 01 Jul 2008 13:29:46 +0900 Subject: [Julius-cvs 193] CVS update: julius4/libsent/include/sent Message-ID: <1214886586.300913.28974.nullmailer@users.sourceforge.jp> Index: julius4/libsent/include/sent/adin.h diff -u julius4/libsent/include/sent/adin.h:1.2 julius4/libsent/include/sent/adin.h:1.3 --- julius4/libsent/include/sent/adin.h:1.2 Tue Dec 18 17:45:50 2007 +++ julius4/libsent/include/sent/adin.h Tue Jul 1 13:29:46 2008 @@ -19,7 +19,7 @@ * @author Akinobu LEE * @date Thu Feb 10 17:22:36 2005 * - * $Revision: 1.2 $ + * $Revision: 1.3 $ */ /* * Copyright (c) 1991-2007 Kawahara Lab., Kyoto University @@ -34,6 +34,18 @@ #include #include +#if defined(HAVE_ALSA_ASOUNDLIB_H) || defined(HAVE_SYS_ASOUNDLIB_H) +#define HAS_ALSA +#endif +#ifdef __linux__ +#if defined(HAVE_SYS_SOUNDCARD_H) || defined(HAVE_MACHINE_SOUNDCARD_H) +#define HAS_OSS +#endif +#endif /* __linux__ */ +#ifdef HAVE_ESD_H +#define HAS_ESD +#endif + /// To select speech input source enum { SP_RAWFILE, ///< Wavefile @@ -44,6 +56,14 @@ SP_STDIN ///< Standard input }; +/// Input device +enum { + SP_INPUT_DEFAULT, + SP_INPUT_ALSA, + SP_INPUT_OSS, + SP_INPUT_ESD, +}; + /// Default unit size of speech input segment in bytes #define DEFAULT_WSTEP 1000 @@ -122,6 +142,21 @@ boolean adin_mic_begin(); boolean adin_mic_end(); int adin_mic_read(SP16 *buf, int sampnum); +/* adin/adin_mic_linux_alsa.c */ +boolean adin_alsa_standby(int freq, void *arg); +boolean adin_alsa_begin(); +boolean adin_alsa_end(); +int adin_alsa_read(SP16 *buf, int sampnum); +/* adin/adin_mic_linux_oss.c */ +boolean adin_oss_standby(int freq, void *arg); +boolean adin_oss_begin(); +boolean adin_oss_end(); +int adin_oss_read(SP16 *buf, int sampnum); +/* adin/adin_esd.c */ +boolean adin_esd_standby(int freq, void *arg); +boolean adin_esd_begin(); +boolean adin_esd_end(); +int adin_esd_read(SP16 *buf, int sampnum); /* adin/adin_netaudio.c and adin/adin_na.c */ boolean adin_netaudio_standby(int freq, void *arg); boolean adin_netaudio_begin(); Index: julius4/libsent/include/sent/config.h.in diff -u julius4/libsent/include/sent/config.h.in:1.4 julius4/libsent/include/sent/config.h.in:1.5 --- julius4/libsent/include/sent/config.h.in:1.4 Sun Mar 2 02:10:19 2008 +++ julius4/libsent/include/sent/config.h.in Tue Jul 1 13:29:46 2008 @@ -33,7 +33,7 @@ * @author Akinobu LEE * @date Thu Feb 10 17:48:32 2005 * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * */ @@ -124,10 +124,10 @@ /* Define if use sin/cos table for MFCC calculation */ #undef MFCC_SINCOS_TABLE -/* Define if found in FreeBSD */ +/* Define if found */ #undef HAVE_SYS_SOUNDCARD_H -/* Define if found in FreeBSD */ +/* Define if found */ #undef HAVE_MACHINE_SOUNDCARD_H /* Define if found */ @@ -135,3 +135,6 @@ /* Define if exist and not exist */ #undef HAVE_SYS_ASOUNDLIB_H + +/* Define if exist */ +#undef HAVE_ESD_H From sumomo @ users.sourceforge.jp Tue Jul 1 13:29:46 2008 From: sumomo @ users.sourceforge.jp (sumomo @ users.sourceforge.jp) Date: Tue, 01 Jul 2008 13:29:46 +0900 Subject: [Julius-cvs 194] CVS update: julius4/libsent/src/adin Message-ID: <1214886586.496068.28985.nullmailer@users.sourceforge.jp> Index: julius4/libsent/src/adin/adin_esd.c diff -u julius4/libsent/src/adin/adin_esd.c:1.2 julius4/libsent/src/adin/adin_esd.c:1.3 --- julius4/libsent/src/adin/adin_esd.c:1.2 Tue Dec 18 17:45:50 2007 +++ julius4/libsent/src/adin/adin_esd.c Tue Jul 1 13:29:46 2008 @@ -21,7 +21,7 @@ * @author Akinobu LEE * @date Sun Feb 13 16:18:26 2005 * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * */ /* @@ -33,13 +33,15 @@ #include #include -/* sound header */ -#include +#ifdef HAS_ESD +#include static int sock; ///< Audio socket static char name_buf[ESD_NAME_MAX]; ///< Unique identifier of this process that will be passed to EsounD static int latency = 50; ///< Lantency time in msec +#endif + /** * Connection initialization: check connectivity and open for recording. * @@ -49,8 +51,12 @@ * @return TRUE on success, FALSE on failure. */ boolean -adin_mic_standby(int sfreq, void *dummy) +adin_esd_standby(int sfreq, void *dummy) { +#ifndef HAS_ESD + jlog("Error: esd not compiled in\n"); + return FALSE; +#else esd_format_t format = ESD_BITS16 | ESD_MONO | ESD_STREAM | ESD_RECORD; /* generate uniq ID */ @@ -65,6 +71,7 @@ } return TRUE; +#endif } /** @@ -73,7 +80,7 @@ * @return TRUE on success, FALSE on failure. */ boolean -adin_mic_begin() +adin_esd_begin() { return(TRUE); } @@ -84,7 +91,7 @@ * @return TRUE on success, FALSE on failure. */ boolean -adin_mic_end() +adin_esd_end() { return TRUE; } @@ -102,8 +109,11 @@ * @return actural number of read samples, -2 if an error occured. */ int -adin_mic_read(SP16 *buf, int sampnum) +adin_esd_read(SP16 *buf, int sampnum) { +#ifndef HAS_ESD + return -2; +#else int size, cnt; size = sampnum; @@ -112,11 +122,12 @@ while((cnt = read(sock, buf, size)) <= 0) { if (cnt < 0) { - perror("adin_mic_read: read error\n"); + perror("adin_esd_read: read error\n"); return ( -2 ); } usleep(latency * 1000); } cnt /= sizeof(SP16); return(cnt); +#endif } Index: julius4/libsent/src/adin/adin_mic_linux_alsa.c diff -u julius4/libsent/src/adin/adin_mic_linux_alsa.c:1.5 julius4/libsent/src/adin/adin_mic_linux_alsa.c:1.6 --- julius4/libsent/src/adin/adin_mic_linux_alsa.c:1.5 Thu May 8 14:44:26 2008 +++ julius4/libsent/src/adin/adin_mic_linux_alsa.c Tue Jul 1 13:29:46 2008 @@ -44,7 +44,7 @@ * @author Akinobu LEE * @date Sun Feb 13 16:18:26 2005 * - * $Revision: 1.5 $ + * $Revision: 1.6 $ * */ /* @@ -61,6 +61,8 @@ #include #include +#ifdef HAS_ALSA + #ifdef HAVE_ALSA_ASOUNDLIB_H #include #elif HAVE_SYS_ASOUNDLIB_H @@ -77,7 +79,9 @@ #define MAXPOLLINTERVAL 300 ///< Read timeout in msec. +#endif /* HAS_ALSA */ +#ifdef HAS_ALSA /** * Output detailed device information. * @@ -143,6 +147,7 @@ snd_ctl_close(ctl); } +#endif /* HAS_ALSA */ /** * Device initialization: check device capability and open for recording. @@ -153,8 +158,12 @@ * @return TRUE on success, FALSE on failure. */ boolean -adin_mic_standby(int sfreq, void *dummy) +adin_alsa_standby(int sfreq, void *dummy) { +#ifndef HAS_ALSA + jlog("Error: ALSA not compiled in\n"); + return FALSE; +#else int err; snd_pcm_hw_params_t *hwparams; ///< Pointer to device hardware parameters #if (SND_LIB_MAJOR == 0) @@ -358,8 +367,10 @@ output_card_info(pcm_name, handle); return(TRUE); +#endif /* HAS_ALSA */ } +#ifdef HAS_ALSA /** * Error recovery when PCM buffer underrun or suspend. * @@ -388,6 +399,7 @@ } return err; } +#endif /* HAS_ALSA */ /** * Start recording. @@ -395,8 +407,11 @@ * @return TRUE on success, FALSE on failure. */ boolean -adin_mic_begin() +adin_alsa_begin() { +#ifndef HAS_ALSA + return FALSE; +#else int err; snd_pcm_state_t status; @@ -433,6 +448,7 @@ } return(TRUE); +#endif /* HAS_ALSA */ } /** @@ -441,7 +457,7 @@ * @return TRUE on success, FALSE on failure. */ boolean -adin_mic_end() +adin_alsa_end() { return(TRUE); } @@ -459,8 +475,11 @@ * @return actural number of read samples, -2 if an error occured. */ int -adin_mic_read(SP16 *buf, int sampnum) +adin_alsa_read(SP16 *buf, int sampnum) { +#ifndef HAS_ALSA + return -2; +#else int cnt; #if (SND_LIB_MAJOR == 0) @@ -502,5 +521,7 @@ } return(cnt); +#endif /* HAS_ALSA */ } + /* end of file */ Index: julius4/libsent/src/adin/adin_mic_linux_oss.c diff -u julius4/libsent/src/adin/adin_mic_linux_oss.c:1.3 julius4/libsent/src/adin/adin_mic_linux_oss.c:1.4 --- julius4/libsent/src/adin/adin_mic_linux_oss.c:1.3 Tue Dec 18 17:45:50 2007 +++ julius4/libsent/src/adin/adin_mic_linux_oss.c Tue Jul 1 13:29:46 2008 @@ -51,7 +51,7 @@ * @author Akinobu LEE * @date Sun Feb 13 16:18:26 2005 * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * */ /* @@ -62,8 +62,8 @@ */ #include -#include +#include #include #include #include @@ -71,7 +71,13 @@ #include /* sound header */ +#ifdef HAS_OSS +#ifdef HAVE_SYS_SOUNDCARD_H #include +#elif HAVE_MACHINE_SOUNDCARD_H +#include +#endif +#endif /// Default device name, can be overridden by AUDIODEV environment variable #define DEFAULT_DEVICE "/dev/dsp" @@ -106,8 +112,12 @@ * @return TRUE on success, FALSE on failure. */ boolean -adin_mic_standby(int sfreq, void *dummy) +adin_oss_standby(int sfreq, void *dummy) { +#ifndef HAS_OSS + jlog("Error: OSS not compiled in\n"); + return FALSE; +#else int fmt, fmt_can, fmt1, fmt2, rfmt; /* sampling format */ int samplerate; /* 16kHz */ char *defaultdev = DEFAULT_DEVICE; /* default device */ @@ -325,6 +335,8 @@ jlog("Stat: adin_oss: audio I/O Latency = %d msec (fragment size = %d samples)\n", frag_size * 1000/ (sfreq * sizeof(SP16)), frag_size / sizeof(SP16)); return TRUE; + +#endif /* HAS_OSS */ } /** @@ -333,7 +345,7 @@ * @return TRUE on success, FALSE on failure. */ boolean -adin_mic_begin() +adin_oss_begin() { char buf[4]; /* Read 1 sample (and ignore it) to tell the audio device start recording. @@ -352,7 +364,7 @@ * @return TRUE on success, FALSE on failure. */ boolean -adin_mic_end() +adin_oss_end() { /* * Not reset device on each end of speech, just let the buffer overrun... @@ -381,8 +393,11 @@ * MAXPOLLINTERVAL msec, -2 if error. */ int -adin_mic_read(SP16 *buf, int sampnum) +adin_oss_read(SP16 *buf, int sampnum) { +#ifndef HAS_OSS + return -2; +#else int size,cnt,i; audio_buf_info info; fd_set rfds; @@ -434,4 +449,6 @@ } return(cnt); +#endif /* HAS_OSS */ } + From sumomo @ users.sourceforge.jp Tue Jul 1 13:29:46 2008 From: sumomo @ users.sourceforge.jp (sumomo @ users.sourceforge.jp) Date: Tue, 01 Jul 2008 13:29:46 +0900 Subject: [Julius-cvs 195] CVS update: julius4/libsent/src/util Message-ID: <1214886586.637275.28992.nullmailer@users.sourceforge.jp> Index: julius4/libsent/src/util/confout.c diff -u julius4/libsent/src/util/confout.c:1.3 julius4/libsent/src/util/confout.c:1.4 --- julius4/libsent/src/util/confout.c:1.3 Tue Mar 18 01:59:45 2008 +++ julius4/libsent/src/util/confout.c Tue Jul 1 13:29:46 2008 @@ -12,7 +12,7 @@ * @author Akinobu LEE * @date Thu Feb 17 15:34:39 2005 * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * */ /* @@ -26,6 +26,7 @@ #include #include #include +#include /** * Output version of this libsent library. @@ -48,16 +49,25 @@ { fprintf(strm, " - Audio input\n"); #ifdef USE_MIC - fprintf(strm, " microphone device API : %s (%s)\n", AUDIO_API_NAME, AUDIO_API_DESC); + fprintf(strm, " primary A/D-in driver : %s (%s)\n", AUDIO_API_NAME, AUDIO_API_DESC); #else - fprintf(strm, " microphone device API : N/A\n"); + fprintf(strm, " primary A/D-in driver : N/A\n"); +#endif + fprintf(strm, " available drivers :"); +#ifdef HAS_ALSA + fprintf(strm, " alsa"); +#endif +#ifdef HAS_OSS + fprintf(strm, " oss"); +#endif +#ifdef HAS_ESD + fprintf(strm, " esd"); #endif - fprintf(strm, " wavefile formats : %s\n", AUDIO_FORMAT_DESC); #ifdef USE_NETAUDIO - fprintf(strm, " DATLink/NetAudio support: yes\n"); -#else - fprintf(strm, " DATLink/NetAudio support: no\n"); + fprintf(strm, " DATLink/NetAudio"); #endif + fprintf(strm, "\n"); + fprintf(strm, " wavefile formats : %s\n", AUDIO_FORMAT_DESC); fprintf(strm, " max. length of an input : %d samples, %d words\n", MAXSPEECHLEN, MAXSEQNUM); } From sumomo @ users.sourceforge.jp Tue Jul 1 22:44:09 2008 From: sumomo @ users.sourceforge.jp (sumomo @ users.sourceforge.jp) Date: Tue, 01 Jul 2008 22:44:09 +0900 Subject: [Julius-cvs 196] CVS update: julius4/libsent/src/adin Message-ID: <1214919849.369519.28511.nullmailer@users.sourceforge.jp> Index: julius4/libsent/src/adin/adin_mic_linux.c diff -u /dev/null julius4/libsent/src/adin/adin_mic_linux.c:1.1 --- /dev/null Tue Jul 1 22:44:09 2008 +++ julius4/libsent/src/adin/adin_mic_linux.c Tue Jul 1 22:44:09 2008 @@ -0,0 +1,124 @@ +/** + * @file adin_mic_linux.c + * + * + * @brief マイク入力 (Linux) - デフォルトデバイス + * + * マイク入力のための低レベル関数です. + * インタフェースを指定しない場合に呼ばれます. + * 実際には,ALSA, OSS, ESD の順で最初に見つかったものが使用されます. + * + * + * @brief Microphone input on Linux - default device + * + * Low level I/O functions for microphone input on Linux. + * This will be called when no device was explicitly specified. + * A call to the functions in this file will be redirected to + * ALSA, OSS or ESD. + * + * + * @author Akinobu LEE + * @date Sun Feb 13 16:18:26 2005 + * + * $Revision: 1.1 $ + * + */ +/* + * Copyright (c) 1991-2008 Kawahara Lab., Kyoto University + * Copyright (c) 2000-2005 Shikano Lab., Nara Institute of Science and Technology + * Copyright (c) 2005-2008 Julius project team, Nagoya Institute of Technology + * All rights reserved + */ + +#include +#include + +/** + * Device initialization: check device capability and open for recording. + * + * @param sfreq [in] required sampling frequency. + * @param dummy [in] a dummy data + * + * @return TRUE on success, FALSE on failure. + */ +boolean +adin_mic_standby(int sfreq, void *dummy) +{ +#ifdef HAS_ALSA + return(adin_alsa_standby(sfreq, dummy)); +#elif HAS_OSS + return(adin_oss_standby(sfreq, dummy)); +#elif HAS_ESD + return(adin_esd_standby(sfreq, dummy)); +#else /* other than Linux */ + jlog("Error: neither of alsa/oss/esd device is available\n"); + return FALSE; +#endif +} + +/** + * Start recording. + * + * @return TRUE on success, FALSE on failure. + */ +boolean +adin_mic_begin() +{ +#ifdef HAS_ALSA + return(adin_alsa_begin()); +#elif HAS_OSS + return(adin_oss_begin()); +#elif HAS_ESD + return(adin_esd_begin()); +#else /* other than Linux */ + jlog("Error: neither of alsa/oss/esd device is available\n"); + return FALSE; +#endif +} + +/** + * Stop recording. + * + * @return TRUE on success, FALSE on failure. + */ +boolean +adin_mic_end() +{ +#ifdef HAS_ALSA + return(adin_alsa_end()); +#elif HAS_OSS + return(adin_oss_end()); +#elif HAS_ESD + return(adin_esd_end()); +#else /* other than Linux */ + jlog("Error: neither of alsa/oss/esd device is available\n"); + return FALSE; +#endif +} + +/** + * @brief Read samples from device + * + * Try to read @a sampnum samples and returns actual number of recorded + * samples currently available. This function will block until + * at least one sample can be obtained. + * + * @param buf [out] samples obtained in this function + * @param sampnum [in] wanted number of samples to be read + * + * @return actural number of read samples, -2 if an error occured. + */ +int +adin_mic_read(SP16 *buf, int sampnum) +{ +#ifdef HAS_ALSA + return(adin_alsa_read(buf, sampnum)); +#elif HAS_OSS + return(adin_oss_read(buf, sampnum)); +#elif HAS_ESD + return(adin_esd_read(buf, sampnum)); +#else /* other than Linux */ + jlog("Error: neither of alsa/oss/esd device is available\n"); + return -2; +#endif +} From sumomo @ users.sourceforge.jp Mon Jul 7 14:50:10 2008 From: sumomo @ users.sourceforge.jp (sumomo @ users.sourceforge.jp) Date: Mon, 07 Jul 2008 14:50:10 +0900 Subject: [Julius-cvs 197] CVS update: julius4/libjulius/include/julius Message-ID: <1215409810.849139.1690.nullmailer@users.sourceforge.jp> Index: julius4/libjulius/include/julius/recog.h diff -u julius4/libjulius/include/julius/recog.h:1.2 julius4/libjulius/include/julius/recog.h:1.3 --- julius4/libjulius/include/julius/recog.h:1.2 Wed Feb 13 17:43:08 2008 +++ julius4/libjulius/include/julius/recog.h Mon Jul 7 14:50:10 2008 @@ -70,7 +70,7 @@ * @author Akinobu Lee * @date Fri Feb 16 13:42:28 2007 * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * */ /* @@ -259,6 +259,11 @@ LOGPROB *gmm_score; ///< Current accumurated scores for each GMM boolean *is_voice; ///< True if corresponding model designates speech, FALSE if noise int framecount; ///< Current frame count + + short OP_nstream; ///< Number of input stream for GMM + VECT *OP_vec_stream[MAXSTREAMNUM]; ///< input vector for each stream at that frame + short OP_veclen_stream[MAXSTREAMNUM]; ///< vector length for each stream + LOGPROB *OP_calced_score; ///< Work area for Gaussian pruning on GMM: scores int *OP_calced_id; ///< Work area for Gaussian pruning on GMM: id int OP_calced_num; ///< Work area for Gaussian pruning on GMM: number of above From sumomo @ users.sourceforge.jp Mon Jul 7 14:50:11 2008 From: sumomo @ users.sourceforge.jp (sumomo @ users.sourceforge.jp) Date: Mon, 07 Jul 2008 14:50:11 +0900 Subject: [Julius-cvs 198] CVS update: julius4/libjulius/src Message-ID: <1215409811.180324.1702.nullmailer@users.sourceforge.jp> Index: julius4/libjulius/src/gmm.c diff -u julius4/libjulius/src/gmm.c:1.3 julius4/libjulius/src/gmm.c:1.4 --- julius4/libjulius/src/gmm.c:1.3 Sun Dec 23 19:08:36 2007 +++ julius4/libjulius/src/gmm.c Mon Jul 7 14:50:10 2008 @@ -41,7 +41,7 @@ * @author Akinobu LEE * @date Tue Mar 15 05:14:10 2005 * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * */ @@ -258,11 +258,11 @@ { /* store the pruning num to local area */ gc->OP_gprune_num = prune_num; - /* maximum Gaussian set size = maximum mixture size */ - gc->OP_calced_maxnum = hmminfo->maxmixturenum; + /* maximum Gaussian set size = maximum mixture size * nstream */ + gc->OP_calced_maxnum = hmminfo->maxmixturenum * gc->OP_nstream; /* allocate memory for storing list of currently computed Gaussian in a frame */ - gc->OP_calced_score = (LOGPROB *)mymalloc(sizeof(LOGPROB) * gc->OP_gprune_num); - gc->OP_calced_id = (int *)mymalloc(sizeof(int) * gc->OP_gprune_num); + gc->OP_calced_score = (LOGPROB *)mymalloc(sizeof(LOGPROB) * gc->OP_calced_maxnum); + gc->OP_calced_id = (int *)mymalloc(sizeof(int) * gc->OP_calced_maxnum); } /** @@ -317,7 +317,7 @@ * あるGMM状態の現フレームに対する出力確率を計算する. * * @param gc [i/o] GMM計算用ワークエリア - * @param s [in] GMM 状態 + * @param state [in] GMM 状態 * * @return 出力確率の対数スコア * @@ -325,29 +325,48 @@ * Compute the output probability of a GMM state for the current frame. * * @param gc [i/o] work area for GMM calculation - * @param s [in] GMM state + * @param state [in] GMM state * * @return the log probability. * */ static LOGPROB -gmm_calc_mix(GMMCalc *gc, HTK_HMM_State *s) +gmm_calc_mix(GMMCalc *gc, HTK_HMM_State *state) { int i; - LOGPROB logprob = LOG_ZERO; + LOGPROB logprob, logprobsum; + int s; + PROB stream_weight; + /* compute Gaussian set */ - gmm_gprune_safe(gc, s->b, s->mix_num); - /* computed Gaussians will be set in: - score ... OP_calced_score[0..OP_calced_num] - id ... OP_calced_id[0..OP_calced_num] */ - + logprobsum = 0.0; + for(s=0;sOP_nstream;s++) { + /* set stream weight */ + if (state->w) stream_weight = state->w->weight[s]; + else stream_weight = 1.0; + /* setup storage pointer for this mixture pdf */ + gc->OP_vec = gc->OP_vec_stream[s]; + gc->OP_veclen = gc->OP_veclen_stream[s]; + /* compute output probabilities */ + gmm_gprune_safe(gc, state->pdf[s]->b, state->pdf[s]->mix_num); + /* computed Gaussians will be set in: + score ... OP_calced_score[0..OP_calced_num] + id ... OP_calced_id[0..OP_calced_num] */ /* sum */ - for(i=0;iOP_calced_num;i++) { - gc->OP_calced_score[i] += s->bweight[gc->OP_calced_id[i]]; + for(i=0;iOP_calced_num;i++) { + gc->OP_calced_score[i] += state->pdf[s]->bweight[gc->OP_calced_id[i]]; + } + /* add log probs */ + logprob = addlog_array(gc->OP_calced_score, gc->OP_calced_num); + /* if outprob of a stream is zero, skip this stream */ + if (logprob <= LOG_ZERO) continue; + /* sum all the obtained mixture scores */ + logprobsum += logprob * stream_weight; + } - logprob = addlog_array(gc->OP_calced_score, gc->OP_calced_num); - if (logprob <= LOG_ZERO) return LOG_ZERO; + if (logprobsum == 0.0) return(LOG_ZERO); /* no valid stream */ + if (logprobsum <= LOG_ZERO) return(LOG_ZERO); /* lowest == LOG_ZERO */ return (logprob * INV_LOG_TEN); } @@ -377,9 +396,12 @@ static LOGPROB outprob_state_nocache(GMMCalc *gc, int t, HTK_HMM_State *stateinfo, HTK_Param *param) { + int d, i; /* set global values for outprob functions to access them */ - gc->OP_vec = param->parvec[t]; - gc->OP_veclen = param->veclen; + for(d=0,i=0;iOP_nstream;i++) { + gc->OP_vec_stream[i] = &(param->parvec[t][d]); + d += gc->OP_veclen_stream[i]; + } return(gmm_calc_mix(gc, stateinfo)); } @@ -433,6 +455,8 @@ if (recog->gc == NULL) { gc = (GMMCalc *)mymalloc(sizeof(GMMCalc)); recog->gc = gc; + } else { + gc = recog->gc; } /* allocate buffers */ @@ -462,6 +486,10 @@ } /* initialize work area */ + gc->OP_nstream = gmm->opt.stream_info.num; + for(i=0;iOP_nstream;i++) { + gc->OP_veclen_stream[i] = gmm->opt.stream_info.vsize[i]; + } gmm_gprune_safe_init(gc, gmm, recog->jconf->reject.gmm_gprune_num); /* check if variances are inversed */ @@ -648,6 +676,7 @@ i = 0; maxprob = LOG_ZERO; dmax = NULL; + maxid = 0; for(d=gmm->start;d;d=d->next) { if (maxprob < score[i]) { dmax = d; Index: julius4/libjulius/src/m_chkparam.c diff -u julius4/libjulius/src/m_chkparam.c:1.3 julius4/libjulius/src/m_chkparam.c:1.4 --- julius4/libjulius/src/m_chkparam.c:1.3 Tue Jun 17 10:20:50 2008 +++ julius4/libjulius/src/m_chkparam.c Mon Jul 7 14:50:10 2008 @@ -20,7 +20,7 @@ * @author Akinobu LEE * @date Fri Mar 18 16:31:45 2005 * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * */ /* @@ -171,6 +171,10 @@ lm->lmvar = LM_DFA_WORD; } } + if (lm->lmtype == LM_UNDEF) { /* an LM is not specified */ + jlog("ERROR: m_chkparam: you should specify at least one LM to run Julius!\n"); + return FALSE; + } if (lm->lmtype == LM_PROB) { if (lm->dictfilename == NULL) { jlog("ERROR: m_chkparam: needs dictionary file (-v dict_file)\n"); Index: julius4/libjulius/src/m_fusion.c diff -u julius4/libjulius/src/m_fusion.c:1.5 julius4/libjulius/src/m_fusion.c:1.6 --- julius4/libjulius/src/m_fusion.c:1.5 Sat May 17 13:06:30 2008 +++ julius4/libjulius/src/m_fusion.c Mon Jul 7 14:50:10 2008 @@ -20,7 +20,7 @@ * @author Akinobu Lee * @date Thu May 12 13:31:47 2005 * - * $Revision: 1.5 $ + * $Revision: 1.6 $ * */ /* @@ -917,7 +917,7 @@ PROCESS_AM *am; PROCESS_LM *lm; - jlog("STAT: *** composing recognizer instance SR%02d %s (AM%02d %s, LM%02d %s)\n", sconf->id, sconf->name, sconf->amconf->id, sconf->amconf->name, sconf->lmconf->id, sconf->lmconf->name); + jlog("STAT: composing recognizer instance SR%02d %s (AM%02d %s, LM%02d %s)\n", sconf->id, sconf->name, sconf->amconf->id, sconf->amconf->name, sconf->lmconf->id, sconf->lmconf->name); /* allocate recognition instance */ p = j_recogprocess_new(recog, sconf); @@ -1111,7 +1111,7 @@ max_successor_cache_init(p->wchmm); } - jlog("STAT: *** SR%02d %s composed\n", sconf->id, sconf->name); + jlog("STAT: SR%02d %s composed\n", sconf->id, sconf->name); if (sconf->sw.start_inactive) { /* start inactive */ @@ -1187,8 +1187,9 @@ PROCESS_AM *am; PROCESS_LM *lm; - jlog("STAT: now all modules into fire for fusion...\n"); - + jlog("STAT: ------\n"); + jlog("STAT: All models are ready, go for final fusion\n"); + jlog("STAT: [1] create MFCC instance(s)\n"); if (recog->jconf->input.speech_input != SP_MFCFILE) { /***************************************************/ /* create MFCC calculation instance from AM config */ @@ -1200,6 +1201,7 @@ /****************************************/ /* create recognition process instances */ /****************************************/ + jlog("STAT: [2] ignite Recognizer instances]\n"); for(sconf=recog->jconf->search_root;sconf;sconf=sconf->next) { if (j_launch_recognition_instance(recog, sconf) == FALSE) return FALSE; } @@ -1208,6 +1210,7 @@ /****** initialize GMM ******/ /****************************/ if (recog->gmm != NULL) { + jlog("STAT: [2.5] ignite GMM instance]\n"); if (gmm_init(recog) == FALSE) { jlog("ERROR: m_fusion: error in initializing GMM\n"); return FALSE; @@ -1215,16 +1218,22 @@ } /* stage 4: setup output probability function for each AM */ + jlog("STAT: [3] set up acoustic prob calculator]\n"); for(am=recog->amlist;am;am=am->next) { if (am->config->hmm_gs_filename != NULL) {/* with GMS */ - outprob_init(&(am->hmmwrk), am->hmminfo, am->hmm_gs, am->config->gs_statenum, am->config->gprune_method, am->config->mixnum_thres); + if (outprob_init(&(am->hmmwrk), am->hmminfo, am->hmm_gs, am->config->gs_statenum, am->config->gprune_method, am->config->mixnum_thres) == FALSE) { + return FALSE; + } } else { - outprob_init(&(am->hmmwrk), am->hmminfo, NULL, 0, am->config->gprune_method, am->config->mixnum_thres); + if (outprob_init(&(am->hmmwrk), am->hmminfo, NULL, 0, am->config->gprune_method, am->config->mixnum_thres) == FALSE) { + return FALSE; + } } } /* stage 5: initialize work area for input and realtime decoding */ + jlog("STAT: [4] set up input MFCC handler]\n"); if (recog->jconf->input.speech_input == SP_MFCFILE) { /* create an MFCC instance for MFCC input */ /* create new mfcc instance */ @@ -1259,6 +1268,7 @@ } if (recog->jconf->decodeopt.realtime_flag) { + jlog("STAT: [5] initialize real-time decoding]\n"); /* prepare for 1st pass pipeline processing */ if (RealTimeInit(recog) == FALSE) { jlog("ERROR: m_fusion: failed to initialize recognition process\n"); From sumomo @ users.sourceforge.jp Mon Jul 7 14:50:11 2008 From: sumomo @ users.sourceforge.jp (sumomo @ users.sourceforge.jp) Date: Mon, 07 Jul 2008 14:50:11 +0900 Subject: [Julius-cvs 199] CVS update: julius4/libsent/include/sent Message-ID: <1215409811.640556.1732.nullmailer@users.sourceforge.jp> Index: julius4/libsent/include/sent/config.h.in diff -u julius4/libsent/include/sent/config.h.in:1.5 julius4/libsent/include/sent/config.h.in:1.6 --- julius4/libsent/include/sent/config.h.in:1.5 Tue Jul 1 13:29:46 2008 +++ julius4/libsent/include/sent/config.h.in Mon Jul 7 14:50:11 2008 @@ -33,7 +33,7 @@ * @author Akinobu LEE * @date Thu Feb 10 17:48:32 2005 * - * $Revision: 1.5 $ + * $Revision: 1.6 $ * */ @@ -138,3 +138,6 @@ /* Define if exist */ #undef HAVE_ESD_H + +/* Define if MSD-HMM support is enabled */ +#undef ENABLE_MSD Index: julius4/libsent/include/sent/hmm_calc.h diff -u julius4/libsent/include/sent/hmm_calc.h:1.3 julius4/libsent/include/sent/hmm_calc.h:1.4 --- julius4/libsent/include/sent/hmm_calc.h:1.3 Tue Dec 18 17:45:50 2007 +++ julius4/libsent/include/sent/hmm_calc.h Mon Jul 7 14:50:11 2008 @@ -13,7 +13,7 @@ * @author Akinobu LEE * @date Thu Feb 10 14:54:06 2005 * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * */ /* @@ -54,7 +54,7 @@ /// A component of per-codebook probability cache while search typedef struct { LOGPROB score; ///< Cached probability of below - unsigned short id; ///< ID of the cached Gaussian in the codebook + int id; ///< ID of the cached Gaussian in the codebook } MIXCACHE; /** @@ -89,14 +89,19 @@ int OP_gprune_num; ///< Current number of computed mixtures for pruning int OP_time; ///< Current time int OP_last_time; ///< last time - VECT *OP_vec; ///< Current input vector - short OP_veclen; ///< Current vector length /* current computing state */ HTK_HMM_State *OP_state; ///< Current state int OP_state_id; ///< Current state ID - /* buffers to hold result of mixture computation */ + /* for multi-stream input */ + short OP_nstream; ///< Number of input stream (copy from header) + VECT *OP_vec_stream[MAXSTREAMNUM]; ///< input vector for each stream at current frame + short OP_veclen_stream[MAXSTREAMNUM]; ///< vector length for each stream + + /* temporal buffers to hold result of mixture computation at each stream */ + VECT *OP_vec; ///< Current input vector to be computed + short OP_veclen; ///< Current vector length to be computed int OP_calced_maxnum; ///< Allocated length of below LOGPROB *OP_calced_score; ///< Scores of computed mixtures int *OP_calced_id; ///< IDs of computed mixtures @@ -111,6 +116,7 @@ /* mixture level cache for tied-mixture model */ MIXCACHE ***mixture_cache; ///< Codebook cache: [time][book_id][0..computed_mixture_num] + short **mixture_cache_num; ///< Num of mixtures to be calculated and stored in mixture_cache BMALLOC_BASE *mroot; ///< Root alloc pointer to state outprob cache /* work area for tied-mixture computation */ @@ -145,7 +151,7 @@ int *gsindex; ///< Index buffer LOGPROB *t_fs; ///< Current fallback_score /* GMS gprune local cache */ - int *gms_last_max_id; ///< maximum mixture id of last call for each states + int **gms_last_max_id_list; ///< maximum mixture id of last call for each states } HMMWork; @@ -189,6 +195,7 @@ boolean calc_tied_mix_prepare(HMMWork *wrk, int framenum); void calc_tied_mix_free(HMMWork *wrk); LOGPROB calc_tied_mix(HMMWork *wrk); +LOGPROB calc_compound_mix(HMMWork *wrk); /* gprune_common.c */ int cache_push(HMMWork *wrk, int id, LOGPROB score, int len); Index: julius4/libsent/include/sent/htk_defs.h diff -u julius4/libsent/include/sent/htk_defs.h:1.2 julius4/libsent/include/sent/htk_defs.h:1.3 --- julius4/libsent/include/sent/htk_defs.h:1.2 Tue Dec 18 17:45:50 2007 +++ julius4/libsent/include/sent/htk_defs.h Mon Jul 7 14:50:11 2008 @@ -24,7 +24,7 @@ * @author Akinobu LEE * @date Thu Feb 10 19:36:47 2005 * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * */ /* @@ -105,4 +105,14 @@ /// A header qualifier string for V2: variance inversed #define BINHMM_HEADER_V2_VARINV 'V' +/// A header qualifier string for V2: has mixture pdf macro def +#define BINHMM_HEADER_V2_MPDFMACRO 'M' + +/// Maximum number of input stream +#define MAXSTREAMNUM 50 + +#ifdef ENABLE_MSD +#define LZERO (-1.0E10) ///< log(0) value of void dimension for MSD-HMM */ +#endif + #endif /* __SENT_HTK_DEFS_H__ */ Index: julius4/libsent/include/sent/htk_hmm.h diff -u julius4/libsent/include/sent/htk_hmm.h:1.3 julius4/libsent/include/sent/htk_hmm.h:1.4 --- julius4/libsent/include/sent/htk_hmm.h:1.3 Wed Feb 13 17:38:50 2008 +++ julius4/libsent/include/sent/htk_hmm.h Mon Jul 7 14:50:11 2008 @@ -16,7 +16,7 @@ * @author Akinobu LEE * @date Thu Feb 10 19:36:47 2005 * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * */ /* @@ -68,7 +68,7 @@ /// @ingroup hmminfo /// Possible maximum value of state ID (in unsigned short) -#define MAX_STATE_NUM 65535 +#define MAX_STATE_NUM 2147483647 /// Delimiter strings/characters to generate logical triphone names #define HMM_RC_DLIM "+" ///< Right context delimiter in string @@ -80,7 +80,7 @@ #define SPMODEL_NAME_DEFAULT "sp" /// Length limit of HMM name (including ones generated in Julius) -#define MAX_HMMNAME_LEN 64 +#define MAX_HMMNAME_LEN 256 /// Specify method of calculating approximated acoustic score at inter-word context pseudo phones on word edge enum iwcd_type { @@ -95,7 +95,7 @@ /// Stream information (although current Julius supports only single stream) typedef struct { short num; ///< Number of stream - short vsize[50]; ///< Vector size for each stream + short vsize[MAXSTREAMNUM]; ///< Vector size for each stream } HTK_HMM_StreamInfo; /// %HMM Option @@ -137,19 +137,42 @@ struct _HTK_HMM_dens *next; ///< Pointer to next data, NULL if last } HTK_HMM_Dens; +/// %HMM stream weight definition +typedef struct _HTK_HMM_stream_weight { + char *name; ///< Name (NULL for in-line definition) + VECT *weight; ///< Weight of each stream in log scale + short len; ///< Length of above + struct _HTK_HMM_stream_weight *next; ///< Pointer to next data, NULL on last +} HTK_HMM_StreamWeight; + /** - * @brief %HMM state data - * + * @brief %HMM mixture PDF for a stream + * * @note * In a tied-mixture model, @a b points to a codebook defined as GCODEBOOK * intead of the array of densities. + * */ -typedef struct _HTK_HMM_state { - char *name; ///< Name (NULL if not defined as Macro) - short mix_num; ///< Number of densities (mixtures) assigned +typedef struct _HTK_HMM_PDF { + char *name; ///< Name (NULL for in-line definition) + boolean tmix; ///< TRUE if this is assigned to tied-mixture codebook + short stream_id; ///< Stream ID to which this pdf is assigned, begins from 0 + short mix_num; ///< Number of densities (mixtures) assigned. HTK_HMM_Dens **b; ///< Link array to assigned densities, or pointer to GCODEBOOK in tied-mixture model PROB *bweight; ///< Weights corresponding to above - unsigned short id; ///< Uniq state id starting from 0 for caching of output probability + struct _HTK_HMM_PDF *next; ///< Pointer to next data, or NULL at last +} HTK_HMM_PDF; + +/** + * @brief %HMM state data + * + */ +typedef struct _HTK_HMM_state { + char *name; ///< Name (NULL if not defined as Macro) + short nstream; ///< Num of stream + HTK_HMM_StreamWeight *w; ///< Pointer to stream weight data, or NULL is not specified + HTK_HMM_PDF **pdf; ///< Array of mixture PDFs for each stream + int id; ///< Uniq state id starting from 0 for caching of output probability struct _HTK_HMM_state *next; ///< Pointer to next data, NULL if last } HTK_HMM_State; @@ -316,6 +339,8 @@ HTK_HMM_Trans *trstart; ///< Root pointer to the list of transition matrixes HTK_HMM_Var *vrstart; ///< Root pointer to the list of variance data HTK_HMM_Dens *dnstart; ///< Root pointer to the list of density (mixture) data + HTK_HMM_PDF *pdfstart; ///< Root pointer to the list of mixture pdf data + HTK_HMM_StreamWeight *swstart; ///< Root pointer to the list of stream weight data HTK_HMM_State *ststart; ///< Root pointer to the list of state data HTK_HMM_Data *start; ///< Root pointer to the list of models //@} @@ -333,7 +358,9 @@ //@{ APATNODE *tr_root; ///< Root index node for transition matrixes APATNODE *vr_root; ///< Root index node for variance data + APATNODE *sw_root; ///< Root index node for stream weight data APATNODE *dn_root; ///< Root index node for density data + APATNODE *pdf_root; ///< Root index node for mixture PDF APATNODE *st_root; ///< Root index node for state data APATNODE *physical_root; ///< Root index node for defined %HMM name APATNODE *logical_root; ///< Root index node for logical %HMM name @@ -367,6 +394,7 @@ int totalhmmnum; ///< Total number of physical %HMM int totallogicalnum; ///< Total number of logical %HMM int totalpseudonum; ///< Total number of pseudo %HMM + int totalpdfnum; ///< Total number of mixture PDF int codebooknum; ///< Total number of codebook on tied-mixture model int maxcodebooksize; ///< Maximum size of codebook on tied-mixture model int maxmixturenum; ///< Maximum number of Gaussian per mixture @@ -375,6 +403,12 @@ BMALLOC_BASE *mroot; ///< Pointer for block memory allocation BMALLOC_BASE *lroot; ///< Pointer for block memory allocation for logical HMM + int *tmp_mixnum; ///< Work area for state reading + +#ifdef ENABLE_MSD + boolean has_msd; ///< TRUE if this model contains MSD part +#endif + //@} } HTK_HMM_INFO; @@ -385,8 +419,11 @@ char *read_token(FILE *fp); boolean rdhmmdef(FILE *, HTK_HMM_INFO *); void htk_hmm_inverse_variances(HTK_HMM_INFO *hmm); +#ifdef ENABLE_MSD +void htk_hmm_check_msd(HTK_HMM_INFO *hmm); +#endif /* rdhmmdef_options.c */ -void set_global_opt(FILE *fp, HTK_HMM_INFO *hmm); +boolean set_global_opt(FILE *fp, HTK_HMM_INFO *hmm); char *get_cov_str(short covtype); char *get_dur_str(short durtype); /* rdhmmdef_trans.c */ @@ -398,6 +435,11 @@ void def_state_macro(char *, FILE *, HTK_HMM_INFO *); HTK_HMM_State *state_lookup(HTK_HMM_INFO *hmm, char *keyname); void state_add(HTK_HMM_INFO *hmm, HTK_HMM_State *new); +/* rdhmmdef_mpdf.c */ +void mpdf_add(HTK_HMM_INFO *hmm, HTK_HMM_PDF *new); +HTK_HMM_PDF *mpdf_lookup(HTK_HMM_INFO *hmm, char *keyname); +HTK_HMM_PDF *get_mpdf_data(FILE *fp, HTK_HMM_INFO *hmm, int mix_num, short stream_id); +void def_mpdf_macro(char *name, FILE *fp, HTK_HMM_INFO *hmm); /* rdhmmdef_dens.c */ HTK_HMM_Dens *get_dens_data(FILE *, HTK_HMM_INFO *); void def_dens_macro(char *, FILE *, HTK_HMM_INFO *); @@ -407,12 +449,16 @@ HTK_HMM_Var *get_var_data(FILE *, HTK_HMM_INFO *); void def_var_macro(char *, FILE *, HTK_HMM_INFO *); void var_add(HTK_HMM_INFO *hmm, HTK_HMM_Var *new); +/* rdhmmdef_streamweight.c */ +HTK_HMM_StreamWeight *get_streamweight_data(FILE *fp, HTK_HMM_INFO *hmm); +void def_streamweight_macro(char *, FILE *, HTK_HMM_INFO *); +void sw_add(HTK_HMM_INFO *hmm, HTK_HMM_StreamWeight *new); /* rdhmmdef_data.c */ void def_HMM(char *, FILE *, HTK_HMM_INFO *); HTK_HMM_Data *htk_hmmdata_new(HTK_HMM_INFO *); void htk_hmmdata_add(HTK_HMM_INFO *hmm, HTK_HMM_Data *new); /* rdhmmdef_tiedmix.c */ -void tmix_read(FILE *fp, HTK_HMM_State *state, HTK_HMM_INFO *hmm); +void tmix_read(FILE *fp, HTK_HMM_PDF *mpdf, HTK_HMM_INFO *hmm); void codebook_add(HTK_HMM_INFO *hmm, GCODEBOOK *new); /* rdhmmdef_regtree.c */ void def_regtree_macro(char *name, FILE *fp, HTK_HMM_INFO *hmm); @@ -422,6 +468,7 @@ void put_htk_trans(FILE *fp, HTK_HMM_Trans *t); void put_htk_var(FILE *fp, HTK_HMM_Var *v); void put_htk_dens(FILE *fp, HTK_HMM_Dens *d); +void put_htk_mpdf(FILE *fp, HTK_HMM_PDF *m); void put_htk_state(FILE *fp, HTK_HMM_State *s); void put_htk_hmm(FILE *fp, HTK_HMM_Data *h); void put_logical_hmm(FILE *fp, HMM_Logical *l); From sumomo @ users.sourceforge.jp Mon Jul 7 14:50:12 2008 From: sumomo @ users.sourceforge.jp (sumomo @ users.sourceforge.jp) Date: Mon, 07 Jul 2008 14:50:12 +0900 Subject: [Julius-cvs 200] CVS update: julius4/libsent/src/phmm Message-ID: <1215409812.269800.1786.nullmailer@users.sourceforge.jp> Index: julius4/libsent/src/phmm/calc_mix.c diff -u julius4/libsent/src/phmm/calc_mix.c:1.2 julius4/libsent/src/phmm/calc_mix.c:1.3 --- julius4/libsent/src/phmm/calc_mix.c:1.2 Tue Dec 18 17:45:54 2007 +++ julius4/libsent/src/phmm/calc_mix.c Mon Jul 7 14:50:12 2008 @@ -12,7 +12,7 @@ * @author Akinobu LEE * @date Thu Feb 17 14:18:52 2005 * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * */ /* @@ -41,28 +41,41 @@ calc_mix(HMMWork *wrk) { int i; - LOGPROB logprob = LOG_ZERO; - int n; - LOGPROB *s; + LOGPROB logprob, logprobsum; PROB *w; int *id; + int s; + PROB stream_weight; /* compute Gaussian set */ - (*(wrk->compute_gaussset))(wrk, wrk->OP_state->b, wrk->OP_state->mix_num, NULL); - /* computed Gaussians will be set in: - score ... OP_calced_score[0..OP_calced_num] - id ... OP_calced_id[0..OP_calced_num] */ - - n = wrk->OP_calced_num; - s = wrk->OP_calced_score; - w = wrk->OP_state->bweight; - id = wrk->OP_calced_id; - - /* sum */ - for(i=0;iOP_nstream;s++) { + /* set stream weight */ + if (wrk->OP_state->w) stream_weight = wrk->OP_state->w->weight[s]; + else stream_weight = 1.0; + /* setup storage pointer for this mixture pdf */ + wrk->OP_vec = wrk->OP_vec_stream[s]; + wrk->OP_veclen = wrk->OP_veclen_stream[s]; + /* compute output probabilities */ + /* computed Gaussians will be set in: + score ... OP_calced_score[0..OP_calced_num] + id ... OP_calced_id[0..OP_calced_num] */ + (*(wrk->compute_gaussset))(wrk, wrk->OP_state->pdf[s]->b, wrk->OP_state->pdf[s]->mix_num, NULL); + /* add weights */ + id = wrk->OP_calced_id; + w = wrk->OP_state->pdf[s]->bweight; + for(i=0;iOP_calced_num;i++) { + //printf("s%d-m%d: %f %f\n", s+1, i+1, wrk->OP_calced_score[i], w[id[i]]); + wrk->OP_calced_score[i] += w[id[i]]; + } + /* add log probs */ + logprob = addlog_array(wrk->OP_calced_score, wrk->OP_calced_num); + /* if outprob of a stream is zero, skip this stream */ + if (logprob <= LOG_ZERO) continue; + /* sum all the obtained mixture scores */ + logprobsum += logprob * stream_weight; } - logprob = addlog_array(s, n); - if (logprob <= LOG_ZERO) return LOG_ZERO; - return (logprob * INV_LOG_TEN); + if (logprobsum == 0.0) return(LOG_ZERO); /* no valid stream */ + if (logprobsum <= LOG_ZERO) return(LOG_ZERO); /* lowest == LOG_ZERO */ + return (logprobsum * INV_LOG_TEN); } Index: julius4/libsent/src/phmm/calc_tied_mix.c diff -u julius4/libsent/src/phmm/calc_tied_mix.c:1.3 julius4/libsent/src/phmm/calc_tied_mix.c:1.4 --- julius4/libsent/src/phmm/calc_tied_mix.c:1.3 Tue Dec 18 17:45:54 2007 +++ julius4/libsent/src/phmm/calc_tied_mix.c Mon Jul 7 14:50:12 2008 @@ -22,7 +22,7 @@ * @author Akinobu LEE * @date Thu Feb 17 14:22:44 2005 * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * */ /* @@ -51,9 +51,10 @@ calc_tied_mix_init(HMMWork *wrk) { wrk->mixture_cache = NULL; + wrk->mixture_cache_num = NULL; wrk->tmix_allocframenum = 0; wrk->mroot = NULL; - wrk->tmix_last_id = (int *)mymalloc(sizeof(int) * wrk->OP_hmminfo->maxmixturenum); + wrk->tmix_last_id = (int *)mymalloc(sizeof(int) * wrk->OP_hmminfo->maxmixturenum * wrk->OP_nstream); return TRUE; } @@ -73,7 +74,7 @@ /* clear */ for(t=0;ttmix_allocframenum;t++) { for(bid=0;bidOP_hmminfo->codebooknum;bid++) { - wrk->mixture_cache[t][bid][0].score = LOG_ZERO; + wrk->mixture_cache_num[t][bid] = 0; } } @@ -102,21 +103,24 @@ if (wrk->mixture_cache == NULL) { wrk->mixture_cache = (MIXCACHE ***)mymalloc(sizeof(MIXCACHE **) * newnum); + wrk->mixture_cache_num = (short **)mymalloc(sizeof(short *) * newnum); } else { wrk->mixture_cache = (MIXCACHE ***)myrealloc(wrk->mixture_cache, sizeof(MIXCACHE **) * newnum); + wrk->mixture_cache_num = (short **)myrealloc(wrk->mixture_cache_num, sizeof(short *) * newnum); } size = wrk->OP_gprune_num * wrk->OP_hmminfo->codebooknum; for(t = wrk->tmix_allocframenum; t < newnum; t++) { wrk->mixture_cache[t] = (MIXCACHE **)mybmalloc2(sizeof(MIXCACHE *) * wrk->OP_hmminfo->codebooknum, &(wrk->mroot)); + wrk->mixture_cache_num[t] = (short *)mybmalloc2(sizeof(short) * wrk->OP_hmminfo->codebooknum, &(wrk->mroot)); wrk->mixture_cache[t][0] = (MIXCACHE *)mybmalloc2(sizeof(MIXCACHE) * size, &(wrk->mroot)); for(bid=1;bidOP_hmminfo->codebooknum;bid++) { wrk->mixture_cache[t][bid] = &(wrk->mixture_cache[t][0][wrk->OP_gprune_num * bid]); } /* clear the new part */ for(bid=0;bidOP_hmminfo->codebooknum;bid++) { - wrk->mixture_cache[t][bid][0].score = LOG_ZERO; + wrk->mixture_cache_num[t][bid] = 0; } } @@ -133,8 +137,12 @@ calc_tied_mix_free(HMMWork *wrk) { if (wrk->mroot != NULL) mybfree2(&(wrk->mroot)); + if (wrk->mixture_cache_num != NULL) free(wrk->mixture_cache_num); if (wrk->mixture_cache != NULL) free(wrk->mixture_cache); free(wrk->tmix_last_id); + wrk->mroot = NULL; + wrk->mixture_cache_num = NULL; + wrk->mixture_cache = NULL; } /** @@ -153,61 +161,183 @@ LOGPROB calc_tied_mix(HMMWork *wrk) { - GCODEBOOK *book = (GCODEBOOK *)(wrk->OP_state->b); - LOGPROB logprob; + GCODEBOOK *book; + LOGPROB logprob, logprobsum; int i, id; MIXCACHE *ttcache; + short ttcachenum; MIXCACHE *last_ttcache; PROB *weight; - - weight = wrk->OP_state->bweight; - -#if 0 - if (wrk->OP_last_time != wrk->OP_time) { /* different frame */ - if (wrk->OP_time >= 1) { - last_tcache = wrk->mixture_cache[wrk->OP_time-1]; + PROB stream_weight; + int s; + int num; + + logprobsum = 0.0; + for(s=0;sOP_nstream;s++) { + book = (GCODEBOOK *)(wrk->OP_state->pdf[s]->b); + weight = wrk->OP_state->pdf[s]->bweight; + /* set stream weight */ + if (wrk->OP_state->w) stream_weight = wrk->OP_state->w->weight[s]; + else stream_weight = 1.0; + /* setup storage pointer for this mixture pdf */ + wrk->OP_vec = wrk->OP_vec_stream[s]; + wrk->OP_veclen = wrk->OP_veclen_stream[s]; + /* extend cache if needed */ + calc_tied_mix_extend(wrk, wrk->OP_time); + /* prepare cache for this codebook at this time */ + ttcache = wrk->mixture_cache[wrk->OP_time][book->id]; + ttcachenum = wrk->mixture_cache_num[wrk->OP_time][book->id]; + /* consult cache */ + if (ttcachenum > 0) { + /* calculate using cache and weight */ + for (i=0;iOP_calced_score[i] = ttcache[i].score + weight[ttcache[i].id]; + } + num = ttcachenum; } else { - last_tcache = NULL; + /* compute Gaussian set */ + /* computed Gaussians will be set in: + score ... OP_calced_score[0..OP_calced_num] + id ... OP_calced_id[0..OP_calced_num] */ + if (wrk->OP_time >= 1) { + last_ttcache = wrk->mixture_cache[wrk->OP_time-1][book->id]; + if (last_ttcache[0].score != LOG_ZERO) { + for(i=0;iOP_gprune_num;i++) wrk->tmix_last_id[i] = last_ttcache[i].id; + /* tell last calced best */ + (*(wrk->compute_gaussset))(wrk, book->d, book->num, wrk->tmix_last_id); + } else { + (*(wrk->compute_gaussset))(wrk, book->d, book->num, NULL); + } + } else { + (*(wrk->compute_gaussset))(wrk, book->d, book->num, NULL); + } + /* store to cache */ + wrk->mixture_cache_num[wrk->OP_time][book->id] = wrk->OP_calced_num; + for (i=0;iOP_calced_num;i++) { + id = wrk->OP_calced_id[i]; + ttcache[i].id = id; + ttcache[i].score = wrk->OP_calced_score[i]; + /* now OP_calced_{id|score} can be used for work area */ + /* add weights */ + wrk->OP_calced_score[i] += weight[id]; + } + num = wrk->OP_calced_num; } + /* add log probs */ + logprob = addlog_array(wrk->OP_calced_score, num); + /* if outprob of a stream is zero, skip this stream */ + if (logprob <= LOG_ZERO) continue; + /* sum all the obtained mixture scores */ + logprobsum += logprob * stream_weight; } -#endif + if (logprobsum == 0.0) return(LOG_ZERO); /* no valid stream */ + if (logprobsum <= LOG_ZERO) return(LOG_ZERO); /* lowest == LOG_ZERO */ + return (logprobsum * INV_LOG_TEN); +} - /* extend cache if needed */ - calc_tied_mix_extend(wrk, wrk->OP_time); - ttcache = wrk->mixture_cache[wrk->OP_time][book->id]; - if (ttcache[0].score != LOG_ZERO) { /* already calced */ - /* calculate using cache and weight */ - for (i=0;iOP_calced_num;i++) { - wrk->OP_calced_score[i] = ttcache[i].score + weight[ttcache[i].id]; - } - } else { /* not calced yet */ - /* compute Gaussian set */ - if (wrk->OP_time >= 1) { - last_ttcache = wrk->mixture_cache[wrk->OP_time-1][book->id]; - if (last_ttcache[0].score != LOG_ZERO) { - for(i=0;iOP_gprune_num;i++) wrk->tmix_last_id[i] = last_ttcache[i].id; - /* tell last calced best */ - (*(wrk->compute_gaussset))(wrk, book->d, book->num, wrk->tmix_last_id); + +/** + * @brief Compute the output probability of current state OP_State, + * regardless of tied-mixture model or state-level mixture PDF. + * + * This function switches calculation function of calc_mix() and + * calc_tied_mix() based on the mixture PDF information. + * This will be used on a system which has tied-mixture codebook + * but some states still has their own mixture PDF. + * + * The initialization functions should be the same as calc_tied_mix(), + * since calc_mix() has no specific initialization. + * + * @param wrk [i/o] HMM computation work area + * + * @return the computed output probability in log10. + */ +LOGPROB +calc_compound_mix(HMMWork *wrk) +{ + HTK_HMM_PDF *m; + GCODEBOOK *book; + LOGPROB logprob, logprobsum; + int i, id; + MIXCACHE *ttcache; + short ttcachenum; + MIXCACHE *last_ttcache; + PROB *weight; + PROB stream_weight; + int s; + int num; + + logprobsum = 0.0; + for(s=0;sOP_nstream;s++) { + /* set stream weight */ + if (wrk->OP_state->w) stream_weight = wrk->OP_state->w->weight[s]; + else stream_weight = 1.0; + m = wrk->OP_state->pdf[s]; + /* setup storage pointer for this mixture pdf */ + wrk->OP_vec = wrk->OP_vec_stream[s]; + wrk->OP_veclen = wrk->OP_veclen_stream[s]; + weight = wrk->OP_state->pdf[s]->bweight; + if (m->tmix) { + /* tied-mixture PDF */ + book = (GCODEBOOK *)(m->b); + /* extend cache if needed */ + calc_tied_mix_extend(wrk, wrk->OP_time); + /* prepare cache for this codebook at this time */ + ttcache = wrk->mixture_cache[wrk->OP_time][book->id]; + ttcachenum = wrk->mixture_cache_num[wrk->OP_time][book->id]; + /* consult cache */ + if (ttcachenum > 0) { + /* calculate using cache and weight */ + for (i=0;iOP_calced_score[i] = ttcache[i].score + weight[ttcache[i].id]; + } + num = ttcachenum; } else { - (*(wrk->compute_gaussset))(wrk, book->d, book->num, NULL); + /* compute Gaussian set */ + /* computed Gaussians will be set in: + score ... OP_calced_score[0..OP_calced_num] + id ... OP_calced_id[0..OP_calced_num] */ + if (wrk->OP_time >= 1) { + last_ttcache = wrk->mixture_cache[wrk->OP_time-1][book->id]; + if (last_ttcache[0].score != LOG_ZERO) { + for(i=0;iOP_gprune_num;i++) wrk->tmix_last_id[i] = last_ttcache[i].id; + /* tell last calced best */ + (*(wrk->compute_gaussset))(wrk, book->d, book->num, wrk->tmix_last_id); + } else { + (*(wrk->compute_gaussset))(wrk, book->d, book->num, NULL); + } + } else { + (*(wrk->compute_gaussset))(wrk, book->d, book->num, NULL); + } + /* store to cache */ + wrk->mixture_cache_num[wrk->OP_time][book->id] = wrk->OP_calced_num; + for (i=0;iOP_calced_num;i++) { + id = wrk->OP_calced_id[i]; + ttcache[i].id = id; + ttcache[i].score = wrk->OP_calced_score[i]; + /* now OP_calced_{id|score} can be used for work area */ + /* add weights */ + wrk->OP_calced_score[i] += weight[id]; + } + num = wrk->OP_calced_num; } } else { - (*(wrk->compute_gaussset))(wrk, book->d, book->num, NULL); - } - /* computed Gaussians will be set in: - score ... OP_calced_score[0..OP_calced_num] - id ... OP_calced_id[0..OP_calced_num] */ - /* OP_gprune_num = required, OP_calced_num = actually calced */ - /* store to cache */ - for (i=0;iOP_calced_num;i++) { - id = wrk->OP_calced_id[i]; - ttcache[i].id = id; - ttcache[i].score = wrk->OP_calced_score[i]; - /* now OP_calced_{id|score} can be used for work area */ - wrk->OP_calced_score[i] += weight[id]; + /* normal state */ + (*(wrk->compute_gaussset))(wrk, m->b, m->mix_num, NULL); + /* add weights */ + for(i=0;iOP_calced_num;i++) { + wrk->OP_calced_score[i] += weight[wrk->OP_calced_id[i]]; + } + num = wrk->OP_calced_num; } + /* add log probs */ + logprob = addlog_array(wrk->OP_calced_score, num); + /* if outprob of a stream is zero, skip this stream */ + if (logprob <= LOG_ZERO) continue; + /* sum all the obtained mixture scores */ + logprobsum += logprob * stream_weight; } - logprob = addlog_array(wrk->OP_calced_score, wrk->OP_calced_num); - if (logprob <= LOG_ZERO) return LOG_ZERO; - return (logprob * INV_LOG_TEN); -} + if (logprobsum == 0.0) return(LOG_ZERO); /* no valid stream */ + if (logprobsum <= LOG_ZERO) return(LOG_ZERO); /* lowest == LOG_ZERO */ + return (logprobsum * INV_LOG_TEN); +} Index: julius4/libsent/src/phmm/gms_gprune.c diff -u julius4/libsent/src/phmm/gms_gprune.c:1.2 julius4/libsent/src/phmm/gms_gprune.c:1.3 --- julius4/libsent/src/phmm/gms_gprune.c:1.2 Tue Dec 18 17:45:54 2007 +++ julius4/libsent/src/phmm/gms_gprune.c Mon Jul 7 14:50:12 2008 @@ -12,7 +12,7 @@ * @author Akinobu LEE * @date Thu Feb 17 15:05:08 2005 * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * */ /* @@ -42,7 +42,11 @@ void gms_gprune_init(HMMWork *wrk) { - wrk->gms_last_max_id = (int *)mymalloc(sizeof(int) * wrk->gsset_num); + int i; + wrk->gms_last_max_id_list = (int **)mymalloc(sizeof(int *) * wrk->gsset_num); + for(i=0;igsset_num;i++) { + wrk->gms_last_max_id_list[i] = (int *)mymalloc(sizeof(int) * wrk->OP_nstream); + } } /** @@ -54,9 +58,11 @@ void gms_gprune_prepare(HMMWork *wrk) { - int i; + int i, j; for(i=0;igsset_num;i++) { - wrk->gms_last_max_id[i] = -1; + for(j=0;jOP_nstream;j++) { + wrk->gms_last_max_id_list[i][j] = -1; + } } } @@ -69,7 +75,9 @@ void gms_gprune_free(HMMWork *wrk) { - free(wrk->gms_last_max_id); + int i; + for(i=0;igsset_num;i++) free(wrk->gms_last_max_id_list[i]); + free(wrk->gms_last_max_id_list); } /**********************************************************************/ @@ -122,39 +130,51 @@ * @return the log likelihood. */ static LOGPROB -compute_g_max(HMMWork *wrk, HTK_HMM_State *stateinfo, int last_maxi, int *maxi_ret) +compute_g_max(HMMWork *wrk, HTK_HMM_State *stateinfo, int *last_maxi) { int i, maxi; LOGPROB prob; LOGPROB maxprob = LOG_ZERO; - - if (last_maxi != -1) { - maxi = last_maxi; - maxprob = calc_contprob_with_safe_pruning(wrk, stateinfo->b[maxi], LOG_ZERO); - for (i = stateinfo->mix_num - 1; i >= 0; i--) { - if (i == last_maxi) continue; - prob = calc_contprob_with_safe_pruning(wrk, stateinfo->b[i], maxprob); - if (prob > maxprob) { - maxprob = prob; - maxi = i; + int s; + PROB stream_weight; + LOGPROB logprob, logprobsum; + + logprobsum = 0.0; + for(s=0;sOP_nstream;s++) { + /* set stream weight */ + if (stateinfo->w) stream_weight = stateinfo->w->weight[s]; + else stream_weight = 1.0; + /* setup storage pointer for this mixture pdf */ + wrk->OP_vec = wrk->OP_vec_stream[s]; + wrk->OP_veclen = wrk->OP_veclen_stream[s]; + + if (last_maxi[s] != -1) { + maxi = last_maxi[s]; + maxprob = calc_contprob_with_safe_pruning(wrk, stateinfo->pdf[s]->b[maxi], LOG_ZERO); + for (i = stateinfo->pdf[s]->mix_num - 1; i >= 0; i--) { + if (i == last_maxi[s]) continue; + prob = calc_contprob_with_safe_pruning(wrk, stateinfo->pdf[s]->b[i], maxprob); + if (prob > maxprob) { + maxprob = prob; + maxi = i; + } } - } - *maxi_ret = maxi; - } else { - maxi = stateinfo->mix_num - 1; - maxprob = calc_contprob_with_safe_pruning(wrk, stateinfo->b[maxi], LOG_ZERO); - i = maxi - 1; - for (; i >= 0; i--) { - prob = calc_contprob_with_safe_pruning(wrk, stateinfo->b[i], maxprob); - if (prob > maxprob) { - maxprob = prob; - maxi = i; + last_maxi[s] = maxi; + } else { + maxi = stateinfo->pdf[s]->mix_num - 1; + maxprob = calc_contprob_with_safe_pruning(wrk, stateinfo->pdf[s]->b[maxi], LOG_ZERO); + for (i = maxi - 1; i >= 0; i--) { + prob = calc_contprob_with_safe_pruning(wrk, stateinfo->pdf[s]->b[i], maxprob); + if (prob > maxprob) { + maxprob = prob; + maxi = i; + } } + last_maxi[s] = maxi; } - *maxi_ret = maxi; + logprobsum += (maxprob + stateinfo->pdf[s]->bweight[maxi]) * stream_weight; } - - return((maxprob + stateinfo->bweight[maxi]) * INV_LOG_TEN); + return (logprobsum * INV_LOG_TEN); } #else /* ~LAST_BEST */ @@ -174,16 +194,30 @@ int i, maxi; LOGPROB prob; LOGPROB maxprob = LOG_ZERO; + int s; + PROB stream_weight; + LOGPROB logprob, logprobsum; + + logprobsum = 0.0; + for(s=0;sOP_nstream;s++) { + /* set stream weight */ + if (stateinfo->w) stream_weight = stateinfo->w->weight[s]; + else stream_weight = 1.0; + /* setup storage pointer for this mixture pdf */ + wrk->OP_vec = wrk->OP_vec_stream[s]; + wrk->OP_veclen = wrk->OP_veclen_stream[s]; - i = maxi = stateinfo->mix_num - 1; - for (; i >= 0; i--) { - prob = calc_contprob_with_safe_pruning(wrk, stateinfo->b[i], maxprob); - if (prob > maxprob) { - maxprob = prob; - maxi = i; + i = maxi = stateinfo->pdf[s]->mix_num - 1; + for (; i >= 0; i--) { + prob = calc_contprob_with_safe_pruning(wrk, stateinfo->pdf[s]->b[i], maxprob); + if (prob > maxprob) { + maxprob = prob; + maxi = i; + } } + logprobsum += (maxprob + stateinfo->pdf[s]->bweight[maxi]) * stream_weight; } - return((maxprob + stateinfo->bweight[maxi]) * INV_LOG_TEN); + return (logprobsum * INV_LOG_TEN); } #endif @@ -204,16 +238,12 @@ compute_gs_scores(HMMWork *wrk) { int i; -#ifdef LAST_BEST - int max_id; -#endif for (i=0;igsset_num;i++) { #ifdef GS_MAX_PROB #ifdef LAST_BEST /* compute only the maximum with pruning (last best first) */ - wrk->t_fs[i] = compute_g_max(wrk, wrk->gsset[i].state, wrk->gms_last_max_id[i], &max_id); - wrk->gms_last_max_id[i] = max_id; + wrk->t_fs[i] = compute_g_max(wrk, wrk->gsset[i].state, wrk->gms_last_max_id_list[i]); #else wrk->t_fs[i] = compute_g_max(wrk, wrk->gsset[i].state); #endif /* LAST_BEST */ Index: julius4/libsent/src/phmm/gprune_beam.c diff -u julius4/libsent/src/phmm/gprune_beam.c:1.2 julius4/libsent/src/phmm/gprune_beam.c:1.3 --- julius4/libsent/src/phmm/gprune_beam.c:1.2 Tue Dec 18 17:45:54 2007 +++ julius4/libsent/src/phmm/gprune_beam.c Mon Jul 7 14:50:12 2008 @@ -40,7 +40,7 @@ * @author Akinobu LEE * @date Thu Feb 17 03:27:53 2005 * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * */ /* @@ -234,10 +234,11 @@ gprune_beam_init(HMMWork *wrk) { int i; - /* maximum Gaussian set size = maximum mixture size */ - wrk->OP_calced_maxnum = wrk->OP_hmminfo->maxmixturenum; - wrk->OP_calced_score = (LOGPROB *)mymalloc(sizeof(LOGPROB) * wrk->OP_gprune_num); - wrk->OP_calced_id = (int *)mymalloc(sizeof(int) * wrk->OP_gprune_num); + + /* maximum Gaussian set size = maximum mixture size * nstream */ + wrk->OP_calced_maxnum = wrk->OP_hmminfo->maxmixturenum * wrk->OP_nstream; + wrk->OP_calced_score = (LOGPROB *)mymalloc(sizeof(LOGPROB) * wrk->OP_calced_maxnum); + wrk->OP_calced_id = (int *)mymalloc(sizeof(int) * wrk->OP_calced_maxnum); wrk->mixcalced = (boolean *)mymalloc(sizeof(int) * wrk->OP_calced_maxnum); for(i=0;iOP_calced_maxnum;i++) wrk->mixcalced[i] = FALSE; wrk->dimthres_num = wrk->OP_hmminfo->opt.vec_size; Index: julius4/libsent/src/phmm/gprune_heu.c diff -u julius4/libsent/src/phmm/gprune_heu.c:1.2 julius4/libsent/src/phmm/gprune_heu.c:1.3 --- julius4/libsent/src/phmm/gprune_heu.c:1.2 Tue Dec 18 17:45:54 2007 +++ julius4/libsent/src/phmm/gprune_heu.c Mon Jul 7 14:50:12 2008 @@ -38,7 +38,7 @@ * @author Akinobu LEE * @date Thu Feb 17 05:44:52 2005 * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * */ /* @@ -237,10 +237,11 @@ gprune_heu_init(HMMWork *wrk) { int i; - /* maximum Gaussian set size = maximum mixture size */ - wrk->OP_calced_maxnum = wrk->OP_hmminfo->maxmixturenum; - wrk->OP_calced_score = (LOGPROB *)mymalloc(sizeof(LOGPROB) * wrk->OP_gprune_num); - wrk->OP_calced_id = (int *)mymalloc(sizeof(int) * wrk->OP_gprune_num); + + /* maximum Gaussian set size = maximum mixture size * nstream */ + wrk->OP_calced_maxnum = wrk->OP_hmminfo->maxmixturenum * wrk->OP_nstream; + wrk->OP_calced_score = (LOGPROB *)mymalloc(sizeof(LOGPROB) * wrk->OP_calced_maxnum); + wrk->OP_calced_id = (int *)mymalloc(sizeof(int) * wrk->OP_calced_maxnum); wrk->mixcalced = (boolean *)mymalloc(sizeof(int) * wrk->OP_calced_maxnum); for(i=0;iOP_calced_maxnum;i++) wrk->mixcalced[i] = FALSE; wrk->backmax_num = wrk->OP_hmminfo->opt.vec_size + 1; Index: julius4/libsent/src/phmm/gprune_none.c diff -u julius4/libsent/src/phmm/gprune_none.c:1.2 julius4/libsent/src/phmm/gprune_none.c:1.3 --- julius4/libsent/src/phmm/gprune_none.c:1.2 Tue Dec 18 17:45:54 2007 +++ julius4/libsent/src/phmm/gprune_none.c Mon Jul 7 14:50:12 2008 @@ -30,7 +30,7 @@ * @author Akinobu LEE * @date Thu Feb 17 05:09:46 2005 * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * */ /* @@ -69,6 +69,12 @@ var = binfo->var->vec; tmp = binfo->gconst; for (; veclen > 0; veclen--) { +#ifdef ENABLE_MSD + if (*vec == LZERO) { + vec++; + continue; + } +#endif x = *(vec++) - *(mean++); tmp += x * x * *(var++); } @@ -85,8 +91,8 @@ boolean gprune_none_init(HMMWork *wrk) { - /* maximum Gaussian set size = maximum mixture size */ - wrk->OP_calced_maxnum = wrk->OP_hmminfo->maxmixturenum; + /* maximum Gaussian set size = maximum mixture size * nstream */ + wrk->OP_calced_maxnum = wrk->OP_hmminfo->maxmixturenum * wrk->OP_nstream; wrk->OP_calced_score = (LOGPROB *)mymalloc(sizeof(LOGPROB) * wrk->OP_calced_maxnum); wrk->OP_calced_id = (int *)mymalloc(sizeof(int) * wrk->OP_calced_maxnum); /* force gprune_num to the max number */ @@ -129,6 +135,40 @@ HTK_HMM_Dens *dens; LOGPROB *prob = wrk->OP_calced_score; int *id = wrk->OP_calced_id; +#ifdef ENABLE_MSD + int valid_dim; + int calced_num; +#endif + +#ifdef ENABLE_MSD + + valid_dim = 0; + for(i=0; iOP_veclen; i++) { + if (wrk->OP_vec[i] != LZERO) valid_dim++; + } + calced_num = 0; + for(i=0; imeanlen != valid_dim) continue; + if (dens->meanlen == 0) { + *(prob++) = 0.0; + } else { + *(prob++) = compute_g_base(wrk, dens); + } + *(id++) = i; + calced_num++; + } + if (calced_num == 0) { + jlog("Error: MSD: input data dim = %d / %d, but no Gaussian defined for it\n", valid_dim, wrk->OP_veclen); + jlog("Error: MSD: Gaussian dimensions in this mixture:"); + for(i=0;imeanlen); + } + jlog("\n"); + } + wrk->OP_calced_num = calced_num; + +#else for(i=0; iOP_calced_num = num; + +#endif } Index: julius4/libsent/src/phmm/gprune_safe.c diff -u julius4/libsent/src/phmm/gprune_safe.c:1.2 julius4/libsent/src/phmm/gprune_safe.c:1.3 --- julius4/libsent/src/phmm/gprune_safe.c:1.2 Tue Dec 18 17:45:54 2007 +++ julius4/libsent/src/phmm/gprune_safe.c Mon Jul 7 14:50:12 2008 @@ -39,7 +39,7 @@ * @author Akinobu LEE * @date Thu Feb 17 05:28:12 2005 * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * */ /* @@ -52,7 +52,7 @@ /* gprune_safe.c --- calculate probability of Gaussian densities */ /* with Gaussian pruning (safe) */ -/* $Id: gprune_safe.c,v 1.2 2007/12/18 08:45:54 sumomo Exp $ */ +/* $Id: gprune_safe.c,v 1.3 2008/07/07 05:50:12 sumomo Exp $ */ #include #include @@ -108,10 +108,10 @@ { int i; - /* maximum Gaussian set size = maximum mixture size */ - wrk->OP_calced_maxnum = wrk->OP_hmminfo->maxmixturenum; - wrk->OP_calced_score = (LOGPROB *)mymalloc(sizeof(LOGPROB) * wrk->OP_gprune_num); - wrk->OP_calced_id = (int *)mymalloc(sizeof(int) * wrk->OP_gprune_num); + /* maximum Gaussian set size = maximum mixture size * nstream */ + wrk->OP_calced_maxnum = wrk->OP_hmminfo->maxmixturenum * wrk->OP_nstream; + wrk->OP_calced_score = (LOGPROB *)mymalloc(sizeof(LOGPROB) * wrk->OP_calced_maxnum); + wrk->OP_calced_id = (int *)mymalloc(sizeof(int) * wrk->OP_calced_maxnum); wrk->mixcalced = (boolean *)mymalloc(sizeof(int) * wrk->OP_calced_maxnum); for(i=0;iOP_calced_maxnum;i++) wrk->mixcalced[i] = FALSE; return TRUE; Index: julius4/libsent/src/phmm/outprob.c diff -u julius4/libsent/src/phmm/outprob.c:1.2 julius4/libsent/src/phmm/outprob.c:1.3 --- julius4/libsent/src/phmm/outprob.c:1.2 Tue Dec 18 17:45:54 2007 +++ julius4/libsent/src/phmm/outprob.c Mon Jul 7 14:50:12 2008 @@ -46,7 +46,7 @@ * @author Akinobu LEE * @date Fri Feb 18 18:45:21 2005 * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * */ /* @@ -185,6 +185,7 @@ { LOGPROB outp; int sid; + int i, d; sid = stateinfo->id; @@ -195,8 +196,10 @@ if (wrk->OP_time != t) { wrk->OP_last_time = wrk->OP_time; wrk->OP_time = t; - wrk->OP_vec = param->parvec[t]; - wrk->OP_veclen = param->veclen; + for(d=0,i=0;iOP_nstream;i++) { + wrk->OP_vec_stream[i] = &(param->parvec[t][d]); + d += wrk->OP_veclen_stream[i]; + } outprob_cache_extend(wrk, t); /* extend cache if needed */ wrk->last_cache = wrk->outprob_cache[t]; /* reduce 2-d array access */ Index: julius4/libsent/src/phmm/outprob_init.c diff -u julius4/libsent/src/phmm/outprob_init.c:1.2 julius4/libsent/src/phmm/outprob_init.c:1.3 --- julius4/libsent/src/phmm/outprob_init.c:1.2 Tue Dec 18 17:45:54 2007 +++ julius4/libsent/src/phmm/outprob_init.c Mon Jul 7 14:50:12 2008 @@ -34,7 +34,7 @@ * @author Akinobu LEE * @date Thu Feb 17 13:35:37 2005 * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * */ /* @@ -70,6 +70,7 @@ int gprune_method, int gprune_mixnum ) { + int i; /* check if variances are inversed */ if (!hmminfo->variance_inversed) { /* here, inverse all variance values for faster computation */ @@ -88,6 +89,13 @@ /** select functions **/ /* select pruning function to compute likelihood of a mixture component and set the pointer to global */ +#ifdef ENABLE_MSD + /* currently MSD model works only for non pruning mode */ + if (hmminfo->has_msd && gprune_method != GPRUNE_SEL_NONE) { + jlog("Error: outprob_init: Julius support only \"-gprune none\" when ENABLE_MSD defined\n"); + return FALSE; + } +#endif switch(gprune_method) { case GPRUNE_SEL_NONE: wrk->compute_gaussset = gprune_none; @@ -112,8 +120,26 @@ } /* select caching function to compute output probability of a mixture */ if (hmminfo->is_tied_mixture) { - wrk->calc_outprob = calc_tied_mix; /* enable book-level cache, typically for a tied-mixture model */ + /* check if all mixture PDFs are tied-mixture */ + { + HTK_HMM_PDF *p; + boolean ok_p = TRUE; + for (p = hmminfo->pdfstart; p; p = p->next) { + if (p->tmix == FALSE) { + ok_p = FALSE; + break; + } + } + if (ok_p) { + jlog("Stat: outprob_init: all mixture PDFs are tied-mixture, use calc_tied_mix()\n"); + wrk->calc_outprob = calc_tied_mix; /* enable book-level cache, typically for a tied-mixture model */ + } else { + jlog("Stat: outprob_init: tied-mixture PDF exist (not all), calc_compound_mix()\n"); + wrk->calc_outprob = calc_compound_mix; /* enable book-level cache, typically for a tied-mixture model */ + } + } } else { + jlog("Stat: outprob_init: state-level mixture PDFs, use calc_mix()\n"); wrk->calc_outprob = calc_mix; /* no mixture-level cache, for a shared-state, non tied-mixture model */ } @@ -129,6 +155,12 @@ wrk->OP_gshmm = gshmm; /* NULL if GMS not used */ wrk->OP_gprune_num = gprune_mixnum; + /* store multi-stream data */ + wrk->OP_nstream = hmminfo->opt.stream_info.num; + for(i=0;iOP_nstream;i++) { + wrk->OP_veclen_stream[i] = hmminfo->opt.stream_info.vsize[i]; + } + /* generate addlog table */ make_log_tbl(); From sumomo @ users.sourceforge.jp Mon Jul 7 14:50:12 2008 From: sumomo @ users.sourceforge.jp (sumomo @ users.sourceforge.jp) Date: Mon, 07 Jul 2008 14:50:12 +0900 Subject: [Julius-cvs 201] CVS update: julius4/libsent/src/util Message-ID: <1215409812.440059.1795.nullmailer@users.sourceforge.jp> Index: julius4/libsent/src/util/confout.c diff -u julius4/libsent/src/util/confout.c:1.4 julius4/libsent/src/util/confout.c:1.5 --- julius4/libsent/src/util/confout.c:1.4 Tue Jul 1 13:29:46 2008 +++ julius4/libsent/src/util/confout.c Mon Jul 7 14:50:12 2008 @@ -12,7 +12,7 @@ * @author Akinobu LEE * @date Thu Feb 17 15:34:39 2005 * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * */ /* @@ -109,7 +109,10 @@ * fprintf(strm, " multi-path HMM handling : no\n"); * #endif */ - fprintf(strm, " multi-path HMM handling : auto\n"); + fprintf(strm, " multi-path treatment : autodetect\n"); +#ifdef ENABLE_MSD + fprintf(strm, " MSD-HMM support : yes\n"); +#endif } /** From sumomo @ users.sourceforge.jp Mon Jul 7 14:50:12 2008 From: sumomo @ users.sourceforge.jp (sumomo @ users.sourceforge.jp) Date: Mon, 07 Jul 2008 14:50:12 +0900 Subject: [Julius-cvs 202] CVS update: julius4/mkbinhmm Message-ID: <1215409812.592661.1803.nullmailer@users.sourceforge.jp> Index: julius4/mkbinhmm/mkbinhmm.c diff -u julius4/mkbinhmm/mkbinhmm.c:1.2 julius4/mkbinhmm/mkbinhmm.c:1.3 --- julius4/mkbinhmm/mkbinhmm.c:1.2 Tue Dec 18 17:45:55 2007 +++ julius4/mkbinhmm/mkbinhmm.c Mon Jul 7 14:50:12 2008 @@ -7,7 +7,7 @@ /* mkbinhmm --- read in ascii hmmdefs file and write in binary format */ -/* $Id: mkbinhmm.c,v 1.2 2007/12/18 08:45:55 sumomo Exp $ */ +/* $Id: mkbinhmm.c,v 1.3 2008/07/07 05:50:12 sumomo Exp $ */ #include #include @@ -69,7 +69,10 @@ /* read hmmdef file */ undef_para(¶); - init_hmminfo(hmminfo, infile, NULL, ¶); + if (init_hmminfo(hmminfo, infile, NULL, ¶) == FALSE) { + fprintf(stderr, "--- terminated\n"); + return -1; + } if (conffile != NULL) { /* if input HMMDEFS already has embedded parameter From sumomo @ users.sourceforge.jp Fri Jul 18 07:56:21 2008 From: sumomo @ users.sourceforge.jp (sumomo @ users.sourceforge.jp) Date: Fri, 18 Jul 2008 07:56:21 +0900 Subject: [Julius-cvs 203] CVS update: julius4/libjulius/src Message-ID: <1216335381.748961.26833.nullmailer@users.sourceforge.jp> Index: julius4/libjulius/src/m_adin.c diff -u julius4/libjulius/src/m_adin.c:1.5 julius4/libjulius/src/m_adin.c:1.6 --- julius4/libjulius/src/m_adin.c:1.5 Tue Jul 1 13:29:45 2008 +++ julius4/libjulius/src/m_adin.c Fri Jul 18 07:56:21 2008 @@ -12,7 +12,7 @@ * @author Akinobu LEE * @date Fri Mar 18 16:17:23 2005 * - * $Revision: 1.5 $ + * $Revision: 1.6 $ * */ /* @@ -74,24 +74,32 @@ a->ad_end = adin_mic_end; a->ad_read = adin_mic_read; break; +#ifdef HAS_ALSA case SP_INPUT_ALSA: a->ad_standby = adin_alsa_standby; a->ad_begin = adin_alsa_begin; a->ad_end = adin_alsa_end; a->ad_read = adin_alsa_read; break; +#endif +#ifdef HAS_OSS case SP_INPUT_OSS: a->ad_standby = adin_oss_standby; a->ad_begin = adin_oss_begin; a->ad_end = adin_oss_end; a->ad_read = adin_oss_read; break; +#endif +#ifdef HAS_ESD case SP_INPUT_ESD: a->ad_standby = adin_esd_standby; a->ad_begin = adin_esd_begin; a->ad_end = adin_esd_end; a->ad_read = adin_esd_read; break; +#endif + default: + jlog("ERROR: m_adin: invalid input device specified\n"); } break; #endif Index: julius4/libjulius/src/m_options.c diff -u julius4/libjulius/src/m_options.c:1.10 julius4/libjulius/src/m_options.c:1.11 --- julius4/libjulius/src/m_options.c:1.10 Tue Jul 1 13:29:45 2008 +++ julius4/libjulius/src/m_options.c Fri Jul 18 07:56:21 2008 @@ -18,7 +18,7 @@ * @author Akinobu Lee * @date Thu May 12 18:52:07 2005 * - * $Revision: 1.10 $ + * $Revision: 1.11 $ * */ /* @@ -286,17 +286,32 @@ jconf->input.device = SP_INPUT_DEFAULT; jconf->decodeopt.realtime_flag = TRUE; } else if (strmatch(tmparg,"alsa")) { +#ifdef HAS_ALSA jconf->input.speech_input = SP_MIC; jconf->input.device = SP_INPUT_ALSA; jconf->decodeopt.realtime_flag = TRUE; +#else + jlog("ERROR: m_options: \"-input alsa\": ALSA support is not built-in\n"); + return FALSE; +#endif } else if (strmatch(tmparg,"oss")) { +#ifdef HAS_OSS jconf->input.speech_input = SP_MIC; jconf->input.device = SP_INPUT_OSS; jconf->decodeopt.realtime_flag = TRUE; +#else + jlog("ERROR: m_options: \"-input oss\": OSS support is not built-in\n"); + return FALSE; +#endif } else if (strmatch(tmparg,"esd")) { +#ifdef HAS_ESD jconf->input.speech_input = SP_MIC; jconf->input.device = SP_INPUT_ESD; jconf->decodeopt.realtime_flag = TRUE; +#else + jlog("ERROR: m_options: \"-input oss\": OSS support is not built-in\n"); + return FALSE; +#endif #endif } else if (strmatch(tmparg,"file")) { /* for 1.1 compat */ jconf->input.speech_input = SP_RAWFILE; From sumomo @ users.sourceforge.jp Sun Jul 20 01:51:35 2008 From: sumomo @ users.sourceforge.jp (sumomo @ users.sourceforge.jp) Date: Sun, 20 Jul 2008 01:51:35 +0900 Subject: [Julius-cvs 204] CVS update: julius4/libsent/include/sent Message-ID: <1216486295.203469.30477.nullmailer@users.sourceforge.jp> Index: julius4/libsent/include/sent/hmm_calc.h diff -u julius4/libsent/include/sent/hmm_calc.h:1.4 julius4/libsent/include/sent/hmm_calc.h:1.5 --- julius4/libsent/include/sent/hmm_calc.h:1.4 Mon Jul 7 14:50:11 2008 +++ julius4/libsent/include/sent/hmm_calc.h Sun Jul 20 01:51:34 2008 @@ -13,7 +13,7 @@ * @author Akinobu LEE * @date Thu Feb 10 14:54:06 2005 * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * */ /* @@ -72,7 +72,7 @@ LOGPROB (*calc_outprob_state)(struct __hmmwork__ *); /// Pruning function to compute likelihood of a mixture component - void (*compute_gaussset)(struct __hmmwork__ *, HTK_HMM_Dens **g, int num, int *last_id); + void (*compute_gaussset)(struct __hmmwork__ *, HTK_HMM_Dens **g, int num, int *last_id, int lnum); /// Initialization function that corresponds to compute_gaussset. boolean (*compute_gaussset_init)(struct __hmmwork__ *); @@ -203,19 +203,19 @@ LOGPROB compute_g_base(HMMWork *wrk, HTK_HMM_Dens *binfo); boolean gprune_none_init(HMMWork *wrk); void gprune_none_free(HMMWork *wrk); -void gprune_none(HMMWork *wrk, HTK_HMM_Dens **g, int num, int *last_id); +void gprune_none(HMMWork *wrk, HTK_HMM_Dens **g, int num, int *last_id, int lnum); /* gprune_safe.c */ LOGPROB compute_g_safe(HMMWork *wrk, HTK_HMM_Dens *binfo, LOGPROB thres); boolean gprune_safe_init(HMMWork *wrk); void gprune_safe_free(HMMWork *wrk); -void gprune_safe(HMMWork *wrk, HTK_HMM_Dens **g, int gnum, int *last_id); +void gprune_safe(HMMWork *wrk, HTK_HMM_Dens **g, int gnum, int *last_id, int lnum); /* gprune_heu.c */ boolean gprune_heu_init(HMMWork *wrk); void gprune_heu_free(HMMWork *wrk); -void gprune_heu(HMMWork *wrk, HTK_HMM_Dens **g, int gnum, int *last_id); +void gprune_heu(HMMWork *wrk, HTK_HMM_Dens **g, int gnum, int *last_id, int lnum); /* gprune_beam.c */ boolean gprune_beam_init(HMMWork *wrk); void gprune_beam_free(HMMWork *wrk); -void gprune_beam(HMMWork *wrk, HTK_HMM_Dens **g, int gnum, int *last_id); +void gprune_beam(HMMWork *wrk, HTK_HMM_Dens **g, int gnum, int *last_id, int lnum); #endif /* __SENT_HMM_CALC_H__ */ From sumomo @ users.sourceforge.jp Sun Jul 20 01:51:35 2008 From: sumomo @ users.sourceforge.jp (sumomo @ users.sourceforge.jp) Date: Sun, 20 Jul 2008 01:51:35 +0900 Subject: [Julius-cvs 205] CVS update: julius4/libsent/src/hmminfo Message-ID: <1216486295.372775.30485.nullmailer@users.sourceforge.jp> Index: julius4/libsent/src/hmminfo/read_binhmm.c diff -u julius4/libsent/src/hmminfo/read_binhmm.c:1.4 julius4/libsent/src/hmminfo/read_binhmm.c:1.5 --- julius4/libsent/src/hmminfo/read_binhmm.c:1.4 Mon Jul 7 14:50:11 2008 +++ julius4/libsent/src/hmminfo/read_binhmm.c Sun Jul 20 01:51:35 2008 @@ -22,7 +22,7 @@ * @author Akinobu LEE * @date Wed Feb 16 05:23:59 2005 * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * */ /* @@ -540,6 +540,7 @@ rdn(fp, &did, sizeof(unsigned int), 1); m->b = (HTK_HMM_Dens **)tm_index[did]; m->mix_num = (tm_index[did])->num; + m->tmix = TRUE; } else { /* mixture */ m->b = (HTK_HMM_Dens **)mybmalloc2(sizeof(HTK_HMM_Dens *) * m->mix_num, &(hmm->mroot)); @@ -551,6 +552,7 @@ m->b[i] = dens_index[did]; } } + m->tmix = FALSE; } m->bweight = (PROB *)mybmalloc2(sizeof(PROB) * m->mix_num, &(hmm->mroot)); rdn(fp, m->bweight, sizeof(PROB), m->mix_num); @@ -650,8 +652,10 @@ /* mpdf are stored sequencially, so read the content here */ for(m=0;mnstream;m++) { s->pdf[m] = (HTK_HMM_PDF *)mybmalloc2(sizeof(HTK_HMM_PDF), &(hmm->mroot)); + s->pdf[m]->name = NULL; if (rd_pdf_sub(fp, hmm, s->pdf[m]) == FALSE) return FALSE; s->pdf[m]->stream_id = m; + mpdf_add(hmm, s->pdf[m]); } } if (hmm->opt.stream_info.num > 1) { From sumomo @ users.sourceforge.jp Sun Jul 20 01:51:35 2008 From: sumomo @ users.sourceforge.jp (sumomo @ users.sourceforge.jp) Date: Sun, 20 Jul 2008 01:51:35 +0900 Subject: [Julius-cvs 206] CVS update: julius4/libsent/src/phmm Message-ID: <1216486295.556703.30502.nullmailer@users.sourceforge.jp> Index: julius4/libsent/src/phmm/calc_mix.c diff -u julius4/libsent/src/phmm/calc_mix.c:1.3 julius4/libsent/src/phmm/calc_mix.c:1.4 --- julius4/libsent/src/phmm/calc_mix.c:1.3 Mon Jul 7 14:50:12 2008 +++ julius4/libsent/src/phmm/calc_mix.c Sun Jul 20 01:51:35 2008 @@ -12,7 +12,7 @@ * @author Akinobu LEE * @date Thu Feb 17 14:18:52 2005 * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * */ /* @@ -60,7 +60,7 @@ /* computed Gaussians will be set in: score ... OP_calced_score[0..OP_calced_num] id ... OP_calced_id[0..OP_calced_num] */ - (*(wrk->compute_gaussset))(wrk, wrk->OP_state->pdf[s]->b, wrk->OP_state->pdf[s]->mix_num, NULL); + (*(wrk->compute_gaussset))(wrk, wrk->OP_state->pdf[s]->b, wrk->OP_state->pdf[s]->mix_num, NULL, 0); /* add weights */ id = wrk->OP_calced_id; w = wrk->OP_state->pdf[s]->bweight; Index: julius4/libsent/src/phmm/calc_tied_mix.c diff -u julius4/libsent/src/phmm/calc_tied_mix.c:1.4 julius4/libsent/src/phmm/calc_tied_mix.c:1.5 --- julius4/libsent/src/phmm/calc_tied_mix.c:1.4 Mon Jul 7 14:50:12 2008 +++ julius4/libsent/src/phmm/calc_tied_mix.c Sun Jul 20 01:51:35 2008 @@ -22,7 +22,7 @@ * @author Akinobu LEE * @date Thu Feb 17 14:22:44 2005 * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * */ /* @@ -167,6 +167,7 @@ MIXCACHE *ttcache; short ttcachenum; MIXCACHE *last_ttcache; + short last_ttcachenum; PROB *weight; PROB stream_weight; int s; @@ -201,15 +202,16 @@ id ... OP_calced_id[0..OP_calced_num] */ if (wrk->OP_time >= 1) { last_ttcache = wrk->mixture_cache[wrk->OP_time-1][book->id]; - if (last_ttcache[0].score != LOG_ZERO) { - for(i=0;iOP_gprune_num;i++) wrk->tmix_last_id[i] = last_ttcache[i].id; + last_ttcachenum = wrk->mixture_cache_num[wrk->OP_time-1][book->id]; + if (last_ttcachenum > 0) { + for(i=0;itmix_last_id[i] = last_ttcache[i].id; /* tell last calced best */ - (*(wrk->compute_gaussset))(wrk, book->d, book->num, wrk->tmix_last_id); + (*(wrk->compute_gaussset))(wrk, book->d, book->num, wrk->tmix_last_id, last_ttcachenum); } else { - (*(wrk->compute_gaussset))(wrk, book->d, book->num, NULL); + (*(wrk->compute_gaussset))(wrk, book->d, book->num, NULL, 0); } } else { - (*(wrk->compute_gaussset))(wrk, book->d, book->num, NULL); + (*(wrk->compute_gaussset))(wrk, book->d, book->num, NULL, 0); } /* store to cache */ wrk->mixture_cache_num[wrk->OP_time][book->id] = wrk->OP_calced_num; @@ -262,6 +264,7 @@ MIXCACHE *ttcache; short ttcachenum; MIXCACHE *last_ttcache; + short last_ttcachenum; PROB *weight; PROB stream_weight; int s; @@ -299,15 +302,16 @@ id ... OP_calced_id[0..OP_calced_num] */ if (wrk->OP_time >= 1) { last_ttcache = wrk->mixture_cache[wrk->OP_time-1][book->id]; - if (last_ttcache[0].score != LOG_ZERO) { - for(i=0;iOP_gprune_num;i++) wrk->tmix_last_id[i] = last_ttcache[i].id; + last_ttcachenum = wrk->mixture_cache_num[wrk->OP_time-1][book->id]; + if (last_ttcachenum > 0) { + for(i=0;itmix_last_id[i] = last_ttcache[i].id; /* tell last calced best */ - (*(wrk->compute_gaussset))(wrk, book->d, book->num, wrk->tmix_last_id); + (*(wrk->compute_gaussset))(wrk, book->d, book->num, wrk->tmix_last_id, last_ttcachenum); } else { - (*(wrk->compute_gaussset))(wrk, book->d, book->num, NULL); + (*(wrk->compute_gaussset))(wrk, book->d, book->num, NULL, 0); } } else { - (*(wrk->compute_gaussset))(wrk, book->d, book->num, NULL); + (*(wrk->compute_gaussset))(wrk, book->d, book->num, NULL, 0); } /* store to cache */ wrk->mixture_cache_num[wrk->OP_time][book->id] = wrk->OP_calced_num; @@ -323,7 +327,7 @@ } } else { /* normal state */ - (*(wrk->compute_gaussset))(wrk, m->b, m->mix_num, NULL); + (*(wrk->compute_gaussset))(wrk, m->b, m->mix_num, NULL, 0); /* add weights */ for(i=0;iOP_calced_num;i++) { wrk->OP_calced_score[i] += weight[wrk->OP_calced_id[i]]; Index: julius4/libsent/src/phmm/gprune_beam.c diff -u julius4/libsent/src/phmm/gprune_beam.c:1.3 julius4/libsent/src/phmm/gprune_beam.c:1.4 --- julius4/libsent/src/phmm/gprune_beam.c:1.3 Mon Jul 7 14:50:12 2008 +++ julius4/libsent/src/phmm/gprune_beam.c Sun Jul 20 01:51:35 2008 @@ -40,7 +40,7 @@ * @author Akinobu LEE * @date Thu Feb 17 03:27:53 2005 * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * */ /* @@ -285,9 +285,10 @@ * @param gnum [in] length of above * @param last_id [in] ID list of N-best mixture in previous input frame, * or NULL if not exist + * @param lnum [in] length of last_id */ void -gprune_beam(HMMWork *wrk, HTK_HMM_Dens **g, int gnum, int *last_id) +gprune_beam(HMMWork *wrk, HTK_HMM_Dens **g, int gnum, int *last_id, int lnum) { int i, j, num = 0; LOGPROB score, thres; @@ -296,7 +297,7 @@ /* 1. clear dimthres */ clear_dimthres(wrk); /* 2. calculate first $OP_gprune_num and set initial thresholds */ - for (j=0; jOP_gprune_num; j++) { + for (j=0; jOP_gprune_num; j++) { + for (j=0; j #include @@ -154,16 +154,17 @@ * @param gnum [in] length of above * @param last_id [in] ID list of N-best mixture in previous input frame, * or NULL if not exist + * @param lnum [in] length of last_id */ void -gprune_safe(HMMWork *wrk, HTK_HMM_Dens **g, int gnum, int *last_id) +gprune_safe(HMMWork *wrk, HTK_HMM_Dens **g, int gnum, int *last_id, int lnum) { int i, j, num = 0; LOGPROB score, thres; if (last_id != NULL) { /* compute them first to form threshold */ /* 1. calculate first $OP_gprune_num and set initial threshold */ - for (j=0; jOP_gprune_num; j++) { + for (j=0; j Index: julius4/libjulius/src/m_fusion.c diff -u julius4/libjulius/src/m_fusion.c:1.6 julius4/libjulius/src/m_fusion.c:1.7 --- julius4/libjulius/src/m_fusion.c:1.6 Mon Jul 7 14:50:10 2008 +++ julius4/libjulius/src/m_fusion.c Sun Jul 20 01:52:33 2008 @@ -20,7 +20,7 @@ * @author Akinobu Lee * @date Thu May 12 13:31:47 2005 * - * $Revision: 1.6 $ + * $Revision: 1.7 $ * */ /* @@ -1189,7 +1189,7 @@ jlog("STAT: ------\n"); jlog("STAT: All models are ready, go for final fusion\n"); - jlog("STAT: [1] create MFCC instance(s)\n"); + jlog("STAT: [1] create MFCC extraction instance(s)\n"); if (recog->jconf->input.speech_input != SP_MFCFILE) { /***************************************************/ /* create MFCC calculation instance from AM config */ @@ -1201,7 +1201,7 @@ /****************************************/ /* create recognition process instances */ /****************************************/ - jlog("STAT: [2] ignite Recognizer instances]\n"); + jlog("STAT: [2] create recognition processing instance(s) with AM and LM\n"); for(sconf=recog->jconf->search_root;sconf;sconf=sconf->next) { if (j_launch_recognition_instance(recog, sconf) == FALSE) return FALSE; } @@ -1210,7 +1210,7 @@ /****** initialize GMM ******/ /****************************/ if (recog->gmm != NULL) { - jlog("STAT: [2.5] ignite GMM instance]\n"); + jlog("STAT: [2.5] create GMM instance\n"); if (gmm_init(recog) == FALSE) { jlog("ERROR: m_fusion: error in initializing GMM\n"); return FALSE; @@ -1218,7 +1218,7 @@ } /* stage 4: setup output probability function for each AM */ - jlog("STAT: [3] set up acoustic prob calculator]\n"); + jlog("STAT: [3] initialize for acoustic HMM calculation\n"); for(am=recog->amlist;am;am=am->next) { if (am->config->hmm_gs_filename != NULL) {/* with GMS */ if (outprob_init(&(am->hmmwrk), am->hmminfo, am->hmm_gs, am->config->gs_statenum, am->config->gprune_method, am->config->mixnum_thres) == FALSE) { @@ -1233,7 +1233,7 @@ /* stage 5: initialize work area for input and realtime decoding */ - jlog("STAT: [4] set up input MFCC handler]\n"); + jlog("STAT: [4] prepare MFCC storage(s)\n"); if (recog->jconf->input.speech_input == SP_MFCFILE) { /* create an MFCC instance for MFCC input */ /* create new mfcc instance */ @@ -1268,7 +1268,7 @@ } if (recog->jconf->decodeopt.realtime_flag) { - jlog("STAT: [5] initialize real-time decoding]\n"); + jlog("STAT: [5] prepare for real-time decoding\n"); /* prepare for 1st pass pipeline processing */ if (RealTimeInit(recog) == FALSE) { jlog("ERROR: m_fusion: failed to initialize recognition process\n"); Index: julius4/libjulius/src/multi-gram.c diff -u julius4/libjulius/src/multi-gram.c:1.3 julius4/libjulius/src/multi-gram.c:1.4 --- julius4/libjulius/src/multi-gram.c:1.3 Thu Feb 14 13:44:30 2008 +++ julius4/libjulius/src/multi-gram.c Sun Jul 20 01:52:33 2008 @@ -47,7 +47,7 @@ * @author Akinobu Lee * @date Sat Jun 18 23:45:18 2005 * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * */ /* @@ -297,7 +297,7 @@ new->next = lm->grammars; lm->grammars = new; - jlog("STAT: Gram #%d %s: read\n", new->id, new->name); + jlog("STAT: Gram #%d %s registered\n", new->id, new->name); lm->gram_maxid++; return new->id; @@ -626,7 +626,7 @@ /* setup additional grammar info of new ones */ for(m=lm->grammars;m;m=m->next) { if (m->newbie) { - jlog("STAT: Gram #%d %s: new grammar found, setup it for recognition\n", m->id, m->name); + jlog("STAT: Gram #%d %s: new grammar loaded, now mash it up for recognition\n", m->id, m->name); /* map dict item to dfa terminal symbols */ if (make_dfa_voca_ref(m->dfa, m->winfo) == FALSE) { jlog("ERROR: failed to map dict <-> DFA. This grammar will be deleted\n"); @@ -637,8 +637,9 @@ /* set dfa->sp_id and dfa->is_sp */ dfa_find_pause_word(m->dfa, m->winfo, lm->am->hmminfo); /* build catergory-pair information */ + jlog("STAT: Gram #%d %s: extracting category-pair constraint for the 1st pass\n", m->id, m->name); if (extract_cpair(m->dfa) == FALSE) { - jlog("ERROR: failed to extracting category pair. This grammar will be deleted\n"); + jlog("ERROR: failed to extract category pair. This grammar will be deleted\n"); /* mark as to be deleted */ m->hook |= MULTIGRAM_DELETE; } @@ -860,8 +861,6 @@ /* register the new grammar to multi-gram tree */ multigram_add(new_dfa, new_winfo, buf, lm); - jlog("STAT: gram \"%s\" registered\n", buf); - return TRUE; } From sumomo @ users.sourceforge.jp Mon Jul 21 14:21:17 2008 From: sumomo @ users.sourceforge.jp (sumomo @ users.sourceforge.jp) Date: Mon, 21 Jul 2008 14:21:17 +0900 Subject: [Julius-cvs 208] CVS update: julius4/libsent/include/sent Message-ID: <1216617677.043626.6086.nullmailer@users.sourceforge.jp> Index: julius4/libsent/include/sent/dfa.h diff -u julius4/libsent/include/sent/dfa.h:1.2 julius4/libsent/include/sent/dfa.h:1.3 --- julius4/libsent/include/sent/dfa.h:1.2 Tue Dec 18 17:45:50 2007 +++ julius4/libsent/include/sent/dfa.h Mon Jul 21 14:21:16 2008 @@ -29,7 +29,7 @@ * @author Akinobu LEE * @date Thu Feb 10 18:21:27 2005 * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * */ /* @@ -46,6 +46,8 @@ #define DFA_STATESTEP 1000 ///< Allocation step of DFA state +#define DFA_CP_MINSTEP 20 ///< Minimum initial CP data size per category + #define INITIAL_S 0x10000000 ///< Status flag mask specifying an initial state #define ACCEPT_S 0x00000001 ///< Status flag mask specifying an accept state @@ -77,19 +79,15 @@ int state_num; ///< Total number of states actually defined int arc_num; ///< Total number of arcs int term_num; ///< Total number of categories - /** - * Category-pair constraint is stored in bit, i.e., - * @code - * cp[c1][c2] -> (c2%8)th bit on cp[c1][c2/8] - * cp_begin[c2] -> (c2%8)th bit on cp_begin[c2/8] - * cp_end[c2] -> (c2%8)th bit on cp_end[c2/8] - * @endcode - * If bit is 1, the combination is allowed to connect. - */ - unsigned char **cp; ///< Store constraint whether @c c2 can follow @c c1 - unsigned char *cp_begin; ///< Store constraint whether @c c can appear at beginning of sentence - unsigned char *cp_end; ///< Store constraint whether @c c can appear at end of sentence - unsigned char *cp_root; ///< Root pointer of @c cp informations + int **cp; ///< Store constraint whether @c c2 can follow @c c1 + int *cplen; ///< Lengthes of each bcp + int *cpalloclen; ///< Allocated lengthes of each cp + int *cp_begin; ///< Store constraint whether @c c can appear at beginning of sentence + int cp_begin_len; ///< Length of cp_begin + int cp_begin_alloclen; ///< Allocated length of cp_begin + int *cp_end; ///< Store constraint whether @c c can appear at end of sentence + int cp_end_len; ///< Length of cp_end + int cp_end_alloclen; ///< Allocated length of cp_end TERM_INFO term; ///< Information of terminal symbols (category) boolean *is_sp; ///< TRUE if the category contains only \a sp word WORD_ID sp_id; ///< Word ID of short pause word @@ -118,11 +116,12 @@ void set_dfa_cp_begin(DFA_INFO *dfa, int i, boolean value); void set_dfa_cp_end(DFA_INFO *dfa, int i, boolean value); void init_dfa_cp(DFA_INFO *dfa); -void malloc_dfa_cp(DFA_INFO *dfa, int term_num); +void malloc_dfa_cp(DFA_INFO *dfa, int term_num, int size); void realloc_dfa_cp(DFA_INFO *dfa, int old_term_num, int new_term_num); void free_dfa_cp(DFA_INFO *dfa); - - +void dfa_cp_output_rawdata(FILE *fp, DFA_INFO *dfa); +void dfa_cp_count_size(DFA_INFO *dfa, unsigned long *size_ret, unsigned long *allocsize_ret); +boolean dfa_cp_append(DFA_INFO *dfa, DFA_INFO *src, int offset); #include boolean make_dfa_voca_ref(DFA_INFO *dinfo, WORD_INFO *winfo); From sumomo @ users.sourceforge.jp Mon Jul 21 14:21:17 2008 From: sumomo @ users.sourceforge.jp (sumomo @ users.sourceforge.jp) Date: Mon, 21 Jul 2008 14:21:17 +0900 Subject: [Julius-cvs 209] CVS update: julius4/libsent/src/dfa Message-ID: <1216617677.241640.6100.nullmailer@users.sourceforge.jp> Index: julius4/libsent/src/dfa/cpair.c diff -u julius4/libsent/src/dfa/cpair.c:1.2 julius4/libsent/src/dfa/cpair.c:1.3 --- julius4/libsent/src/dfa/cpair.c:1.2 Tue Dec 18 17:45:51 2007 +++ julius4/libsent/src/dfa/cpair.c Mon Jul 21 14:21:17 2008 @@ -18,7 +18,7 @@ * @author Akinobu LEE * @date Tue Feb 15 13:54:44 2005 * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * */ /* @@ -31,10 +31,52 @@ #include #include -/// Bit mask to access category-pair matrix -static unsigned char cp_table[] = { - 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80 -}; +/** + * Search for a terminal ID in a cp list. Set its location to loc. + * When not found, the location where to insert the key data iwill be set. + * + * @param list [in] cp list + * @param len [in] length of list + * @param key [in] a terminal ID value to find + * @param loc [out] return the to-be-inserted location of the key + * + * @return its location when found, or -1 when not found. + * + */ +static int +cp_find(int *list, int len, int key, int *loc) +{ + int left, right, mid; + int ret; + + if (len == 0) { + *loc = 0; + return -1; + } + + left = 0; + right = len - 1; + while (left < right) { + mid = (left + right) / 2; + if (list[mid] < key) { + left = mid + 1; + } else { + right = mid; + } + } + if (list[left] == key) { + *loc = left; + ret = left; + } else { + ret = -1; + if (list[left] > key) { + *loc = left; + } else { + *loc = left + 1; + } + } + return ret; +} /** * Return whether the given two category can be connected or not. @@ -48,8 +90,11 @@ boolean dfa_cp(DFA_INFO *dfa, int i, int j) { + int loc; + /*return(dfa->cp[i][j]);*/ - return((dfa->cp[i][j>>3] & cp_table[j&7]) ? TRUE : FALSE); + //return((dfa->cp[i][j>>3] & cp_table[j&7]) ? TRUE : FALSE); + return(cp_find(dfa->cp[i], dfa->cplen[i], j, &loc) != -1 ? TRUE : FALSE); } /** @@ -63,8 +108,10 @@ boolean dfa_cp_begin(DFA_INFO *dfa, int i) { + int loc; /*return(dfa->cp_begin[i]);*/ - return((dfa->cp_begin[i>>3] & cp_table[i&7]) ? TRUE : FALSE); + //return((dfa->cp_begin[i>>3] & cp_table[i&7]) ? TRUE : FALSE); + return(cp_find(dfa->cp_begin, dfa->cp_begin_len, i, &loc) != -1 ? TRUE : FALSE); } /** @@ -78,12 +125,71 @@ boolean dfa_cp_end(DFA_INFO *dfa, int i) { + int loc; /*return(dfa->cp_end[i]);*/ - return((dfa->cp_end[i>>3] & cp_table[i&7]) ? TRUE : FALSE); + //return((dfa->cp_end[i>>3] & cp_table[i&7]) ? TRUE : FALSE); + return(cp_find(dfa->cp_end, dfa->cp_end_len, i, &loc) != -1 ? TRUE : FALSE); +} + +/** + * Add an terminal ID to a specified location in the cp list. + * + * @param list [i/o] cp list + * @param len [i/o] data num in the list + * @param alloclen [i/o] allocated length of the list + * @param val [in] value to be added + * @param loc [in] location where to add the val + * + * @return TRUE on success, FALSE on failure. + * + */ +static boolean +cp_add(int **list, int *len, int *alloclen, int val, int loc) +{ + if (loc > *len) { + jlog("InternalError: skip?\n"); + return FALSE; + } + if (*len + 1 > *alloclen) { + /* expand cplist if necessary */ + *alloclen *= 2; + *list = (int *)myrealloc(*list, sizeof(int) * (*alloclen)); + } + if (loc < *len) { + memmove(&((*list)[loc+1]), &((*list)[loc]), sizeof(int) * (*len - loc)); + } + (*list)[loc] = val; + (*len)++; + return TRUE; } /** - * Set the category-pair matrix bit + * Remove an element from the cp list. + * + * @param list [i/o] cp list + * @param len [i/o] data num in the list + * @param loc [in] location of removing value + * + * @return TRUE on success, FALSE on error. + * + */static boolean +cp_remove(int **list, int *len, int loc) +{ + if (*len == 0) return TRUE; + if (loc >= *len) { + jlog("InternalError: skip?\n"); + return FALSE; + } + if (loc < *len - 1) { + memmove(&((*list)[loc]), &((*list)[loc+1]), sizeof(int) * (*len - loc - 1)); + } + (*len) --; + return TRUE; +} + + +/** + * Set a category-pair matrix bit. * * @param dfa [out] DFA grammar holding category pair matrix * @param i [in] category id of left word @@ -93,16 +199,22 @@ void set_dfa_cp(DFA_INFO *dfa, int i, int j, boolean value) { - /*dfa->cp[i][j] = value;*/ + int loc; if (value) { - dfa->cp[i][j>>3] |= cp_table[j&7]; + /* add j to cp list of i */ + if (cp_find(dfa->cp[i], dfa->cplen[i], j, &loc) == -1) { /* not exist */ + cp_add(&(dfa->cp[i]), &(dfa->cplen[i]), &(dfa->cpalloclen[i]), j, loc); + } } else { - dfa->cp[i][j>>3] &= ~ cp_table[j&7]; + /* remove j from cp list of i */ + if (cp_find(dfa->cp[i], dfa->cplen[i], j, &loc) != -1) { /* already exist */ + cp_remove(&(dfa->cp[i]), &(dfa->cplen[i]), loc); + } } } /** - * Set the category-pair matrix bit at the beginning of sentence + * Set a category-pair matrix bit for the beginning of sentence * * @param dfa [out] DFA grammar holding category pair matrix * @param i [in] category id of the word @@ -112,16 +224,23 @@ void set_dfa_cp_begin(DFA_INFO *dfa, int i, boolean value) { - /*dfa->cp_begin[i] = value;*/ + int loc; + if (value) { - dfa->cp_begin[i>>3] |= cp_table[i&7]; + /* add j to cp list of i */ + if (cp_find(dfa->cp_begin, dfa->cp_begin_len, i, &loc) == -1) { /* not exist */ + cp_add(&(dfa->cp_begin), &(dfa->cp_begin_len), &(dfa->cp_begin_alloclen), i, loc); + } } else { - dfa->cp_begin[i>>3] &= ~ cp_table[i&7]; + /* remove j from cp list of i */ + if (cp_find(dfa->cp_begin, dfa->cp_begin_len, i, &loc) != -1) { /* already exist */ + cp_remove(&(dfa->cp_begin), &(dfa->cp_begin_len), loc); + } } } /** - * Set the category-pair matrix bit at the end of sentence + * Set a category-pair matrix bit for the end of sentence * * @param dfa [out] DFA grammar holding category pair matrix * @param i [in] category id of the word @@ -131,11 +250,18 @@ void set_dfa_cp_end(DFA_INFO *dfa, int i, boolean value) { - /*dfa->cp_end[i] = value;*/ + int loc; + if (value) { - dfa->cp_end[i>>3] |= cp_table[i&7]; + /* add j to cp list of i */ + if (cp_find(dfa->cp_end, dfa->cp_end_len, i, &loc) == -1) { /* not exist */ + cp_add(&(dfa->cp_end), &(dfa->cp_end_len), &(dfa->cp_end_alloclen), i, loc); + } } else { - dfa->cp_end[i>>3] &= ~ cp_table[i&7]; + /* remove j from cp list of i */ + if (cp_find(dfa->cp_end, dfa->cp_end_len, i, &loc) != -1) { /* already exist */ + cp_remove(&(dfa->cp_end), &(dfa->cp_end_len), loc); + } } } @@ -147,10 +273,7 @@ void init_dfa_cp(DFA_INFO *dfa) { - dfa->cp_root = NULL; dfa->cp = NULL; - dfa->cp_begin = NULL; - dfa->cp_end = NULL; } /** @@ -158,92 +281,111 @@ * * @param dfa [out] DFA grammar to hold category pair matrix * @param term_num [in] number of categories in the grammar + * @param size [in] memory allocation length for each cp list as initial */ void -malloc_dfa_cp(DFA_INFO *dfa, int term_num) +malloc_dfa_cp(DFA_INFO *dfa, int term_num, int size) { int i, j, x; + int maxlen; - x = (term_num + 7) >> 3; - dfa->cp_root = (unsigned char *)mymalloc(sizeof(unsigned char) * term_num * x); - dfa->cp = (unsigned char **)mymalloc(sizeof(unsigned char *) * term_num); - for(i=0;icp[i] = &(dfa->cp_root[x*i]); - for(j=0;jcp_begin = (unsigned char *)mymalloc(sizeof(unsigned char) * x); - dfa->cp_end = (unsigned char *)mymalloc(sizeof(unsigned char) * x); + dfa->cp = (int **)mymalloc(sizeof(int *) * term_num); + dfa->cplen = (int *)mymalloc(sizeof(int) * term_num); + dfa->cpalloclen = (int *)mymalloc(sizeof(int) * term_num); for(i=0;iterm_num = term_num; + dfa->cp[i] = (int *)mymalloc(sizeof(int) * size); + dfa->cpalloclen[i] = size; + dfa->cplen[i] = 0; + } + dfa->cp_begin = (int *)mymalloc(sizeof(int) * size); + dfa->cp_begin_alloclen = size; + dfa->cp_begin_len = 0; + dfa->cp_end = (int *)mymalloc(sizeof(int) * size); + dfa->cp_end_alloclen = size; + dfa->cp_end_len = 0; } /** - * Re-allocate memory for category pair matrix, can be called when - * the number of category is expanded. - * - * @param dfa [I/O] DFA grammar holding category pair matrix - * @param old_term_num [in] number of categories when the last category pair matrix was allocated - * @param new_term_num [in] new number of categories in the grammar + * Append a categori-pair matrix to another. + * This function assumes that other grammar information has been already + * appended and dfa->term_num contains the new size. + * + * @param dfa [i/o] DFA grammar to which the new category pair will be appended + * @param src [in] source DFA + * @param offset [in] appending point at dfa + * + * @return TRUE on success, FALSE on error. */ -void -realloc_dfa_cp(DFA_INFO *dfa, int old_term_num, int new_term_num) +boolean +dfa_cp_append(DFA_INFO *dfa, DFA_INFO *src, int offset) { - int i, j, n, x, old_x; - unsigned char *oldroot, *oldbegin, *oldend; - unsigned char **oldcp; + int i, j, size; if (dfa->cp == NULL) { - malloc_dfa_cp(dfa, new_term_num); - return; + /* no category pair information exist on target */ + if (dfa->term_num != src->term_num) { + jlog("InternalError: dfa_cp_append\n"); + return FALSE; + } + /* just malloc and copy */ + dfa->cp = (int **)mymalloc(sizeof(int *) * dfa->term_num); + dfa->cplen = (int *)mymalloc(sizeof(int) * dfa->term_num); + dfa->cpalloclen = (int *)mymalloc(sizeof(int) * dfa->term_num); + for(i=0;iterm_num;i++) { + size = src->cplen[i]; + if (size < DFA_CP_MINSTEP) size = DFA_CP_MINSTEP; + dfa->cp[i] = (int *)mymalloc(sizeof(int) * size); + dfa->cpalloclen[i] = size; + memcpy(dfa->cp[i], src->cp[i], sizeof(int) * src->cplen[i]); + dfa->cplen[i] = src->cplen[i]; + } + size = src->cp_begin_len; + if (size < DFA_CP_MINSTEP) size = DFA_CP_MINSTEP; + dfa->cp_begin = (int *)mymalloc(sizeof(int) * size); + dfa->cp_begin_alloclen = size; + memcpy(dfa->cp_begin, src->cp_begin, sizeof(int) * src->cp_begin_len); + dfa->cp_begin_len = src->cp_begin_len; + size = src->cp_end_len; + if (size < DFA_CP_MINSTEP) size = DFA_CP_MINSTEP; + dfa->cp_end = (int *)mymalloc(sizeof(int) * size); + dfa->cp_end_alloclen = size; + memcpy(dfa->cp_end, src->cp_end, sizeof(int) * src->cp_end_len); + dfa->cp_end_len = src->cp_end_len; + return TRUE; + } + /* expand index */ + dfa->cp = (int **)myrealloc(dfa->cp, sizeof(int *) * dfa->term_num); + dfa->cplen = (int *)myrealloc(dfa->cplen, sizeof(int) * dfa->term_num); + dfa->cpalloclen = (int *)myrealloc(dfa->cpalloclen, sizeof(int) * dfa->term_num); + /* copy src->cp[i][j] to target->cp[i+offset][j+offset] */ + for(i=offset;iterm_num;i++) { + size = src->cplen[i-offset]; + if (size < DFA_CP_MINSTEP) size = DFA_CP_MINSTEP; + dfa->cp[i] = (int *)mymalloc(sizeof(int) * size); + dfa->cpalloclen[i] = size; + for(j=0;jcplen[i-offset];j++) { + dfa->cp[i][j] = src->cp[i-offset][j] + offset; + } + dfa->cplen[i] = src->cplen[i-offset]; } - - x = (new_term_num + 7) >> 3; - old_x = (old_term_num + 7) >> 3; - - oldroot = dfa->cp_root; - oldcp = dfa->cp; - - dfa->cp_root = (unsigned char *)mymalloc(sizeof(unsigned char) * new_term_num * x); - dfa->cp = (unsigned char **)mymalloc(sizeof(unsigned char *) * new_term_num); - for(i=0;icp[i] = &(dfa->cp_root[x*i]); - } - for(i=0;icp[i][n] = oldcp[i][n]; - } - } - for(i=old_term_num;icp_begin; - oldend = dfa->cp_end; - dfa->cp_begin = (unsigned char *)mymalloc(sizeof(unsigned char) * x); - dfa->cp_end = (unsigned char *)mymalloc(sizeof(unsigned char) * x); - for(n=0;ncp_begin[n] = oldbegin[n]; - dfa->cp_end[n] = oldend[n]; - } - for(i=old_term_num;icp_begin_alloclen < dfa->cp_begin_len + src->cp_begin_len) { + dfa->cp_begin_alloclen = dfa->cp_begin_len + src->cp_begin_len; + dfa->cp_begin = (int *)myrealloc(dfa->cp_begin, sizeof(int) * dfa->cp_begin_alloclen); + } + for(j=0;jcp_begin_len;j++) { + dfa->cp_begin[dfa->cp_begin_len + j] = src->cp_begin[j] + offset; + } + dfa->cp_begin_len += src->cp_begin_len; + if (dfa->cp_end_alloclen < dfa->cp_end_len + src->cp_end_len) { + dfa->cp_end_alloclen = dfa->cp_end_len + src->cp_end_len; + dfa->cp_end = (int *)myrealloc(dfa->cp_end, sizeof(int) * dfa->cp_end_alloclen); + } + for(j=0;jcp_end_len;j++) { + dfa->cp_end[dfa->cp_end_len + j] = src->cp_end[j] + offset; } - free(oldbegin); - free(oldend); + dfa->cp_end_len += src->cp_end_len; - dfa->term_num = new_term_num; + return TRUE; } /** @@ -254,10 +396,62 @@ void free_dfa_cp(DFA_INFO *dfa) { + int i; + if (dfa->cp != NULL) { - free(dfa->cp_begin); free(dfa->cp_end); + free(dfa->cp_begin); + for(i=0;iterm_num;i++) free(dfa->cp[i]); + free(dfa->cpalloclen); + free(dfa->cplen); free(dfa->cp); - free(dfa->cp_root); + dfa->cp = NULL; + } +} + +void +dfa_cp_output_rawdata(FILE *fp, DFA_INFO *dfa) +{ + int i, j; + + for(i=0;iterm_num;i++) { + fprintf(fp, "%d:", i); + for(j=0;jcplen[i];j++) { + fprintf(fp, " %d", dfa->cp[i][j]); + } + fprintf(fp, "\n"); + } + fprintf(fp, "bgn:", i); + for(j=0;jcp_begin_len;j++) { + fprintf(fp, " %d", dfa->cp_begin[j]); + } + fprintf(fp, "\n"); + fprintf(fp, "end:", i); + for(j=0;jcp_end_len;j++) { + fprintf(fp, " %d", dfa->cp_end[j]); } + fprintf(fp, "\n"); +} + +void +dfa_cp_count_size(DFA_INFO *dfa, unsigned long *size_ret, unsigned long *allocsize_ret) +{ + int i; + unsigned long size, allocsize; + + size = 0; + allocsize = 0; + for(i=0;iterm_num;i++) { + size += sizeof(int) * dfa->cplen[i]; + allocsize += sizeof(int) * dfa->cpalloclen[i]; + } + size += sizeof(int) * dfa->cp_begin_len; + allocsize += sizeof(int) * dfa->cp_begin_alloclen; + size += sizeof(int) * dfa->cp_end_len; + allocsize += sizeof(int) * dfa->cp_end_alloclen; + + allocsize += (sizeof(int *) + sizeof(int) + sizeof(int)) * dfa->term_num; + + *size_ret = size; + *allocsize_ret = allocsize; } Index: julius4/libsent/src/dfa/dfa_util.c diff -u julius4/libsent/src/dfa/dfa_util.c:1.2 julius4/libsent/src/dfa/dfa_util.c:1.3 --- julius4/libsent/src/dfa/dfa_util.c:1.2 Tue Dec 18 17:45:51 2007 +++ julius4/libsent/src/dfa/dfa_util.c Mon Jul 21 14:21:17 2008 @@ -12,7 +12,7 @@ * @author Akinobu LEE * @date Tue Feb 15 14:18:36 2005 * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * */ /* @@ -34,12 +34,14 @@ void print_dfa_info(FILE *fp, DFA_INFO *dinfo) { + unsigned long size, allocsize; if (fp == NULL) return; fprintf(fp, " DFA grammar info:\n"); fprintf(fp, " %d nodes, %d arcs, %d terminal(category) symbols\n", dinfo->state_num, dinfo->arc_num, dinfo->term_num); - fprintf(fp, " size of category-pair matrix is %d bytes\n", - sizeof(unsigned char) * dinfo->term_num * dinfo->term_num / 8); + + dfa_cp_count_size(dinfo, &size, &allocsize); + fprintf(fp, " category-pair matrix: %ld bytes (%d bytes allocated)\n", size, allocsize); } /** @@ -56,37 +58,5 @@ if (fp == NULL) return; fprintf(fp, "---------- terminal(category)-pair matrix ----------\n"); - /* horizontal ruler */ - fprintf(fp, " "); - for (j=0;jterm_num;j++) { - if (j > 0 && (j % 10) == 0) { - t = j / 10; - fprintf(fp, "%1d", t); - } else { - fprintf(fp, " "); - } - } - fprintf(fp, "\n "); - for (j=0;jterm_num;j++) { - fprintf(fp, "%1d", j % 10); - } - fprintf(fp, "\n"); - - fprintf(fp, "bgn "); - for (j=0;jterm_num;j++) { - fprintf(fp, (dfa_cp_begin(dinfo, j) == TRUE) ? "o" : " "); - } - fprintf(fp, "\n"); - fprintf(fp, "end "); - for (j=0;jterm_num;j++) { - fprintf(fp, (dfa_cp_end(dinfo, j) == TRUE) ? "o" : " "); - } - fprintf(fp, "\n"); - for (i=0;iterm_num;i++) { - fprintf(fp, "%3d ",i); - for (j=0;jterm_num;j++) { - fprintf(fp, (dfa_cp(dinfo, i, j) == TRUE) ? "o" : " "); - } - fprintf(fp, "\n"); - } + dfa_cp_output_rawdata(fp, dinfo); } Index: julius4/libsent/src/dfa/mkcpair.c diff -u julius4/libsent/src/dfa/mkcpair.c:1.2 julius4/libsent/src/dfa/mkcpair.c:1.3 --- julius4/libsent/src/dfa/mkcpair.c:1.2 Tue Dec 18 17:45:51 2007 +++ julius4/libsent/src/dfa/mkcpair.c Mon Jul 21 14:21:17 2008 @@ -38,7 +38,7 @@ * @author Akinobu LEE * @date Tue Feb 15 14:35:33 2005 * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * */ /* @@ -63,9 +63,13 @@ int i; DFA_ARC *arc_l, *arc_r, *arc_r2; int left, right; + int size; /* initialize */ - malloc_dfa_cp(dinfo, dinfo->term_num); + /* initial size = average fun-out num per state */ + size = dinfo->arc_num / dinfo->state_num; + if (size < DFA_CP_MINSTEP) size = DFA_CP_MINSTEP; + malloc_dfa_cp(dinfo, dinfo->term_num, size); /* extract cpair info */ for (i=0;istate_num;i++) { @@ -129,16 +133,7 @@ } /* allocate appended area */ - realloc_dfa_cp(dst, coffset, dst->term_num); - - /* append cp */ - for(i=coffset;iterm_num;i++) { - for(j=coffset;jterm_num;j++) { - set_dfa_cp(dst, i, j, dfa_cp(src, i-coffset, j-coffset)); - } - set_dfa_cp_begin(dst, i, dfa_cp_begin(src, i-coffset)); - set_dfa_cp_end(dst, i, dfa_cp_end(src, i-coffset)); - } + if (dfa_cp_append(dst, src, coffset) == FALSE) return FALSE; return TRUE; } From sumomo @ users.sourceforge.jp Thu Jul 24 18:18:09 2008 From: sumomo @ users.sourceforge.jp (sumomo @ users.sourceforge.jp) Date: Thu, 24 Jul 2008 18:18:09 +0900 Subject: [Julius-cvs 210] CVS update: julius4/libjulius/src Message-ID: <1216891089.907605.23982.nullmailer@users.sourceforge.jp> Index: julius4/libjulius/src/m_fusion.c diff -u julius4/libjulius/src/m_fusion.c:1.7 julius4/libjulius/src/m_fusion.c:1.8 --- julius4/libjulius/src/m_fusion.c:1.7 Sun Jul 20 01:52:33 2008 +++ julius4/libjulius/src/m_fusion.c Thu Jul 24 18:18:09 2008 @@ -20,7 +20,7 @@ * @author Akinobu Lee * @date Thu May 12 13:31:47 2005 * - * $Revision: 1.7 $ + * $Revision: 1.8 $ * */ /* @@ -474,11 +474,11 @@ if (am->config->gprune_method == GPRUNE_SEL_UNDEF) {/* set default if not specified */ if (am->hmminfo->is_tied_mixture) { /* enabled by default for tied-mixture models */ -#ifdef GPRUNE_DEFAULT_SAFE +#if defined(GPRUNE_DEFAULT_SAFE) am->config->gprune_method = GPRUNE_SEL_SAFE; -#elif GPRUNE_DEFAULT_HEURISTIC +#elif defined(GPRUNE_DEFAULT_HEURISTIC) am->config->gprune_method = GPRUNE_SEL_HEURISTIC; -#elif GPRUNE_DEFAULT_BEAM +#elif defined(GPRUNE_DEFAULT_BEAM) am->config->gprune_method = GPRUNE_SEL_BEAM; #endif } else { From sumomo @ users.sourceforge.jp Thu Jul 24 18:18:10 2008 From: sumomo @ users.sourceforge.jp (sumomo @ users.sourceforge.jp) Date: Thu, 24 Jul 2008 18:18:10 +0900 Subject: [Julius-cvs 211] CVS update: julius4/libsent/src/adin Message-ID: <1216891090.100030.23997.nullmailer@users.sourceforge.jp> Index: julius4/libsent/src/adin/adin_mic_freebsd.c diff -u julius4/libsent/src/adin/adin_mic_freebsd.c:1.3 julius4/libsent/src/adin/adin_mic_freebsd.c:1.4 --- julius4/libsent/src/adin/adin_mic_freebsd.c:1.3 Tue Dec 18 17:45:50 2007 +++ julius4/libsent/src/adin/adin_mic_freebsd.c Thu Jul 24 18:18:09 2008 @@ -39,7 +39,7 @@ * @author Akinobu LEE * @date Sun Feb 13 16:18:26 2005 * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * */ /* @@ -62,9 +62,9 @@ #include /* sound header */ -#ifdef HAVE_SYS_SOUNDCARD_H +#if defined(HAVE_SYS_SOUNDCARD_H) #include -#elif HAVE_MACHINE_SOUNDCARD_H +#elif defined(HAVE_MACHINE_SOUNDCARD_H) #include #endif Index: julius4/libsent/src/adin/adin_mic_linux.c diff -u julius4/libsent/src/adin/adin_mic_linux.c:1.1 julius4/libsent/src/adin/adin_mic_linux.c:1.2 --- julius4/libsent/src/adin/adin_mic_linux.c:1.1 Tue Jul 1 22:44:09 2008 +++ julius4/libsent/src/adin/adin_mic_linux.c Thu Jul 24 18:18:09 2008 @@ -20,7 +20,7 @@ * @author Akinobu LEE * @date Sun Feb 13 16:18:26 2005 * - * $Revision: 1.1 $ + * $Revision: 1.2 $ * */ /* @@ -44,11 +44,11 @@ boolean adin_mic_standby(int sfreq, void *dummy) { -#ifdef HAS_ALSA +#if defined(HAS_ALSA) return(adin_alsa_standby(sfreq, dummy)); -#elif HAS_OSS +#elif defined(HAS_OSS) return(adin_oss_standby(sfreq, dummy)); -#elif HAS_ESD +#elif defined(HAS_ESD) return(adin_esd_standby(sfreq, dummy)); #else /* other than Linux */ jlog("Error: neither of alsa/oss/esd device is available\n"); @@ -64,11 +64,11 @@ boolean adin_mic_begin() { -#ifdef HAS_ALSA +#if defined(HAS_ALSA) return(adin_alsa_begin()); -#elif HAS_OSS +#elif defined(HAS_OSS) return(adin_oss_begin()); -#elif HAS_ESD +#elif defined(HAS_ESD) return(adin_esd_begin()); #else /* other than Linux */ jlog("Error: neither of alsa/oss/esd device is available\n"); @@ -84,11 +84,11 @@ boolean adin_mic_end() { -#ifdef HAS_ALSA +#if defined(HAS_ALSA) return(adin_alsa_end()); -#elif HAS_OSS +#elif defined(HAS_OSS) return(adin_oss_end()); -#elif HAS_ESD +#elif defined(HAS_ESD) return(adin_esd_end()); #else /* other than Linux */ jlog("Error: neither of alsa/oss/esd device is available\n"); @@ -111,11 +111,11 @@ int adin_mic_read(SP16 *buf, int sampnum) { -#ifdef HAS_ALSA +#if defined(HAS_ALSA) return(adin_alsa_read(buf, sampnum)); -#elif HAS_OSS +#elif defined(HAS_OSS) return(adin_oss_read(buf, sampnum)); -#elif HAS_ESD +#elif defined(HAS_ESD) return(adin_esd_read(buf, sampnum)); #else /* other than Linux */ jlog("Error: neither of alsa/oss/esd device is available\n"); Index: julius4/libsent/src/adin/adin_mic_linux_alsa.c diff -u julius4/libsent/src/adin/adin_mic_linux_alsa.c:1.6 julius4/libsent/src/adin/adin_mic_linux_alsa.c:1.7 --- julius4/libsent/src/adin/adin_mic_linux_alsa.c:1.6 Tue Jul 1 13:29:46 2008 +++ julius4/libsent/src/adin/adin_mic_linux_alsa.c Thu Jul 24 18:18:09 2008 @@ -44,7 +44,7 @@ * @author Akinobu LEE * @date Sun Feb 13 16:18:26 2005 * - * $Revision: 1.6 $ + * $Revision: 1.7 $ * */ /* @@ -63,9 +63,9 @@ #ifdef HAS_ALSA -#ifdef HAVE_ALSA_ASOUNDLIB_H +#if defined(HAVE_ALSA_ASOUNDLIB_H) #include -#elif HAVE_SYS_ASOUNDLIB_H +#elif defined(HAVE_SYS_ASOUNDLIB_H) #include #endif Index: julius4/libsent/src/adin/adin_mic_linux_oss.c diff -u julius4/libsent/src/adin/adin_mic_linux_oss.c:1.4 julius4/libsent/src/adin/adin_mic_linux_oss.c:1.5 --- julius4/libsent/src/adin/adin_mic_linux_oss.c:1.4 Tue Jul 1 13:29:46 2008 +++ julius4/libsent/src/adin/adin_mic_linux_oss.c Thu Jul 24 18:18:09 2008 @@ -51,7 +51,7 @@ * @author Akinobu LEE * @date Sun Feb 13 16:18:26 2005 * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * */ /* @@ -72,9 +72,9 @@ /* sound header */ #ifdef HAS_OSS -#ifdef HAVE_SYS_SOUNDCARD_H +#if defined(HAVE_SYS_SOUNDCARD_H) #include -#elif HAVE_MACHINE_SOUNDCARD_H +#elif defined(HAVE_MACHINE_SOUNDCARD_H) #include #endif #endif From sumomo @ users.sourceforge.jp Thu Jul 31 16:49:14 2008 From: sumomo @ users.sourceforge.jp (sumomo @ users.sourceforge.jp) Date: Thu, 31 Jul 2008 16:49:14 +0900 Subject: [Julius-cvs 212] CVS update: julius4/gramtools/generate Message-ID: <1217490554.308922.21024.nullmailer@users.sourceforge.jp> Index: julius4/gramtools/generate/generate.c diff -u julius4/gramtools/generate/generate.c:1.2 julius4/gramtools/generate/generate.c:1.3 --- julius4/gramtools/generate/generate.c:1.2 Tue Dec 18 17:45:47 2007 +++ julius4/gramtools/generate/generate.c Thu Jul 31 16:49:14 2008 @@ -172,14 +172,13 @@ int main(int argc, char *argv[]) { int i, len; - char *prefix; + char *prefix = NULL; char *dfafile, *dictfile, *termfile; int gnum = 10; char *spname_default = SPNAME_DEF; char *spname = NULL; #define NEXTARG (++i >= argc) ? (char *)usage(argv[0]) : argv[i] - if (argc == 1) usage(argv[0]); /* argument */ for(i=1;i