From sumomo @ users.sourceforge.jp Tue Sep 16 12:52:20 2008 From: sumomo @ users.sourceforge.jp (sumomo @ users.sourceforge.jp) Date: Tue, 16 Sep 2008 12:52:20 +0900 Subject: [Julius-cvs 225] CVS update: julius4/jclient-perl Message-ID: <1221537140.596425.24348.nullmailer@users.sourceforge.jp> From sumomo @ users.sourceforge.jp Tue Sep 16 12:55:48 2008 From: sumomo @ users.sourceforge.jp (sumomo @ users.sourceforge.jp) Date: Tue, 16 Sep 2008 12:55:48 +0900 Subject: [Julius-cvs 226] CVS update: julius4/jclient-perl Message-ID: <1221537348.285522.26386.nullmailer@users.sourceforge.jp> Index: julius4/jclient-perl/00readme-ja.txt diff -u /dev/null julius4/jclient-perl/00readme-ja.txt:1.1 --- /dev/null Tue Sep 16 12:55:48 2008 +++ julius4/jclient-perl/00readme-ja.txt Tue Sep 16 12:55:48 2008 @@ -0,0 +1,21 @@ +jclient.pl +============ + +Julius ?????????????? "jcontrol" ? Perl ???? +???????????????? Julius ???ッ?????????? +Julius ??????????? + +??? 57 ?????????????????????? Julius ???? +???????????????ゥ?????????? + +--- + +jclient.pl ? ???? ?? (nisimura @ sys.wakayama-u.ac.jp) ????? +????????????????????????メ??????????+???ゥ??????????????? + +??????????????????????????????? +?L???????????????????????????? + + http://w3voice.jp/ + Index: julius4/jclient-perl/00readme.txt diff -u /dev/null julius4/jclient-perl/00readme.txt:1.1 --- /dev/null Tue Sep 16 12:55:48 2008 +++ julius4/jclient-perl/00readme.txt Tue Sep 16 12:55:48 2008 @@ -0,0 +1,19 @@ +jclient.pl +============ + +This is a perl version of "jcontrol". +You can receive recognition result from Julius running in module mode, +or send command to Julius. + +You can use this tiny program for free. + +--- + +"jclient.pl" has been developed by Dr. Ryuichi Nisimura +(nisimura @ sys.wakayama-u.ac.jp). Use at your own risk. + +If you have any feedback, comment or request, please contact the +E-mail address above, or look at the Web page below. + + http://w3voice.jp/ + Index: julius4/jclient-perl/jclient.pl diff -u /dev/null julius4/jclient-perl/jclient.pl:1.1 --- /dev/null Tue Sep 16 12:55:48 2008 +++ julius4/jclient-perl/jclient.pl Tue Sep 16 12:55:48 2008 @@ -0,0 +1,57 @@ +#! /usr/bin/perl +use strict; +use IO::Socket; +use IO::Select; + +my $host = "localhost"; +my $port = 10500; + +print STDERR "$host($port) に接続します\n"; + +# Socketを生成して接続 +my $socket; +while(!$socket){ + $socket = IO::Socket::INET->new(PeerAddr => $host, + PeerPort => $port, + Proto => 'tcp', + ); + if (!$socket){ + printf STDERR "$host($port) の接続に失敗しました\n"; + printf STDERR "再接続を試みます\n"; + sleep 10; + } +} + +print STDERR "$host($port) に接続しました\n"; + +# バッファリングをしない +$| = 1; +my($old) = select($socket); $| = 1; select($old); + +# Selecterを生成 +my $selecter = IO::Select->new; +$selecter->add($socket); +$selecter->add(\*STDIN); + +# 入力待ち +while(1){ + my ($active_socks) = IO::Select->select($selecter, undef, undef, undef); + + foreach my $sock (@{$active_socks}){ + # Juliusからの出力を表示 + if ($sock == $socket){ + while(<$socket>){ + print; + last if(/^\./); + } + # 標準入力をJuliusに送信 + }else{ + my $input = ; + # 小文字を大文字に変換 + $input =~ tr/a-z/A-Z/d; + + print $socket $input; + } + } +} + From sumomo @ users.sourceforge.jp Thu Sep 25 01:17:17 2008 From: sumomo @ users.sourceforge.jp (sumomo @ users.sourceforge.jp) Date: Thu, 25 Sep 2008 01:17:17 +0900 Subject: [Julius-cvs 227] CVS update: julius4/libjulius/include/julius Message-ID: <1222273037.328562.27065.nullmailer@users.sourceforge.jp> Index: julius4/libjulius/include/julius/jconf.h diff -u julius4/libjulius/include/julius/jconf.h:1.4 julius4/libjulius/include/julius/jconf.h:1.5 --- julius4/libjulius/include/julius/jconf.h:1.4 Tue Jul 1 13:29:45 2008 +++ julius4/libjulius/include/julius/jconf.h Thu Sep 25 01:17:17 2008 @@ -23,7 +23,7 @@ * @author Akinobu Lee * @date Fri Feb 16 13:42:28 2007 * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * */ /* @@ -997,8 +997,29 @@ */ JCONF_AM *gmm; + /** + * Current option declaration mode while loading options + * + */ + short optsection; + + /** + * Whether option sectioning ristriction should be applied or not + * + */ + boolean optsectioning; + + } Jconf; +enum { + JCONF_OPT_GLOBAL, + JCONF_OPT_AM, + JCONF_OPT_LM, + JCONF_OPT_SR, + SIZEOF_JCONF_OPT +}; + #endif /* __J_JCONF_H__ */ /* From sumomo @ users.sourceforge.jp Thu Sep 25 01:17:17 2008 From: sumomo @ users.sourceforge.jp (sumomo @ users.sourceforge.jp) Date: Thu, 25 Sep 2008 01:17:17 +0900 Subject: [Julius-cvs 228] CVS update: julius4/libjulius/src Message-ID: <1222273037.578680.27077.nullmailer@users.sourceforge.jp> Index: julius4/libjulius/src/default.c diff -u julius4/libjulius/src/default.c:1.5 julius4/libjulius/src/default.c:1.6 --- julius4/libjulius/src/default.c:1.5 Tue Jul 1 13:29:45 2008 +++ julius4/libjulius/src/default.c Thu Sep 25 01:17:17 2008 @@ -17,7 +17,7 @@ * @author Akinobu Lee * @date Fri Feb 16 15:05:43 2007 * - * $Revision: 1.5 $ + * $Revision: 1.6 $ * */ /* @@ -95,6 +95,9 @@ j->decodeopt.forced_realtime = FALSE; j->decodeopt.force_realtime_flag = FALSE; j->decodeopt.segment = FALSE; + + j->optsection = JCONF_OPT_GLOBAL; + j->optsectioning = TRUE; } /** Index: julius4/libjulius/src/m_options.c diff -u julius4/libjulius/src/m_options.c:1.12 julius4/libjulius/src/m_options.c:1.13 --- julius4/libjulius/src/m_options.c:1.12 Tue Aug 5 18:47:56 2008 +++ julius4/libjulius/src/m_options.c Thu Sep 25 01:17:17 2008 @@ -18,7 +18,7 @@ * @author Akinobu Lee * @date Thu May 12 18:52:07 2005 * - * $Revision: 1.12 $ + * $Revision: 1.13 $ * */ /* @@ -98,6 +98,37 @@ return(argv[*cur]); } +static boolean +check_section(Jconf *jconf, char *optname, short sec) +{ + if (! jconf->optsectioning) return TRUE; + + if (jconf->optsection == sec) return TRUE; + + if (jconf->optsection == JCONF_OPT_GLOBAL) return TRUE; + + switch(sec) { + case JCONF_OPT_GLOBAL: + jlog("ERROR: \"%s\" is global option (should be before any instance declaration)", optname); break; + case JCONF_OPT_AM: + jlog("ERROR: \"%s\" is AM option", optname); break; + case JCONF_OPT_LM: + jlog("ERROR: \"%s\" is LM option", optname); break; + case JCONF_OPT_SR: + jlog("ERROR: \"%s\" is SR (search) option", optname); break; + } + switch(jconf->optsection) { + case JCONF_OPT_AM: + jlog(", but exists at AM section (-AM \"%s\")\n", jconf->amnow->name); break; + case JCONF_OPT_LM: + jlog(", but exists at LM section (-LM \"%s\")\n", jconf->lmnow->name); break; + case JCONF_OPT_SR: + jlog(", but exists at recognizer section (-SR \"%s\")\n", jconf->searchnow->name); break; + } + jlog("ERROR: fix it, or you can disable this check by \"-nosectioncheck\"\n"); + return FALSE; +} + /** * * メモリ領域を解放し NULL で埋める. @@ -179,6 +210,7 @@ return FALSE; } jconf->amnow = amconf; + jconf->optsection = JCONF_OPT_AM; continue; } else if (strmatch(argv[i],"-AM_GMM") || strmatch(argv[i], "[AM_GMM]")) { /* switch current to GMM */ @@ -187,6 +219,7 @@ jconf->gmm = j_jconf_am_new(); } jconf->amnow = jconf->gmm; + jconf->optsection = JCONF_OPT_AM; continue; } else if (strmatch(argv[i],"-LM") || strmatch(argv[i], "[LM]")) { GET_TMPARG; @@ -208,6 +241,7 @@ return FALSE; } jconf->lmnow = lmconf; + jconf->optsection = JCONF_OPT_LM; continue; } else if (strmatch(argv[i],"-SR") || strmatch(argv[i], "[SR]")) { GET_TMPARG; @@ -254,8 +288,16 @@ return FALSE; } jconf->searchnow = sconf; + jconf->optsection = JCONF_OPT_SR; + continue; + } else if (strmatch(argv[i],"-sectioncheck")) { /* enable section check */ + jconf->optsectioning = TRUE; + continue; + } else if (strmatch(argv[i],"-nosectioncheck")) { /* disable section check */ + jconf->optsectioning = FALSE; continue; } else if (strmatch(argv[i],"-input")) { /* speech input */ + if (!check_section(jconf, argv[i], JCONF_OPT_GLOBAL)) return FALSE; GET_TMPARG; if (strmatch(tmparg,"file")) { jconf->input.speech_input = SP_RAWFILE; @@ -325,22 +367,26 @@ } continue; } else if (strmatch(argv[i],"-filelist")) { /* input file list */ - FREE_MEMORY(jconf->input.inputlist_filename); + if (!check_section(jconf, argv[i], JCONF_OPT_GLOBAL)) return FALSE; GET_TMPARG; + FREE_MEMORY(jconf->input.inputlist_filename); //jconf->input.inputlist_filename = strcpy((char*)mymalloc(strlen(tmparg)+1),tmparg); jconf->input.inputlist_filename = filepath(tmparg, cwd); continue; } else if (strmatch(argv[i],"-rejectshort")) { /* short input rejection */ + if (!check_section(jconf, argv[i], JCONF_OPT_GLOBAL)) return FALSE; GET_TMPARG; jconf->reject.rejectshortlen = atoi(tmparg); continue; #ifdef POWER_REJECT } else if (strmatch(argv[i],"-powerthres")) { /* short input rejection */ + if (!check_section(jconf, argv[i], JCONF_OPT_GLOBAL)) return FALSE; GET_TMPARG; jconf->reject.powerthres = atoi(tmparg); continue; #endif } else if (strmatch(argv[i],"-force_realtime")) { /* force realtime */ + if (!check_section(jconf, argv[i], JCONF_OPT_GLOBAL)) return FALSE; GET_TMPARG; if (strmatch(tmparg, "on")) { jconf->decodeopt.forced_realtime = TRUE; @@ -353,17 +399,21 @@ jconf->decodeopt.force_realtime_flag = TRUE; continue; } else if (strmatch(argv[i],"-realtime")) { /* equal to "-force_realtime on" */ + if (!check_section(jconf, argv[i], JCONF_OPT_GLOBAL)) return FALSE; jconf->decodeopt.forced_realtime = TRUE; jconf->decodeopt.force_realtime_flag = TRUE; continue; } else if (strmatch(argv[i], "-norealtime")) { /* equal to "-force_realtime off" */ + if (!check_section(jconf, argv[i], JCONF_OPT_GLOBAL)) return FALSE; jconf->decodeopt.forced_realtime = FALSE; jconf->decodeopt.force_realtime_flag = TRUE; continue; } else if (strmatch(argv[i],"-forcedict")) { /* skip dict error */ + if (!check_section(jconf, argv[i], JCONF_OPT_LM)) return FALSE; jconf->lmnow->forcedict_flag = TRUE; continue; } else if (strmatch(argv[i],"-check")) { /* interactive model check mode */ + if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE; GET_TMPARG; if (strmatch(tmparg, "wchmm")) { jconf->searchnow->sw.wchmm_check_flag = TRUE; @@ -377,10 +427,12 @@ } continue; } else if (strmatch(argv[i],"-notypecheck")) { /* don't check param type */ + if (!check_section(jconf, argv[i], JCONF_OPT_GLOBAL)) return FALSE; jconf->input.paramtype_check_flag = FALSE; continue; } else if (strmatch(argv[i],"-nlimit")) { /* limit N token in a node */ #ifdef WPAIR_KEEP_NLIMIT + if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE; GET_TMPARG; jconf->searchnow->pass1.wpair_keep_nlimit = atoi(tmparg); #else @@ -388,68 +440,84 @@ #endif continue; } else if (strmatch(argv[i],"-lookuprange")) { /* trellis neighbor range */ + if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE; GET_TMPARG; jconf->searchnow->pass2.lookup_range = atoi(tmparg); continue; } else if (strmatch(argv[i],"-graphout")) { /* enable graph output */ + if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE; jconf->searchnow->graph.enabled = TRUE; jconf->searchnow->graph.lattice = TRUE; jconf->searchnow->graph.confnet = FALSE; continue; } else if (strmatch(argv[i],"-lattice")) { /* enable graph output */ + if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE; jconf->searchnow->graph.enabled = TRUE; jconf->searchnow->graph.lattice = TRUE; continue; } else if (strmatch(argv[i],"-nolattice")) { /* disable graph output */ + if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE; jconf->searchnow->graph.enabled = FALSE; jconf->searchnow->graph.lattice = FALSE; continue; } else if (strmatch(argv[i],"-confnet")) { /* enable confusion network */ + if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE; jconf->searchnow->graph.enabled = TRUE; jconf->searchnow->graph.confnet = TRUE; continue; } else if (strmatch(argv[i],"-noconfnet")) { /* disable graph output */ + if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE; jconf->searchnow->graph.enabled = FALSE; jconf->searchnow->graph.confnet = FALSE; continue; } else if (strmatch(argv[i],"-graphrange")) { /* neighbor merge range frame */ + if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE; GET_TMPARG; jconf->searchnow->graph.graph_merge_neighbor_range = atoi(tmparg); continue; #ifdef GRAPHOUT_DEPTHCUT } else if (strmatch(argv[i],"-graphcut")) { /* cut graph word by depth */ + if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE; GET_TMPARG; jconf->searchnow->graph.graphout_cut_depth = atoi(tmparg); continue; #endif #ifdef GRAPHOUT_LIMIT_BOUNDARY_LOOP } else if (strmatch(argv[i],"-graphboundloop")) { /* neighbor merge range frame */ + if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE; GET_TMPARG; jconf->searchnow->graph.graphout_limit_boundary_loop_num = atoi(tmparg); continue; #endif #ifdef GRAPHOUT_SEARCH_DELAY_TERMINATION } else if (strmatch(argv[i],"-graphsearchdelay")) { /* not do graph search termination before the 1st sentence is found */ + if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE; jconf->searchnow->graph.graphout_search_delay = TRUE; continue; } else if (strmatch(argv[i],"-nographsearchdelay")) { /* not do graph search termination before the 1st sentence is found */ + if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE; jconf->searchnow->graph.graphout_search_delay = FALSE; continue; #endif } else if (strmatch(argv[i],"-looktrellis")) { /* activate loopuprange */ + if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE; jconf->searchnow->pass2.looktrellis_flag = TRUE; continue; } else if (strmatch(argv[i],"-multigramout")) { /* enable per-grammar decoding on 2nd pass */ + if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE; jconf->searchnow->output.multigramout_flag = TRUE; continue; } else if (strmatch(argv[i],"-nomultigramout")) { /* disable per-grammar decoding on 2nd pass */ + if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE; jconf->searchnow->output.multigramout_flag = FALSE; continue; } else if (strmatch(argv[i],"-oldtree")) { /* use old tree function */ + if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE; jconf->searchnow->pass1.old_tree_function_flag = TRUE; continue; } else if (strmatch(argv[i],"-sb")) { /* score envelope width in 2nd pass */ #ifdef SCAN_BEAM + if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE; GET_TMPARG; jconf->searchnow->pass2.scan_beam_thres = atof(tmparg); #else @@ -460,114 +528,144 @@ jlog("WARNING: m_options: option \"-discount\" is now bogus, ignored\n"); continue; } else if (strmatch(argv[i],"-cutsilence")) { /* force (long) silence detection on */ + if (!check_section(jconf, argv[i], JCONF_OPT_GLOBAL)) return FALSE; jconf->detect.silence_cut = 1; continue; } else if (strmatch(argv[i],"-nocutsilence")) { /* force (long) silence detection off */ + if (!check_section(jconf, argv[i], JCONF_OPT_GLOBAL)) return FALSE; jconf->detect.silence_cut = 0; continue; } else if (strmatch(argv[i],"-pausesegment")) { /* force (long) silence detection on (for backward compatibility) */ + if (!check_section(jconf, argv[i], JCONF_OPT_GLOBAL)) return FALSE; jconf->detect.silence_cut = 1; continue; } else if (strmatch(argv[i],"-nopausesegment")) { /* force (long) silence detection off (for backward comatibility) */ + if (!check_section(jconf, argv[i], JCONF_OPT_GLOBAL)) return FALSE; jconf->detect.silence_cut = 0; continue; } else if (strmatch(argv[i],"-lv")) { /* silence detection threshold level */ + if (!check_section(jconf, argv[i], JCONF_OPT_GLOBAL)) return FALSE; GET_TMPARG; jconf->detect.level_thres = atoi(tmparg); continue; } else if (strmatch(argv[i],"-zc")) { /* silence detection zero cross num */ + if (!check_section(jconf, argv[i], JCONF_OPT_GLOBAL)) return FALSE; GET_TMPARG; jconf->detect.zero_cross_num = atoi(tmparg); continue; } else if (strmatch(argv[i],"-headmargin")) { /* head silence length */ + if (!check_section(jconf, argv[i], JCONF_OPT_GLOBAL)) return FALSE; GET_TMPARG; jconf->detect.head_margin_msec = atoi(tmparg); continue; } else if (strmatch(argv[i],"-tailmargin")) { /* tail silence length */ + if (!check_section(jconf, argv[i], JCONF_OPT_GLOBAL)) return FALSE; GET_TMPARG; jconf->detect.tail_margin_msec = atoi(tmparg); continue; } else if (strmatch(argv[i],"-hipass")||strmatch(argv[i],"-hifreq")) { /* frequency of upper band limit */ + if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE; GET_TMPARG; jconf->amnow->analysis.para.hipass = atoi(tmparg); continue; } else if (strmatch(argv[i],"-lopass")||strmatch(argv[i],"-lofreq")) { /* frequency of lower band limit */ + if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE; GET_TMPARG; jconf->amnow->analysis.para.lopass = atoi(tmparg); continue; } else if (strmatch(argv[i],"-smpPeriod")) { /* sample period (ns) */ + if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE; GET_TMPARG; jconf->amnow->analysis.para.smp_period = atoi(tmparg); jconf->amnow->analysis.para.smp_freq = period2freq(jconf->amnow->analysis.para.smp_period); continue; } else if (strmatch(argv[i],"-smpFreq")) { /* sample frequency (Hz) */ + if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE; GET_TMPARG; jconf->amnow->analysis.para.smp_freq = atoi(tmparg); jconf->amnow->analysis.para.smp_period = freq2period(jconf->amnow->analysis.para.smp_freq); continue; } else if (strmatch(argv[i],"-fsize")) { /* Window size */ + if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE; GET_TMPARG; jconf->amnow->analysis.para.framesize = atoi(tmparg); continue; } else if (strmatch(argv[i],"-fshift")) { /* Frame shiht */ + if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE; GET_TMPARG; jconf->amnow->analysis.para.frameshift = atoi(tmparg); continue; } else if (strmatch(argv[i],"-preemph")) { + if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE; GET_TMPARG; jconf->amnow->analysis.para.preEmph = atof(tmparg); continue; } else if (strmatch(argv[i],"-fbank")) { + if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE; GET_TMPARG; jconf->amnow->analysis.para.fbank_num = atoi(tmparg); continue; } else if (strmatch(argv[i],"-ceplif")) { + if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE; GET_TMPARG; jconf->amnow->analysis.para.lifter = atoi(tmparg); continue; } else if (strmatch(argv[i],"-rawe")) { + if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE; jconf->amnow->analysis.para.raw_e = TRUE; continue; } else if (strmatch(argv[i],"-norawe")) { + if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE; jconf->amnow->analysis.para.raw_e = FALSE; continue; } else if (strmatch(argv[i],"-enormal")) { + if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE; jconf->amnow->analysis.para.enormal = TRUE; continue; } else if (strmatch(argv[i],"-noenormal")) { + if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE; jconf->amnow->analysis.para.enormal = FALSE; continue; } else if (strmatch(argv[i],"-escale")) { + if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE; GET_TMPARG; jconf->amnow->analysis.para.escale = atof(tmparg); continue; } else if (strmatch(argv[i],"-silfloor")) { + if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE; GET_TMPARG; jconf->amnow->analysis.para.silFloor = atof(tmparg); continue; } else if (strmatch(argv[i],"-delwin")) { /* Delta window length */ + if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE; GET_TMPARG; jconf->amnow->analysis.para.delWin = atoi(tmparg); continue; } else if (strmatch(argv[i],"-accwin")) { /* Acceleration window length */ + if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE; GET_TMPARG; jconf->amnow->analysis.para.accWin = atoi(tmparg); continue; } else if (strmatch(argv[i],"-ssalpha")) { /* alpha coef. for SS */ + if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE; GET_TMPARG; jconf->amnow->frontend.ss_alpha = atof(tmparg); continue; } else if (strmatch(argv[i],"-ssfloor")) { /* spectral floor for SS */ + if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE; GET_TMPARG; jconf->amnow->frontend.ss_floor = atof(tmparg); continue; } else if (strmatch(argv[i],"-cvn")) { + if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE; jconf->amnow->analysis.para.cvn = 1; continue; } else if (strmatch(argv[i],"-nocvn")) { + if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE; jconf->amnow->analysis.para.cvn = 0; continue; } else if (strmatch(argv[i],"-vtln")) { /* VTLN */ + if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE; GET_TMPARG; jconf->amnow->analysis.para.vtln_alpha = (float)atof(tmparg); GET_TMPARG; @@ -576,9 +674,11 @@ jconf->amnow->analysis.para.vtln_upper = (float)atof(tmparg); continue; } else if (strmatch(argv[i],"-novtln")) { /* disable VTLN */ + if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE; jconf->amnow->analysis.para.vtln_alpha = 1.0; continue; } else if (strmatch(argv[i],"-48")) { /* use 48kHz input and down to 16kHz */ + if (!check_section(jconf, argv[i], JCONF_OPT_GLOBAL)) return FALSE; jconf->input.use_ds48to16 = TRUE; continue; } else if (strmatch(argv[i],"-version") || strmatch(argv[i], "--version") || strmatch(argv[i], "-setting") || strmatch(argv[i], "--setting")) { /* print version and exit */ @@ -597,9 +697,11 @@ callback_debug_flag = TRUE; continue; } else if (strmatch(argv[i],"-progout")) { /* enable progressive output */ + if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE; jconf->searchnow->output.progout_flag = TRUE; continue; } else if (strmatch(argv[i],"-proginterval")) { /* interval for -progout */ + if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE; GET_TMPARG; jconf->searchnow->output.progout_interval = atoi(tmparg); continue; @@ -608,39 +710,48 @@ jconf->searchnow->output.progout_flag = TRUE; continue; } else if (strmatch(argv[i],"-walign")) { /* do forced alignment by word */ + if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE; jconf->searchnow->annotate.align_result_word_flag = TRUE; continue; } else if (strmatch(argv[i],"-palign")) { /* do forced alignment by phoneme */ + if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE; jconf->searchnow->annotate.align_result_phoneme_flag = TRUE; continue; } else if (strmatch(argv[i],"-salign")) { /* do forced alignment by state */ + if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE; jconf->searchnow->annotate.align_result_state_flag = TRUE; continue; } else if (strmatch(argv[i],"-output")) { /* output up to N candidate */ + if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE; GET_TMPARG; jconf->searchnow->output.output_hypo_maxnum = atoi(tmparg); continue; } else if (strmatch(argv[i],"-1pass")) { /* do only 1st pass */ + if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE; jconf->searchnow->compute_only_1pass = TRUE; continue; } else if (strmatch(argv[i],"-hlist")) { /* HMM list file */ + if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE; FREE_MEMORY(jconf->amnow->mapfilename); GET_TMPARG; jconf->amnow->mapfilename = filepath(tmparg, cwd); continue; } else if (strmatch(argv[i],"-nlr")) { /* word LR n-gram (ARPA) */ + if (!check_section(jconf, argv[i], JCONF_OPT_LM)) return FALSE; FREE_MEMORY(jconf->lmnow->ngram_filename_lr_arpa); GET_TMPARG; jconf->lmnow->ngram_filename_lr_arpa = filepath(tmparg, cwd); FREE_MEMORY(jconf->lmnow->ngram_filename); continue; } else if (strmatch(argv[i],"-nrl")) { /* word RL n-gram (ARPA) */ + if (!check_section(jconf, argv[i], JCONF_OPT_LM)) return FALSE; FREE_MEMORY(jconf->lmnow->ngram_filename_rl_arpa); GET_TMPARG; jconf->lmnow->ngram_filename_rl_arpa = filepath(tmparg, cwd); FREE_MEMORY(jconf->lmnow->ngram_filename); continue; } else if (strmatch(argv[i],"-lmp")) { /* LM weight and penalty (pass1) */ + if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE; GET_TMPARG; jconf->searchnow->lmp.lm_weight = (LOGPROB)atof(tmparg); GET_TMPARG; @@ -648,6 +759,7 @@ jconf->searchnow->lmp.lmp_specified = TRUE; continue; } else if (strmatch(argv[i],"-lmp2")) { /* LM weight and penalty (pass2) */ + if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE; GET_TMPARG; jconf->searchnow->lmp.lm_weight2 = (LOGPROB)atof(tmparg); GET_TMPARG; @@ -655,10 +767,12 @@ jconf->searchnow->lmp.lmp2_specified = TRUE; continue; } else if (strmatch(argv[i],"-transp")) { /* penalty for transparent word */ + if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE; GET_TMPARG; jconf->searchnow->lmp.lm_penalty_trans = (LOGPROB)atof(tmparg); continue; } else if (strmatch(argv[i],"-gram")) { /* comma-separatedlist of grammar prefix */ + if (!check_section(jconf, argv[i], JCONF_OPT_LM)) return FALSE; GET_TMPARG; if (multigram_add_prefix_list(tmparg, cwd, jconf->lmnow, LM_DFA_GRAMMAR) == FALSE) { jlog("ERROR: m_options: failed to read some grammars\n"); @@ -666,6 +780,7 @@ } continue; } else if (strmatch(argv[i],"-gramlist")) { /* file of grammar prefix list */ + if (!check_section(jconf, argv[i], JCONF_OPT_LM)) return FALSE; GET_TMPARG; tmparg = filepath(tmparg, cwd); if (multigram_add_prefix_filelist(tmparg, jconf->lmnow, LM_DFA_GRAMMAR) == FALSE) { @@ -676,6 +791,7 @@ free(tmparg); continue; } else if (strmatch(argv[i],"-userlm")) { + if (!check_section(jconf, argv[i], JCONF_OPT_LM)) return FALSE; /* just set lm flags here */ if (jconf->lmnow->lmtype != LM_PROB && jconf->lmnow->lmtype != LM_UNDEF) { jlog("ERROR: m_options: LM type conflicts: multiple LM specified?\n"); @@ -689,6 +805,7 @@ jconf->lmnow->lmvar = LM_NGRAM_USER; continue; } else if (strmatch(argv[i],"-nogram")) { /* remove grammar list */ + if (!check_section(jconf, argv[i], JCONF_OPT_LM)) return FALSE; multigram_remove_gramlist(jconf->lmnow); FREE_MEMORY(jconf->lmnow->dfa_filename); FREE_MEMORY(jconf->lmnow->dictfilename); @@ -698,53 +815,65 @@ } continue; } else if (strmatch(argv[i],"-dfa")) { /* DFA filename */ + if (!check_section(jconf, argv[i], JCONF_OPT_LM)) return FALSE; FREE_MEMORY(jconf->lmnow->dfa_filename); GET_TMPARG; jconf->lmnow->dfa_filename = filepath(tmparg, cwd); continue; } else if (strmatch(argv[i],"-penalty1")) { /* word insertion penalty (pass1) */ + if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE; GET_TMPARG; jconf->searchnow->lmp.penalty1 = (LOGPROB)atof(tmparg); continue; } else if (strmatch(argv[i],"-penalty2")) { /* word insertion penalty (pass2) */ + if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE; GET_TMPARG; jconf->searchnow->lmp.penalty2 = (LOGPROB)atof(tmparg); continue; } else if (strmatch(argv[i],"-spmodel") || strmatch(argv[i], "-sp")) { /* name of short pause word */ + if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE; FREE_MEMORY(jconf->amnow->spmodel_name); GET_TMPARG; jconf->amnow->spmodel_name = strcpy((char*)mymalloc(strlen(tmparg)+1),tmparg); continue; } else if (strmatch(argv[i],"-multipath")) { /* force multipath mode */ + if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE; jconf->amnow->force_multipath = TRUE; continue; } else if (strmatch(argv[i],"-iwsp")) { /* enable inter-word short pause handing (for multipath) */ + if (!check_section(jconf, argv[i], JCONF_OPT_LM)) return FALSE; jconf->lmnow->enable_iwsp = TRUE; continue; } else if (strmatch(argv[i],"-iwsppenalty")) { /* set inter-word short pause transition penalty (for multipath) */ + if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE; GET_TMPARG; jconf->amnow->iwsp_penalty = atof(tmparg); continue; } else if (strmatch(argv[i],"-silhead")) { /* head silence word name */ + if (!check_section(jconf, argv[i], JCONF_OPT_LM)) return FALSE; FREE_MEMORY(jconf->lmnow->head_silname); GET_TMPARG; jconf->lmnow->head_silname = strcpy((char*)mymalloc(strlen(tmparg)+1),tmparg); continue; } else if (strmatch(argv[i],"-siltail")) { /* tail silence word name */ + if (!check_section(jconf, argv[i], JCONF_OPT_LM)) return FALSE; FREE_MEMORY(jconf->lmnow->tail_silname); GET_TMPARG; jconf->lmnow->tail_silname = strcpy((char*)mymalloc(strlen(tmparg)+1),tmparg); continue; } else if (strmatch(argv[i],"-iwspword")) { /* add short pause word */ + if (!check_section(jconf, argv[i], JCONF_OPT_LM)) return FALSE; jconf->lmnow->enable_iwspword = TRUE; continue; } else if (strmatch(argv[i],"-iwspentry")) { /* content of the iwspword */ + if (!check_section(jconf, argv[i], JCONF_OPT_LM)) return FALSE; FREE_MEMORY(jconf->lmnow->iwspentry); GET_TMPARG; jconf->lmnow->iwspentry = strcpy((char*)mymalloc(strlen(tmparg)+1),tmparg); continue; } else if (strmatch(argv[i],"-iwcache")) { /* control cross-word LM cache */ #ifdef HASH_CACHE_IW + if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE; GET_TMPARG; jconf->searchnow->pass1.iw_cache_rate = atof(tmparg); if (jconf->searchnow->pass1.iw_cache_rate > 100) jconf->searchnow->pass1.iw_cache_rate = 100; @@ -755,6 +884,7 @@ continue; } else if (strmatch(argv[i],"-sepnum")) { /* N-best frequent word will be separated from tree */ #ifdef SEPARATE_BY_UNIGRAM + if (!check_section(jconf, argv[i], JCONF_OPT_LM)) return FALSE; GET_TMPARG; jconf->lmnow->separate_wnum = atoi(tmparg); #else @@ -764,59 +894,74 @@ continue; #ifdef USE_NETAUDIO } else if (strmatch(argv[i],"-NA")) { /* netautio device name */ + if (!check_section(jconf, argv[i], JCONF_OPT_GLOBAL)) return FALSE; FREE_MEMORY(jconf->input.netaudio_devname); GET_TMPARG; jconf->input.netaudio_devname = strcpy((char*)mymalloc(strlen(tmparg)+1),tmparg); continue; #endif } else if (strmatch(argv[i],"-adport")) { /* adinnet port num */ + if (!check_section(jconf, argv[i], JCONF_OPT_GLOBAL)) return FALSE; GET_TMPARG; jconf->input.adinnet_port = atoi(tmparg); continue; } else if (strmatch(argv[i],"-nostrip")) { /* do not strip zero samples */ + if (!check_section(jconf, argv[i], JCONF_OPT_GLOBAL)) return FALSE; jconf->preprocess.strip_zero_sample = FALSE; continue; } else if (strmatch(argv[i],"-zmean")) { /* enable DC offset by zero mean */ + if (!check_section(jconf, argv[i], JCONF_OPT_GLOBAL)) return FALSE; jconf->preprocess.use_zmean = TRUE; continue; } else if (strmatch(argv[i],"-nozmean")) { /* disable DC offset by zero mean */ + if (!check_section(jconf, argv[i], JCONF_OPT_GLOBAL)) return FALSE; jconf->preprocess.use_zmean = FALSE; continue; } else if (strmatch(argv[i],"-zmeanframe")) { /* enable frame-wise DC offset by zero mean */ + if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE; jconf->amnow->analysis.para.zmeanframe = TRUE; continue; } else if (strmatch(argv[i],"-nozmeanframe")) { /* disable frame-wise DC offset by zero mean */ + if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE; jconf->amnow->analysis.para.zmeanframe = FALSE; continue; } else if (strmatch(argv[i],"-usepower")) { /* use power instead of magnitude in filterbank analysis */ + if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE; jconf->amnow->analysis.para.usepower = TRUE; continue; } else if (strmatch(argv[i],"-nousepower")) { /* use magnitude in fbank analysis (default) */ + if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE; jconf->amnow->analysis.para.usepower = FALSE; continue; } else if (strmatch(argv[i],"-spsegment")) { /* enable short-pause segmentation */ + if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE; jconf->searchnow->successive.enabled = TRUE; continue; } else if (strmatch(argv[i],"-spdur")) { /* speech down-trigger duration threshold in frame */ + if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE; GET_TMPARG; jconf->searchnow->successive.sp_frame_duration = atoi(tmparg); continue; #ifdef SPSEGMENT_NAIST } else if (strmatch(argv[i],"-spmargin")) { /* speech up-trigger backstep margin in frame */ + if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE; GET_TMPARG; jconf->searchnow->successive.sp_margin = atoi(tmparg); continue; } else if (strmatch(argv[i],"-spdelay")) { /* speech up-trigger delay frame */ + if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE; GET_TMPARG; jconf->searchnow->successive.sp_delay = atoi(tmparg); continue; #endif } else if (strmatch(argv[i],"-pausemodels")) { /* short-pause duration threshold */ + if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE; FREE_MEMORY(jconf->searchnow->successive.pausemodelname); GET_TMPARG; jconf->searchnow->successive.pausemodelname = strcpy((char*)mymalloc(strlen(tmparg)+1),tmparg); continue; } else if (strmatch(argv[i],"-gprune")) { /* select Gaussian pruning method */ + if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE; GET_TMPARG; if (strmatch(tmparg,"safe")) { /* safest, slowest */ jconf->amnow->gprune_method = GPRUNE_SEL_SAFE; @@ -839,14 +984,17 @@ * continue; */ } else if (strmatch(argv[i],"-no_ccd")) { /* force triphone handling = OFF */ + if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE; jconf->searchnow->ccd_handling = FALSE; jconf->searchnow->force_ccd_handling = TRUE; continue; } else if (strmatch(argv[i],"-force_ccd")) { /* force triphone handling = ON */ + if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE; jconf->searchnow->ccd_handling = TRUE; jconf->searchnow->force_ccd_handling = TRUE; continue; } else if (strmatch(argv[i],"-iwcd1")) { /* select cross-word triphone computation method */ + if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE; GET_TMPARG; if (strmatch(tmparg, "max")) { /* use maximum score in triphone variants */ jconf->amnow->iwcdmethod = IWCD_MAX; @@ -862,61 +1010,75 @@ } continue; } else if (strmatch(argv[i],"-tmix")) { /* num of mixture to select */ + if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE; if (i + 1 < argc && isdigit(argv[i+1][0])) { jconf->amnow->mixnum_thres = atoi(argv[++i]); } continue; } else if (strmatch(argv[i],"-b2") || strmatch(argv[i],"-bw") || strmatch(argv[i],"-wb")) { /* word beam width in 2nd pass */ + if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE; GET_TMPARG; jconf->searchnow->pass2.enveloped_bestfirst_width = atoi(tmparg); continue; } else if (strmatch(argv[i],"-hgs")) { /* Gaussian selection model file */ + if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE; FREE_MEMORY(jconf->amnow->hmm_gs_filename); GET_TMPARG; jconf->amnow->hmm_gs_filename = filepath(tmparg, cwd); continue; } else if (strmatch(argv[i],"-booknum")) { /* num of state to select in GS */ + if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE; GET_TMPARG; jconf->amnow->gs_statenum = atoi(tmparg); continue; } else if (strmatch(argv[i],"-gshmm")) { /* same as "-hgs" */ + if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE; FREE_MEMORY(jconf->amnow->hmm_gs_filename); GET_TMPARG; jconf->amnow->hmm_gs_filename = filepath(tmparg, cwd); continue; } else if (strmatch(argv[i],"-gsnum")) { /* same as "-booknum" */ + if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE; GET_TMPARG; jconf->amnow->gs_statenum = atoi(tmparg); continue; } else if (strmatch(argv[i],"-cmnload")) { /* load CMN parameter from file */ + if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE; FREE_MEMORY(jconf->amnow->analysis.cmnload_filename); GET_TMPARG; jconf->amnow->analysis.cmnload_filename = filepath(tmparg, cwd); continue; } else if (strmatch(argv[i],"-cmnsave")) { /* save CMN parameter to file */ + if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE; FREE_MEMORY(jconf->amnow->analysis.cmnsave_filename); GET_TMPARG; jconf->amnow->analysis.cmnsave_filename = filepath(tmparg, cwd); continue; } else if (strmatch(argv[i],"-cmnupdate")) { /* update CMN parameter */ + if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE; jconf->amnow->analysis.cmn_update = TRUE; continue; } else if (strmatch(argv[i],"-cmnnoupdate")) { /* not update CMN parameter */ + if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE; jconf->amnow->analysis.cmn_update = FALSE; continue; } else if (strmatch(argv[i],"-cmnmapweight")) { /* CMN weight for MAP */ + if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE; GET_TMPARG; jconf->amnow->analysis.cmn_map_weight = (float)atof(tmparg); continue; } else if (strmatch(argv[i],"-sscalc")) { /* do spectral subtraction (SS) for raw file input */ + if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE; jconf->amnow->frontend.sscalc = TRUE; FREE_MEMORY(jconf->amnow->frontend.ssload_filename); continue; } else if (strmatch(argv[i],"-sscalclen")) { /* head silence length used to compute SS (in msec) */ + if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE; GET_TMPARG; jconf->amnow->frontend.sscalc_len = atoi(tmparg); continue; } else if (strmatch(argv[i],"-ssload")) { /* load SS parameter from file */ + if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE; FREE_MEMORY(jconf->amnow->frontend.ssload_filename); GET_TMPARG; jconf->amnow->frontend.ssload_filename = filepath(tmparg, cwd); @@ -924,6 +1086,7 @@ continue; #ifdef CONFIDENCE_MEASURE } else if (strmatch(argv[i],"-cmalpha")) { /* CM log score scaling factor */ + if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE; #ifdef CM_MULTIPLE_ALPHA GET_TMPARG; jconf->searchnow->annotate.cm_alpha_bgn = (LOGPROB)atof(tmparg); @@ -943,46 +1106,55 @@ continue; #ifdef CM_SEARCH_LIMIT } else if (strmatch(argv[i],"-cmthres")) { /* CM cut threshold for CM decoding */ + if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE; GET_TMPARG; jconf->searchnow->annotate.cm_cut_thres = (LOGPROB)atof(tmparg); continue; #endif #ifdef CM_SEARCH_LIMIT_POP } else if (strmatch(argv[i],"-cmthres2")) { /* CM cut threshold for CM decoding */ + if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE; GET_TMPARG; jconf->searchnow->annotate.cm_cut_thres_pop = (LOGPROB)atof(tmparg); continue; #endif #endif /* CONFIDENCE_MEASURE */ } else if (strmatch(argv[i],"-gmm")) { /* load SS parameter from file */ + if (!check_section(jconf, argv[i], JCONF_OPT_GLOBAL)) return FALSE; FREE_MEMORY(jconf->reject.gmm_filename); GET_TMPARG; jconf->reject.gmm_filename = filepath(tmparg, cwd); continue; } else if (strmatch(argv[i],"-gmmnum")) { /* num of Gaussian pruning for GMM */ + if (!check_section(jconf, argv[i], JCONF_OPT_GLOBAL)) return FALSE; GET_TMPARG; jconf->reject.gmm_gprune_num = atoi(tmparg); continue; } else if (strmatch(argv[i],"-gmmreject")) { + if (!check_section(jconf, argv[i], JCONF_OPT_GLOBAL)) return FALSE; GET_TMPARG; FREE_MEMORY(jconf->reject.gmm_reject_cmn_string); jconf->reject.gmm_reject_cmn_string = strcpy((char *)mymalloc(strlen(tmparg)+1), tmparg); continue; #ifdef GMM_VAD } else if (strmatch(argv[i],"-gmmmargin")) { /* backstep margin */ + if (!check_section(jconf, argv[i], JCONF_OPT_GLOBAL)) return FALSE; GET_TMPARG; jconf->detect.gmm_margin = atoi(tmparg); continue; } else if (strmatch(argv[i],"-gmmup")) { /* uptrigger threshold */ + if (!check_section(jconf, argv[i], JCONF_OPT_GLOBAL)) return FALSE; GET_TMPARG; jconf->detect.gmm_uptrigger_thres = atof(tmparg); continue; } else if (strmatch(argv[i],"-gmmdown")) { /* uptrigger threshold */ + if (!check_section(jconf, argv[i], JCONF_OPT_GLOBAL)) return FALSE; GET_TMPARG; jconf->detect.gmm_downtrigger_thres = atof(tmparg); continue; #endif } else if (strmatch(argv[i],"-htkconf")) { + if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE; GET_TMPARG; if (htk_config_file_parse(tmparg, &(jconf->amnow->analysis.para_htk)) == FALSE) { jlog("ERROR: m_options: failed to read %s\n", tmparg); @@ -990,6 +1162,7 @@ } continue; } else if (strmatch(argv[i], "-wlist")) { + if (!check_section(jconf, argv[i], JCONF_OPT_LM)) return FALSE; GET_TMPARG; tmparg = filepath(tmparg, cwd); if (multigram_add_prefix_filelist(tmparg, jconf->lmnow, LM_DFA_WORD) == FALSE) { @@ -1006,6 +1179,7 @@ * return FALSE; * } */ + if (!check_section(jconf, argv[i], JCONF_OPT_LM)) return FALSE; GET_TMPARG; strncpy(jconf->lmnow->wordrecog_head_silence_model_name, tmparg, MAX_HMMNAME_LEN); GET_TMPARG; @@ -1023,6 +1197,7 @@ //jlog("ERROR: \"-wed\" only valid for isolated word recognition mode\n"); //return FALSE; //} + if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE; GET_TMPARG; jconf->searchnow->pass1.determine_score_thres = atof(tmparg); GET_TMPARG; @@ -1030,12 +1205,15 @@ continue; #endif } else if (strmatch(argv[i], "-inactive")) { /* start inactive */ + if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE; jconf->searchnow->sw.start_inactive = TRUE; continue; } else if (strmatch(argv[i], "-active")) { /* start active (default) */ + if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE; jconf->searchnow->sw.start_inactive = FALSE; continue; } else if (strmatch(argv[i],"-fallback1pass")) { /* use 1st pass result on search failure */ + if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE; jconf->searchnow->sw.fallback_pass1_flag = TRUE; continue; } @@ -1043,16 +1221,19 @@ /* 1-letter options */ switch(argv[i][1]) { case 'h': /* hmmdefs */ + if (!check_section(jconf, argv[i], JCONF_OPT_AM)) return FALSE; FREE_MEMORY(jconf->amnow->hmmfilename); GET_TMPARG; jconf->amnow->hmmfilename = filepath(tmparg, cwd); break; case 'v': /* dictionary */ + if (!check_section(jconf, argv[i], JCONF_OPT_LM)) return FALSE; FREE_MEMORY(jconf->lmnow->dictfilename); GET_TMPARG; jconf->lmnow->dictfilename = filepath(tmparg, cwd); break; case 'w': /* word list (isolated word recognition) */ + if (!check_section(jconf, argv[i], JCONF_OPT_LM)) return FALSE; GET_TMPARG; if (multigram_add_prefix_list(tmparg, cwd, jconf->lmnow, LM_DFA_WORD) == FALSE) { jlog("ERROR: m_options: failed to read some word list\n"); @@ -1061,6 +1242,7 @@ break; case 'd': /* binary N-gram */ /* lmvar should be overriden by the content of the binary N-gram */ + if (!check_section(jconf, argv[i], JCONF_OPT_LM)) return FALSE; FREE_MEMORY(jconf->lmnow->ngram_filename); FREE_MEMORY(jconf->lmnow->ngram_filename_lr_arpa); FREE_MEMORY(jconf->lmnow->ngram_filename_rl_arpa); @@ -1068,18 +1250,22 @@ jconf->lmnow->ngram_filename = filepath(tmparg, cwd); break; case 'b': /* beam width in 1st pass */ + if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE; GET_TMPARG; jconf->searchnow->pass1.specified_trellis_beam_width = atoi(tmparg); break; case 's': /* stack size in 2nd pass */ + if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE; GET_TMPARG; jconf->searchnow->pass2.stack_size = atoi(tmparg); break; case 'n': /* N-best search */ + if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE; GET_TMPARG; jconf->searchnow->pass2.nbest = atoi(tmparg); break; case 'm': /* upper limit of hypothesis generation */ + if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE; GET_TMPARG; jconf->searchnow->pass2.hypo_overflow = atoi(tmparg); break; Index: julius4/libjulius/src/m_usage.c diff -u julius4/libjulius/src/m_usage.c:1.8 julius4/libjulius/src/m_usage.c:1.9 --- julius4/libjulius/src/m_usage.c:1.8 Tue Jul 1 13:29:45 2008 +++ julius4/libjulius/src/m_usage.c Thu Sep 25 01:17:17 2008 @@ -12,7 +12,7 @@ * @author Akinobu Lee * @date Fri May 13 15:04:34 2005 * - * $Revision: 1.8 $ + * $Revision: 1.9 $ * */ /* @@ -134,6 +134,7 @@ fprintf(fp, " [-LM] start a new language model instance\n"); fprintf(fp, " [-SR] start a new recognizer (search) instance\n"); fprintf(fp, " [-AM_GMM] start an AM feature instance for GMM\n"); + fprintf(fp, " [-nosectioncheck] disable option location check\n"); fprintf(fp, "\n--- Acoustic Model Options (-AM) ---------------------------------\n"); fprintf(fp, "\n Acoustic analysis:\n"); From sumomo @ users.sourceforge.jp Thu Sep 25 13:22:58 2008 From: sumomo @ users.sourceforge.jp (sumomo @ users.sourceforge.jp) Date: Thu, 25 Sep 2008 13:22:58 +0900 Subject: [Julius-cvs 229] CVS update: julius4/libjulius/include/julius Message-ID: <1222316578.266047.7691.nullmailer@users.sourceforge.jp> Index: julius4/libjulius/include/julius/jconf.h diff -u julius4/libjulius/include/julius/jconf.h:1.5 julius4/libjulius/include/julius/jconf.h:1.6 --- julius4/libjulius/include/julius/jconf.h:1.5 Thu Sep 25 01:17:17 2008 +++ julius4/libjulius/include/julius/jconf.h Thu Sep 25 13:22:57 2008 @@ -23,7 +23,7 @@ * @author Akinobu Lee * @date Fri Feb 16 13:42:28 2007 * - * $Revision: 1.5 $ + * $Revision: 1.6 $ * */ /* @@ -1013,6 +1013,7 @@ } Jconf; enum { + JCONF_OPT_DEFAULT, JCONF_OPT_GLOBAL, JCONF_OPT_AM, JCONF_OPT_LM, From sumomo @ users.sourceforge.jp Thu Sep 25 13:22:58 2008 From: sumomo @ users.sourceforge.jp (sumomo @ users.sourceforge.jp) Date: Thu, 25 Sep 2008 13:22:58 +0900 Subject: [Julius-cvs 230] CVS update: julius4/libjulius/src Message-ID: <1222316578.523655.7703.nullmailer@users.sourceforge.jp> Index: julius4/libjulius/src/default.c diff -u julius4/libjulius/src/default.c:1.6 julius4/libjulius/src/default.c:1.7 --- julius4/libjulius/src/default.c:1.6 Thu Sep 25 01:17:17 2008 +++ julius4/libjulius/src/default.c Thu Sep 25 13:22:58 2008 @@ -17,7 +17,7 @@ * @author Akinobu Lee * @date Fri Feb 16 15:05:43 2007 * - * $Revision: 1.6 $ + * $Revision: 1.7 $ * */ /* @@ -96,7 +96,7 @@ j->decodeopt.force_realtime_flag = FALSE; j->decodeopt.segment = FALSE; - j->optsection = JCONF_OPT_GLOBAL; + j->optsection = JCONF_OPT_DEFAULT; j->optsectioning = TRUE; } Index: julius4/libjulius/src/m_options.c diff -u julius4/libjulius/src/m_options.c:1.13 julius4/libjulius/src/m_options.c:1.14 --- julius4/libjulius/src/m_options.c:1.13 Thu Sep 25 01:17:17 2008 +++ julius4/libjulius/src/m_options.c Thu Sep 25 13:22:58 2008 @@ -18,7 +18,7 @@ * @author Akinobu Lee * @date Thu May 12 18:52:07 2005 * - * $Revision: 1.13 $ + * $Revision: 1.14 $ * */ /* @@ -105,7 +105,7 @@ if (jconf->optsection == sec) return TRUE; - if (jconf->optsection == JCONF_OPT_GLOBAL) return TRUE; + if (jconf->optsection == JCONF_OPT_DEFAULT) return TRUE; switch(sec) { case JCONF_OPT_GLOBAL: @@ -118,6 +118,8 @@ jlog("ERROR: \"%s\" is SR (search) option", optname); break; } switch(jconf->optsection) { + case JCONF_OPT_GLOBAL: + jlog(", but exists at global section (-GLOBAL)\n"); break; case JCONF_OPT_AM: jlog(", but exists at AM section (-AM \"%s\")\n", jconf->amnow->name); break; case JCONF_OPT_LM: @@ -290,6 +292,9 @@ jconf->searchnow = sconf; jconf->optsection = JCONF_OPT_SR; continue; + } else if (strmatch(argv[i],"-GLOBAL")) { + jconf->optsection = JCONF_OPT_GLOBAL; + continue; } else if (strmatch(argv[i],"-sectioncheck")) { /* enable section check */ jconf->optsectioning = TRUE; continue; Index: julius4/libjulius/src/m_usage.c diff -u julius4/libjulius/src/m_usage.c:1.9 julius4/libjulius/src/m_usage.c:1.10 --- julius4/libjulius/src/m_usage.c:1.9 Thu Sep 25 01:17:17 2008 +++ julius4/libjulius/src/m_usage.c Thu Sep 25 13:22:58 2008 @@ -12,7 +12,7 @@ * @author Akinobu Lee * @date Fri May 13 15:04:34 2005 * - * $Revision: 1.9 $ + * $Revision: 1.10 $ * */ /* @@ -134,6 +134,7 @@ fprintf(fp, " [-LM] start a new language model instance\n"); fprintf(fp, " [-SR] start a new recognizer (search) instance\n"); fprintf(fp, " [-AM_GMM] start an AM feature instance for GMM\n"); + fprintf(fp, " [-GLOBAL] start a global section\n"); fprintf(fp, " [-nosectioncheck] disable option location check\n"); fprintf(fp, "\n--- Acoustic Model Options (-AM) ---------------------------------\n"); From sumomo @ users.sourceforge.jp Thu Sep 25 13:49:04 2008 From: sumomo @ users.sourceforge.jp (sumomo @ users.sourceforge.jp) Date: Thu, 25 Sep 2008 13:49:04 +0900 Subject: [Julius-cvs 231] CVS update: julius4/adinrec Message-ID: <1222318144.742965.29555.nullmailer@users.sourceforge.jp> Index: julius4/adinrec/Makefile.in diff -u julius4/adinrec/Makefile.in:1.2 julius4/adinrec/Makefile.in:1.3 --- julius4/adinrec/Makefile.in:1.2 Tue Dec 18 17:45:46 2007 +++ julius4/adinrec/Makefile.in Thu Sep 25 13:49:04 2008 @@ -3,7 +3,7 @@ # Copyright (c) 2005-2007 Julius project team, Nagoya Institute of Technology # All rights reserved # -# $Id: Makefile.in,v 1.2 2007/12/18 08:45:46 sumomo Exp $ +# $Id: Makefile.in,v 1.3 2008/09/25 04:49:04 sumomo Exp $ # SHELL=/bin/sh .SUFFIXES: @@ -16,7 +16,7 @@ CC=@CC@ CFLAGS=@CFLAGS@ CPPFLAGS=-I. -I$(LIBJULIUS)/include -I$(LIBSENT)/include @CPPFLAGS@ `$(LIBSENT)/libsent-config --cflags` `$(LIBJULIUS)/libjulius-config --cflags` -LDFLAGS=@LDFLAGS@ -L$(LIBJULIUS) -ljulius -L$(LIBSENT) -lsent `$(LIBSENT)/libsent-config --libs` -lm `$(LIBJULIUS)/libjulius-config --libs` -lm +LDFLAGS=@LDFLAGS@ -L$(LIBJULIUS) `$(LIBJULIUS)/libjulius-config --libs` -L$(LIBSENT) `$(LIBSENT)/libsent-config --libs` RM=@RM@ -f prefix=@prefix@ exec_prefix=@exec_prefix@ From sumomo @ users.sourceforge.jp Thu Sep 25 13:49:04 2008 From: sumomo @ users.sourceforge.jp (sumomo @ users.sourceforge.jp) Date: Thu, 25 Sep 2008 13:49:04 +0900 Subject: [Julius-cvs 232] CVS update: julius4/adintool Message-ID: <1222318144.899528.29563.nullmailer@users.sourceforge.jp> Index: julius4/adintool/Makefile.in diff -u julius4/adintool/Makefile.in:1.2 julius4/adintool/Makefile.in:1.3 --- julius4/adintool/Makefile.in:1.2 Tue Dec 18 17:45:46 2007 +++ julius4/adintool/Makefile.in Thu Sep 25 13:49:04 2008 @@ -3,7 +3,7 @@ # Copyright (c) 2005-2007 Julius project team, Nagoya Institute of Technology # All rights reserved # -# $Id: Makefile.in,v 1.2 2007/12/18 08:45:46 sumomo Exp $ +# $Id: Makefile.in,v 1.3 2008/09/25 04:49:04 sumomo Exp $ # SHELL=/bin/sh .SUFFIXES: @@ -16,7 +16,7 @@ CC=@CC@ CFLAGS=@CFLAGS@ CPPFLAGS=-I. -I$(LIBJULIUS)/include -I$(LIBSENT)/include @CPPFLAGS@ `$(LIBSENT)/libsent-config --cflags` `$(LIBJULIUS)/libjulius-config --cflags` -LDFLAGS=@LDFLAGS@ -L$(LIBJULIUS) -ljulius -L$(LIBSENT) -lsent `$(LIBSENT)/libsent-config --libs` -lm `$(LIBJULIUS)/libjulius-config --libs` -lm +LDFLAGS=@LDFLAGS@ -L$(LIBJULIUS) `$(LIBJULIUS)/libjulius-config --libs` -L$(LIBSENT) `$(LIBSENT)/libsent-config --libs` RM=@RM@ -f prefix=@prefix@ exec_prefix=@exec_prefix@ From sumomo @ users.sourceforge.jp Thu Sep 25 13:49:05 2008 From: sumomo @ users.sourceforge.jp (sumomo @ users.sourceforge.jp) Date: Thu, 25 Sep 2008 13:49:05 +0900 Subject: [Julius-cvs 233] CVS update: julius4/generate-ngram Message-ID: <1222318145.073094.29570.nullmailer@users.sourceforge.jp> Index: julius4/generate-ngram/Makefile.in diff -u julius4/generate-ngram/Makefile.in:1.5 julius4/generate-ngram/Makefile.in:1.6 --- julius4/generate-ngram/Makefile.in:1.5 Tue Jan 22 22:01:54 2008 +++ julius4/generate-ngram/Makefile.in Thu Sep 25 13:49:04 2008 @@ -3,7 +3,7 @@ # Copyright (c) 2005-2007 Julius project team, Nagoya Institute of Technology # All rights reserved # -# $Id: Makefile.in,v 1.5 2008/01/22 13:01:54 sumomo Exp $ +# $Id: Makefile.in,v 1.6 2008/09/25 04:49:04 sumomo Exp $ # SHELL=/bin/sh .SUFFIXES: @@ -15,7 +15,7 @@ CC=@CC@ CFLAGS=@CFLAGS@ CPPFLAGS=-I$(LIBSENT)/include @CPPFLAGS@ @DEFS@ `$(LIBSENT)/libsent-config --cflags` -LDFLAGS=@LDFLAGS@ -L$(LIBSENT) -lsent @LIBS@ `$(LIBSENT)/libsent-config --libs` -lm +LDFLAGS=@LDFLAGS@ -L$(LIBSENT) `$(LIBSENT)/libsent-config --libs` RM=@RM@ -f prefix=@prefix@ exec_prefix=@exec_prefix@ From sumomo @ users.sourceforge.jp Thu Sep 25 13:49:05 2008 From: sumomo @ users.sourceforge.jp (sumomo @ users.sourceforge.jp) Date: Thu, 25 Sep 2008 13:49:05 +0900 Subject: [Julius-cvs 234] CVS update: julius4/julius Message-ID: <1222318145.211487.29577.nullmailer@users.sourceforge.jp> Index: julius4/julius/Makefile.in diff -u julius4/julius/Makefile.in:1.3 julius4/julius/Makefile.in:1.4 --- julius4/julius/Makefile.in:1.3 Tue Jan 22 22:01:55 2008 +++ julius4/julius/Makefile.in Thu Sep 25 13:49:05 2008 @@ -5,7 +5,7 @@ # All rights reserved # -# $Id: Makefile.in,v 1.3 2008/01/22 13:01:55 sumomo Exp $ +# $Id: Makefile.in,v 1.4 2008/09/25 04:49:05 sumomo Exp $ # SHELL=/bin/sh .SUFFIXES: @@ -18,7 +18,7 @@ CC=@CC@ CFLAGS=@CFLAGS@ CPPFLAGS=-I. -I$(LIBJULIUS)/include -I$(LIBSENT)/include @CPPFLAGS@ `$(LIBSENT)/libsent-config --cflags` `$(LIBJULIUS)/libjulius-config --cflags` -LDFLAGS=@LDFLAGS@ -L$(LIBJULIUS) -ljulius -L$(LIBSENT) -lsent `$(LIBSENT)/libsent-config --libs` -lm `$(LIBJULIUS)/libjulius-config --libs` -lm +LDFLAGS=@LDFLAGS@ -L$(LIBJULIUS) `$(LIBJULIUS)/libjulius-config --libs` -L$(LIBSENT) `$(LIBSENT)/libsent-config --libs` GTK_CFLAGS=@GTK_CFLAGS@ GTK_LIBS=@GTK_LIBS@ RM=@RM@ -f From sumomo @ users.sourceforge.jp Thu Sep 25 13:49:05 2008 From: sumomo @ users.sourceforge.jp (sumomo @ users.sourceforge.jp) Date: Thu, 25 Sep 2008 13:49:05 +0900 Subject: [Julius-cvs 235] CVS update: julius4/julius-simple Message-ID: <1222318145.386522.29584.nullmailer@users.sourceforge.jp> Index: julius4/julius-simple/Makefile diff -u julius4/julius-simple/Makefile:1.1 julius4/julius-simple/Makefile:1.2 --- julius4/julius-simple/Makefile:1.1 Tue Dec 18 17:45:49 2007 +++ julius4/julius-simple/Makefile Thu Sep 25 13:49:05 2008 @@ -5,7 +5,7 @@ CFLAGS=-g -O2 CPPFLAGS=-I. -I$(LIBJULIUS)/include -I$(LIBSENT)/include `$(LIBSENT)/libsent-config --cflags` `$(LIBJULIUS)/libjulius-config --cflags` -LDFLAGS= -L$(LIBJULIUS) -ljulius -L$(LIBSENT) -lsent `$(LIBSENT)/libsent-config --libs` `$(LIBJULIUS)/libjulius-config --libs` -lm +LDFLAGS= -L$(LIBJULIUS) `$(LIBJULIUS)/libjulius-config --libs` -L$(LIBSENT) `$(LIBSENT)/libsent-config --libs` ############################################################ From sumomo @ users.sourceforge.jp Thu Sep 25 13:49:05 2008 From: sumomo @ users.sourceforge.jp (sumomo @ users.sourceforge.jp) Date: Thu, 25 Sep 2008 13:49:05 +0900 Subject: [Julius-cvs 236] CVS update: julius4/libjulius Message-ID: <1222318145.523287.29592.nullmailer@users.sourceforge.jp> Index: julius4/libjulius/libjulius-config.in diff -u julius4/libjulius/libjulius-config.in:1.2 julius4/libjulius/libjulius-config.in:1.3 --- julius4/libjulius/libjulius-config.in:1.2 Tue Dec 18 17:45:49 2007 +++ julius4/libjulius/libjulius-config.in Thu Sep 25 13:49:05 2008 @@ -12,7 +12,7 @@ # # ripped from gtk's gtk-config.in # -# $Id: libjulius-config.in,v 1.2 2007/12/18 08:45:49 sumomo Exp $ +# $Id: libjulius-config.in,v 1.3 2008/09/25 04:49:05 sumomo Exp $ # # @@ -40,7 +40,7 @@ echo @CPPFLAGS@ ;; --libs) - echo @LDFLAGS@ @LIBS@ + echo -ljulius @LDFLAGS@ @LIBS@ ;; --version) echo "${version}" From sumomo @ users.sourceforge.jp Thu Sep 25 13:49:05 2008 From: sumomo @ users.sourceforge.jp (sumomo @ users.sourceforge.jp) Date: Thu, 25 Sep 2008 13:49:05 +0900 Subject: [Julius-cvs 237] CVS update: julius4/libsent Message-ID: <1222318145.689350.29600.nullmailer@users.sourceforge.jp> Index: julius4/libsent/libsent-config.in diff -u julius4/libsent/libsent-config.in:1.3 julius4/libsent/libsent-config.in:1.4 --- julius4/libsent/libsent-config.in:1.3 Tue Jul 1 13:29:45 2008 +++ julius4/libsent/libsent-config.in Thu Sep 25 13:49:05 2008 @@ -12,7 +12,7 @@ # # ripped from gtk's gtk-config.in # -# $Id: libsent-config.in,v 1.3 2008/07/01 04:29:45 sumomo Exp $ +# $Id: libsent-config.in,v 1.4 2008/09/25 04:49:05 sumomo Exp $ # # @@ -62,7 +62,7 @@ echo $sound_inc ;; --libs) - echo $sound_libs @LIBS@ + echo -lsent $sound_libs @LIBS@ -lm ;; --version) echo "${version}" From sumomo @ users.sourceforge.jp Thu Sep 25 13:49:05 2008 From: sumomo @ users.sourceforge.jp (sumomo @ users.sourceforge.jp) Date: Thu, 25 Sep 2008 13:49:05 +0900 Subject: [Julius-cvs 238] CVS update: julius4/mkbingram Message-ID: <1222318145.828009.29607.nullmailer@users.sourceforge.jp> Index: julius4/mkbingram/Makefile.in diff -u julius4/mkbingram/Makefile.in:1.2 julius4/mkbingram/Makefile.in:1.3 --- julius4/mkbingram/Makefile.in:1.2 Tue Dec 18 17:45:54 2007 +++ julius4/mkbingram/Makefile.in Thu Sep 25 13:49:05 2008 @@ -3,7 +3,7 @@ # Copyright (c) 2005-2007 Julius project team, Nagoya Institute of Technology # All rights reserved # -# $Id: Makefile.in,v 1.2 2007/12/18 08:45:54 sumomo Exp $ +# $Id: Makefile.in,v 1.3 2008/09/25 04:49:05 sumomo Exp $ # SHELL=/bin/sh .SUFFIXES: @@ -15,7 +15,7 @@ CC=@CC@ CFLAGS=@CFLAGS@ CPPFLAGS=-I$(LIBSENT)/include @CPPFLAGS@ @DEFS@ `$(LIBSENT)/libsent-config --cflags` -LDFLAGS=@LDFLAGS@ -L$(LIBSENT) -lsent @LIBS@ `$(LIBSENT)/libsent-config --libs` -lm +LDFLAGS=@LDFLAGS@ -L$(LIBSENT) `$(LIBSENT)/libsent-config --libs` RM=@RM@ -f prefix=@prefix@ exec_prefix=@exec_prefix@ From sumomo @ users.sourceforge.jp Thu Sep 25 13:49:06 2008 From: sumomo @ users.sourceforge.jp (sumomo @ users.sourceforge.jp) Date: Thu, 25 Sep 2008 13:49:06 +0900 Subject: [Julius-cvs 239] CVS update: julius4/mkbinhmm Message-ID: <1222318146.019381.29614.nullmailer@users.sourceforge.jp> Index: julius4/mkbinhmm/Makefile.in diff -u julius4/mkbinhmm/Makefile.in:1.2 julius4/mkbinhmm/Makefile.in:1.3 --- julius4/mkbinhmm/Makefile.in:1.2 Tue Dec 18 17:45:55 2007 +++ julius4/mkbinhmm/Makefile.in Thu Sep 25 13:49:05 2008 @@ -3,7 +3,7 @@ # Copyright (c) 2005-2007 Julius project team, Nagoya Institute of Technology # All rights reserved # -# $Id: Makefile.in,v 1.2 2007/12/18 08:45:55 sumomo Exp $ +# $Id: Makefile.in,v 1.3 2008/09/25 04:49:05 sumomo Exp $ # SHELL=/bin/sh .SUFFIXES: @@ -15,7 +15,7 @@ CC=@CC@ CFLAGS=@CFLAGS@ CPPFLAGS=-I$(LIBSENT)/include @CPPFLAGS@ @DEFS@ `$(LIBSENT)/libsent-config --cflags` -LDFLAGS=@LDFLAGS@ -L$(LIBSENT) -lsent @LIBS@ `$(LIBSENT)/libsent-config --libs` -lm +LDFLAGS=@LDFLAGS@ -L$(LIBSENT) `$(LIBSENT)/libsent-config --libs` RM=@RM@ -f prefix=@prefix@ exec_prefix=@exec_prefix@ From sumomo @ users.sourceforge.jp Thu Sep 25 13:49:06 2008 From: sumomo @ users.sourceforge.jp (sumomo @ users.sourceforge.jp) Date: Thu, 25 Sep 2008 13:49:06 +0900 Subject: [Julius-cvs 240] CVS update: julius4/mkss Message-ID: <1222318146.203875.29623.nullmailer@users.sourceforge.jp> Index: julius4/mkss/Makefile.in diff -u julius4/mkss/Makefile.in:1.2 julius4/mkss/Makefile.in:1.3 --- julius4/mkss/Makefile.in:1.2 Tue Dec 18 17:45:55 2007 +++ julius4/mkss/Makefile.in Thu Sep 25 13:49:06 2008 @@ -3,7 +3,7 @@ # Copyright (c) 2005-2007 Julius project team, Nagoya Institute of Technology # All rights reserved # -# $Id: Makefile.in,v 1.2 2007/12/18 08:45:55 sumomo Exp $ +# $Id: Makefile.in,v 1.3 2008/09/25 04:49:06 sumomo Exp $ # SHELL=/bin/sh .SUFFIXES: @@ -16,7 +16,7 @@ CC=@CC@ CFLAGS=@CFLAGS@ CPPFLAGS=-I. -I$(LIBJULIUS)/include -I$(LIBSENT)/include @CPPFLAGS@ `$(LIBSENT)/libsent-config --cflags` `$(LIBJULIUS)/libjulius-config --cflags` -LDFLAGS=@LDFLAGS@ -L$(LIBJULIUS) -ljulius -L$(LIBSENT) -lsent `$(LIBSENT)/libsent-config --libs` -lm `$(LIBJULIUS)/libjulius-config --libs` -lm +LDFLAGS=@LDFLAGS@ -L$(LIBJULIUS) `$(LIBJULIUS)/libjulius-config --libs` -L$(LIBSENT) `$(LIBSENT)/libsent-config --libs` RM=@RM@ -f prefix=@prefix@ exec_prefix=@exec_prefix@ From sumomo @ users.sourceforge.jp Thu Sep 25 13:49:06 2008 From: sumomo @ users.sourceforge.jp (sumomo @ users.sourceforge.jp) Date: Thu, 25 Sep 2008 13:49:06 +0900 Subject: [Julius-cvs 241] CVS update: julius4/gramtools/accept_check Message-ID: <1222318146.358435.29630.nullmailer@users.sourceforge.jp> Index: julius4/gramtools/accept_check/Makefile.in diff -u julius4/gramtools/accept_check/Makefile.in:1.2 julius4/gramtools/accept_check/Makefile.in:1.3 --- julius4/gramtools/accept_check/Makefile.in:1.2 Tue Dec 18 17:45:46 2007 +++ julius4/gramtools/accept_check/Makefile.in Thu Sep 25 13:49:06 2008 @@ -13,7 +13,8 @@ CC=@CC@ CFLAGS=@CFLAGS@ CPPFLAGS=@CPPFLAGS@ @DEFS@ -I$(LIBSENT)/include `$(LIBSENT)/libsent-config --cflags` -LDFLAGS=@LDFLAGS@ @LIBS@ -L$(LIBSENT) -lsent `$(LIBSENT)/libsent-config --libs` -lm +LDFLAGS=@LDFLAGS@ @LIBS@ -L$(LIBSENT) `$(LIBSENT)/libsent-config --libs` + RM=@RM@ -f prefix=@prefix@ exec_prefix=@exec_prefix@ From sumomo @ users.sourceforge.jp Thu Sep 25 13:49:06 2008 From: sumomo @ users.sourceforge.jp (sumomo @ users.sourceforge.jp) Date: Thu, 25 Sep 2008 13:49:06 +0900 Subject: [Julius-cvs 242] CVS update: julius4/gramtools/dfa_determinize Message-ID: <1222318146.496976.29637.nullmailer@users.sourceforge.jp> Index: julius4/gramtools/dfa_determinize/Makefile.in diff -u julius4/gramtools/dfa_determinize/Makefile.in:1.2 julius4/gramtools/dfa_determinize/Makefile.in:1.3 --- julius4/gramtools/dfa_determinize/Makefile.in:1.2 Tue Dec 18 17:45:46 2007 +++ julius4/gramtools/dfa_determinize/Makefile.in Thu Sep 25 13:49:06 2008 @@ -13,7 +13,7 @@ CC=@CC@ CFLAGS=@CFLAGS@ CPPFLAGS=@CPPFLAGS@ @DEFS@ -I$(LIBSENT)/include `$(LIBSENT)/libsent-config --cflags` -LDFLAGS=@LDFLAGS@ @LIBS@ -L$(LIBSENT) -lsent `$(LIBSENT)/libsent-config --libs` -lm +LDFLAGS=@LDFLAGS@ @LIBS@ -L$(LIBSENT) `$(LIBSENT)/libsent-config --libs` RM=@RM@ -f prefix=@prefix@ exec_prefix=@exec_prefix@ From sumomo @ users.sourceforge.jp Thu Sep 25 13:49:06 2008 From: sumomo @ users.sourceforge.jp (sumomo @ users.sourceforge.jp) Date: Thu, 25 Sep 2008 13:49:06 +0900 Subject: [Julius-cvs 243] CVS update: julius4/gramtools/dfa_minimize Message-ID: <1222318146.664209.29646.nullmailer@users.sourceforge.jp> Index: julius4/gramtools/dfa_minimize/Makefile.in diff -u julius4/gramtools/dfa_minimize/Makefile.in:1.2 julius4/gramtools/dfa_minimize/Makefile.in:1.3 --- julius4/gramtools/dfa_minimize/Makefile.in:1.2 Tue Dec 18 17:45:46 2007 +++ julius4/gramtools/dfa_minimize/Makefile.in Thu Sep 25 13:49:06 2008 @@ -13,7 +13,7 @@ CC=@CC@ CFLAGS=@CFLAGS@ CPPFLAGS=@CPPFLAGS@ @DEFS@ -I$(LIBSENT)/include `$(LIBSENT)/libsent-config --cflags` -LDFLAGS=@LDFLAGS@ @LIBS@ -L$(LIBSENT) -lsent `$(LIBSENT)/libsent-config --libs` -lm +LDFLAGS=@LDFLAGS@ @LIBS@ -L$(LIBSENT) `$(LIBSENT)/libsent-config --libs` RM=@RM@ -f prefix=@prefix@ exec_prefix=@exec_prefix@ From sumomo @ users.sourceforge.jp Thu Sep 25 13:49:06 2008 From: sumomo @ users.sourceforge.jp (sumomo @ users.sourceforge.jp) Date: Thu, 25 Sep 2008 13:49:06 +0900 Subject: [Julius-cvs 244] CVS update: julius4/gramtools/generate Message-ID: <1222318146.841640.29653.nullmailer@users.sourceforge.jp> Index: julius4/gramtools/generate/Makefile.in diff -u julius4/gramtools/generate/Makefile.in:1.2 julius4/gramtools/generate/Makefile.in:1.3 --- julius4/gramtools/generate/Makefile.in:1.2 Tue Dec 18 17:45:47 2007 +++ julius4/gramtools/generate/Makefile.in Thu Sep 25 13:49:06 2008 @@ -13,7 +13,7 @@ CC=@CC@ CFLAGS=@CFLAGS@ CPPFLAGS=@CPPFLAGS@ @DEFS@ -I$(LIBSENT)/include `$(LIBSENT)/libsent-config --cflags` -LDFLAGS=@LDFLAGS@ @LIBS@ -L$(LIBSENT) -lsent `$(LIBSENT)/libsent-config --libs` -lm +LDFLAGS=@LDFLAGS@ @LIBS@ -L$(LIBSENT) `$(LIBSENT)/libsent-config --libs` RM=@RM@ -f prefix=@prefix@ exec_prefix=@exec_prefix@ From sumomo @ users.sourceforge.jp Thu Sep 25 13:49:06 2008 From: sumomo @ users.sourceforge.jp (sumomo @ users.sourceforge.jp) Date: Thu, 25 Sep 2008 13:49:06 +0900 Subject: [Julius-cvs 245] CVS update: julius4/gramtools/nextword Message-ID: <1222318146.982582.29660.nullmailer@users.sourceforge.jp> Index: julius4/gramtools/nextword/Makefile.in diff -u julius4/gramtools/nextword/Makefile.in:1.2 julius4/gramtools/nextword/Makefile.in:1.3 --- julius4/gramtools/nextword/Makefile.in:1.2 Tue Dec 18 17:45:47 2007 +++ julius4/gramtools/nextword/Makefile.in Thu Sep 25 13:49:06 2008 @@ -14,7 +14,7 @@ CC=@CC@ CFLAGS=@CFLAGS@ CPPFLAGS=@CPPFLAGS@ @DEFS@ -I$(LIBSENT)/include `$(LIBSENT)/libsent-config --cflags` -LDFLAGS=@LDFLAGS@ @LIBS@ @READLINE_LIBS@ -L$(LIBSENT) -lsent `$(LIBSENT)/libsent-config --libs` -lm +LDFLAGS=@LDFLAGS@ @LIBS@ @READLINE_LIBS@ -L$(LIBSENT) `$(LIBSENT)/libsent-config --libs` RM=@RM@ -f prefix=@prefix@ exec_prefix=@exec_prefix@ From sumomo @ users.sourceforge.jp Thu Sep 25 13:54:59 2008 From: sumomo @ users.sourceforge.jp (sumomo @ users.sourceforge.jp) Date: Thu, 25 Sep 2008 13:54:59 +0900 Subject: [Julius-cvs 246] CVS update: julius4/libjulius/src Message-ID: <1222318499.632230.2049.nullmailer@users.sourceforge.jp> Index: julius4/libjulius/src/pass1.c diff -u julius4/libjulius/src/pass1.c:1.6 julius4/libjulius/src/pass1.c:1.7 --- julius4/libjulius/src/pass1.c:1.6 Tue Mar 25 17:12:54 2008 +++ julius4/libjulius/src/pass1.c Thu Sep 25 13:54:59 2008 @@ -36,7 +36,7 @@ * @author Akinobu Lee * @date Fri Oct 12 23:14:13 2007 * - * $Revision: 1.6 $ + * $Revision: 1.7 $ * */ /* @@ -605,9 +605,7 @@ MFCCCalc *mfcc; int rewind_frame; PROCESS_AM *am; - RecogProcess *p; boolean reprocess; - boolean started; /* initialize mfcc instances */ for(mfcc=recog->mfcclist;mfcc;mfcc=mfcc->next) { Index: julius4/libjulius/src/spsegment.c diff -u julius4/libjulius/src/spsegment.c:1.1 julius4/libjulius/src/spsegment.c:1.2 --- julius4/libjulius/src/spsegment.c:1.1 Tue Dec 18 17:45:49 2007 +++ julius4/libjulius/src/spsegment.c Thu Sep 25 13:54:59 2008 @@ -58,7 +58,7 @@ * @author Akinobu Lee * @date Wed Oct 17 12:47:29 2007 * - * $Revision: 1.1 $ + * $Revision: 1.2 $ * */ /* @@ -631,7 +631,6 @@ void finalize_segment(Recog *recog) { - int t; int spstart; RecogProcess *r; MFCCCalc *mfcc; @@ -837,7 +836,9 @@ boolean spsegment_need_restart(Recog *recog, int *rf_ret, boolean *repro_ret) { +#ifdef SPSEGMENT_NAIST RecogProcess *p; +#endif boolean ok_p; int rewind_frame; boolean reprocess; From sumomo @ users.sourceforge.jp Thu Sep 25 13:54:59 2008 From: sumomo @ users.sourceforge.jp (sumomo @ users.sourceforge.jp) Date: Thu, 25 Sep 2008 13:54:59 +0900 Subject: [Julius-cvs 247] CVS update: julius4/libsent/src/phmm Message-ID: <1222318499.814272.2062.nullmailer@users.sourceforge.jp> Index: julius4/libsent/src/phmm/gms_gprune.c diff -u julius4/libsent/src/phmm/gms_gprune.c:1.3 julius4/libsent/src/phmm/gms_gprune.c:1.4 --- julius4/libsent/src/phmm/gms_gprune.c:1.3 Mon Jul 7 14:50:12 2008 +++ julius4/libsent/src/phmm/gms_gprune.c Thu Sep 25 13:54:59 2008 @@ -12,7 +12,7 @@ * @author Akinobu LEE * @date Thu Feb 17 15:05:08 2005 * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * */ /* @@ -137,7 +137,7 @@ LOGPROB maxprob = LOG_ZERO; int s; PROB stream_weight; - LOGPROB logprob, logprobsum; + LOGPROB logprobsum; logprobsum = 0.0; for(s=0;sOP_nstream;s++) { From sumomo @ users.sourceforge.jp Thu Sep 25 13:55:00 2008 From: sumomo @ users.sourceforge.jp (sumomo @ users.sourceforge.jp) Date: Thu, 25 Sep 2008 13:55:00 +0900 Subject: [Julius-cvs 248] CVS update: julius4/libsent/src/dfa Message-ID: <1222318500.192477.2074.nullmailer@users.sourceforge.jp> Index: julius4/libsent/src/dfa/cpair.c diff -u julius4/libsent/src/dfa/cpair.c:1.3 julius4/libsent/src/dfa/cpair.c:1.4 --- julius4/libsent/src/dfa/cpair.c:1.3 Mon Jul 21 14:21:17 2008 +++ julius4/libsent/src/dfa/cpair.c Thu Sep 25 13:54:59 2008 @@ -18,7 +18,7 @@ * @author Akinobu LEE * @date Tue Feb 15 13:54:44 2005 * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * */ /* @@ -286,8 +286,7 @@ void malloc_dfa_cp(DFA_INFO *dfa, int term_num, int size) { - int i, j, x; - int maxlen; + int i; dfa->cp = (int **)mymalloc(sizeof(int *) * term_num); dfa->cplen = (int *)mymalloc(sizeof(int) * term_num); @@ -421,12 +420,12 @@ } fprintf(fp, "\n"); } - fprintf(fp, "bgn:", i); + fprintf(fp, "bgn:"); for(j=0;jcp_begin_len;j++) { fprintf(fp, " %d", dfa->cp_begin[j]); } fprintf(fp, "\n"); - fprintf(fp, "end:", i); + fprintf(fp, "end:"); for(j=0;jcp_end_len;j++) { fprintf(fp, " %d", dfa->cp_end[j]); } Index: julius4/libsent/src/dfa/dfa_util.c diff -u julius4/libsent/src/dfa/dfa_util.c:1.3 julius4/libsent/src/dfa/dfa_util.c:1.4 --- julius4/libsent/src/dfa/dfa_util.c:1.3 Mon Jul 21 14:21:17 2008 +++ julius4/libsent/src/dfa/dfa_util.c Thu Sep 25 13:54:59 2008 @@ -12,7 +12,7 @@ * @author Akinobu LEE * @date Tue Feb 15 14:18:36 2005 * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * */ /* @@ -41,7 +41,7 @@ dinfo->state_num, dinfo->arc_num, dinfo->term_num); dfa_cp_count_size(dinfo, &size, &allocsize); - fprintf(fp, " category-pair matrix: %ld bytes (%d bytes allocated)\n", size, allocsize); + fprintf(fp, " category-pair matrix: %ld bytes (%ld bytes allocated)\n", size, allocsize); } /** @@ -53,9 +53,6 @@ void print_dfa_cp(FILE *fp, DFA_INFO *dinfo) { - int i,j; - int t; - if (fp == NULL) return; fprintf(fp, "---------- terminal(category)-pair matrix ----------\n"); dfa_cp_output_rawdata(fp, dinfo); Index: julius4/libsent/src/dfa/mkcpair.c diff -u julius4/libsent/src/dfa/mkcpair.c:1.3 julius4/libsent/src/dfa/mkcpair.c:1.4 --- julius4/libsent/src/dfa/mkcpair.c:1.3 Mon Jul 21 14:21:17 2008 +++ julius4/libsent/src/dfa/mkcpair.c Thu Sep 25 13:54:59 2008 @@ -38,7 +38,7 @@ * @author Akinobu LEE * @date Tue Feb 15 14:35:33 2005 * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * */ /* @@ -122,8 +122,6 @@ boolean cpair_append(DFA_INFO *dst, DFA_INFO *src, int coffset) { - int i,j; - /* dst info must be already appended */ /* [coffset..dst->term_num-1] is the new categories */ if (dst->term_num - coffset != src->term_num) { From sumomo @ users.sourceforge.jp Thu Sep 25 13:55:00 2008 From: sumomo @ users.sourceforge.jp (sumomo @ users.sourceforge.jp) Date: Thu, 25 Sep 2008 13:55:00 +0900 Subject: [Julius-cvs 249] CVS update: julius4/libsent/src/hmminfo Message-ID: <1222318500.366452.2083.nullmailer@users.sourceforge.jp> Index: julius4/libsent/src/hmminfo/put_htkdata_info.c diff -u julius4/libsent/src/hmminfo/put_htkdata_info.c:1.4 julius4/libsent/src/hmminfo/put_htkdata_info.c:1.5 --- julius4/libsent/src/hmminfo/put_htkdata_info.c:1.4 Mon Jul 7 14:50:11 2008 +++ julius4/libsent/src/hmminfo/put_htkdata_info.c Thu Sep 25 13:55:00 2008 @@ -12,7 +12,7 @@ * @author Akinobu LEE * @date Tue Feb 15 23:36:00 2005 * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * */ /* @@ -122,7 +122,7 @@ book = (GCODEBOOK *)m->b; fprintf(fp, " tmix codebook = \"%s\" (size=%d)\n", book->name, book->num); for (i=0;imix_num;i++) { - fprintf(fp, " weight%d = %f\n", exp(m->bweight[i])); + fprintf(fp, " weight%d = %f\n", i, exp(m->bweight[i])); } } else { for (i=0;imix_num;i++) { @@ -141,7 +141,7 @@ void put_htk_state(FILE *fp, HTK_HMM_State *s) { - int st, i; + int st; if (fp == NULL) return; if (s == NULL) { From sumomo @ users.sourceforge.jp Thu Sep 25 13:56:20 2008 From: sumomo @ users.sourceforge.jp (sumomo @ users.sourceforge.jp) Date: Thu, 25 Sep 2008 13:56:20 +0900 Subject: [Julius-cvs 250] CVS update: julius4/julius Message-ID: <1222318580.593410.3382.nullmailer@users.sourceforge.jp> Index: julius4/julius/module.c diff -u julius4/julius/module.c:1.5 julius4/julius/module.c:1.6 --- julius4/julius/module.c:1.5 Tue Aug 5 18:50:53 2008 +++ julius4/julius/module.c Thu Sep 25 13:56:20 2008 @@ -325,7 +325,7 @@ if (multigram_delete(gid, cur->lm) == FALSE) { /* deletion marking failed */ fprintf(stderr, "Warning: msock(DELGRAM): gram #%d failed to delete, ignored\n", gid); /* tell module */ - module_send(module_sd, "\n.\n", gid); + module_send(module_sd, "\n.\n", gid); } } /* need to rebuild the global lexicon */ From sumomo @ users.sourceforge.jp Thu Sep 25 13:57:39 2008 From: sumomo @ users.sourceforge.jp (sumomo @ users.sourceforge.jp) Date: Thu, 25 Sep 2008 13:57:39 +0900 Subject: [Julius-cvs 251] CVS update: julius4/libsent/src/adin Message-ID: <1222318659.378945.3830.nullmailer@users.sourceforge.jp> Index: julius4/libsent/src/adin/adin_mic_linux_alsa.c diff -u julius4/libsent/src/adin/adin_mic_linux_alsa.c:1.7 julius4/libsent/src/adin/adin_mic_linux_alsa.c:1.8 --- julius4/libsent/src/adin/adin_mic_linux_alsa.c:1.7 Thu Jul 24 18:18:09 2008 +++ julius4/libsent/src/adin/adin_mic_linux_alsa.c Thu Sep 25 13:57:39 2008 @@ -44,7 +44,7 @@ * @author Akinobu LEE * @date Sun Feb 13 16:18:26 2005 * - * $Revision: 1.7 $ + * $Revision: 1.8 $ * */ /* @@ -74,8 +74,10 @@ static int latency = 32; ///< Lantency time in msec. You can override this value by specifying environment valuable "LATENCY_MSEC". static boolean need_swap; ///< Whether samples need byte swap +#if (SND_LIB_MAJOR == 0) static struct pollfd *ufds; ///< Poll descriptor static int count; ///< Poll descriptor count +#endif #define MAXPOLLINTERVAL 300 ///< Read timeout in msec. @@ -444,6 +446,9 @@ return(FALSE); } break; + default: + /* do nothing */ + break; } } From sumomo @ users.sourceforge.jp Thu Sep 25 13:58:31 2008 From: sumomo @ users.sourceforge.jp (sumomo @ users.sourceforge.jp) Date: Thu, 25 Sep 2008 13:58:31 +0900 Subject: [Julius-cvs 252] CVS update: julius4/plugin Message-ID: <1222318711.264770.5115.nullmailer@users.sourceforge.jp> From sumomo @ users.sourceforge.jp Thu Sep 25 14:00:04 2008 From: sumomo @ users.sourceforge.jp (sumomo @ users.sourceforge.jp) Date: Thu, 25 Sep 2008 14:00:04 +0900 Subject: [Julius-cvs 253] CVS update: julius4/adinrec Message-ID: <1222318804.330737.7777.nullmailer@users.sourceforge.jp> Index: julius4/adinrec/adinrec.c diff -u julius4/adinrec/adinrec.c:1.2 julius4/adinrec/adinrec.c:1.3 --- julius4/adinrec/adinrec.c:1.2 Tue Dec 18 17:45:46 2007 +++ julius4/adinrec/adinrec.c Thu Sep 25 14:00:02 2008 @@ -12,7 +12,7 @@ * @author Akinobu LEE * @date Wed Mar 23 20:33:01 2005 * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * */ /* @@ -44,6 +44,7 @@ { fprintf(stderr, "adinrec --- record one sentence input to a file\n"); fprintf(stderr, "Usage: adinrec [options..] filename\n"); + fprintf(stderr, " [-input mic|alsa|oss|esd|...] input source (mic)\n"); fprintf(stderr, " [-freq frequency] sampling frequency in Hz (%ld)\n", jconf->am_root->analysis.para_default.smp_freq); fprintf(stderr, " [-48] 48000Hz recording with down sampling (16kHz only)\n"); fprintf(stderr, " [-lv unsignedshort] silence cut level threshold (%d)\n", jconf->detect.level_thres); @@ -234,12 +235,16 @@ filename = argv[argc-1]; } + /* set default as same as "-input mic" */ + jconf->input.type = INPUT_WAVEFORM; + jconf->input.speech_input = SP_MIC; + jconf->input.device = SP_INPUT_DEFAULT; + /* read arguments and set parameters */ if (j_config_load_args(jconf, argc-1, argv) == -1) { fprintf(stderr, "Error reading arguments\n"); return -1; } - jconf->input.speech_input = SP_MIC; /* exit if no file name specified */ if (filename == NULL) { From sumomo @ users.sourceforge.jp Thu Sep 25 14:00:04 2008 From: sumomo @ users.sourceforge.jp (sumomo @ users.sourceforge.jp) Date: Thu, 25 Sep 2008 14:00:04 +0900 Subject: [Julius-cvs 254] CVS update: julius4/adintool Message-ID: <1222318804.673436.7793.nullmailer@users.sourceforge.jp> Index: julius4/adintool/adintool.c diff -u julius4/adintool/adintool.c:1.3 julius4/adintool/adintool.c:1.4 --- julius4/adintool/adintool.c:1.3 Wed Aug 6 15:00:32 2008 +++ julius4/adintool/adintool.c Thu Sep 25 14:00:04 2008 @@ -35,7 +35,7 @@ * @author Akinobu LEE * @date Wed Mar 23 20:43:32 2005 * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * */ /* @@ -101,6 +101,7 @@ fprintf(stderr, " file speech file (filename given from prompt)\n"); fprintf(stderr, " adinnet from adinnet client (I'm server)\n"); fprintf(stderr, " stdin standard tty input\n"); + fprintf(stderr, " (\"-input xxx\" can be used instead, as same as Julius)\n"); fprintf(stderr, "outputdev: output data to:\n"); fprintf(stderr, " file speech file (\"foo.0000.wav\" - \"foo.N.wav\"\n"); fprintf(stderr, " adinnet to adinnet server (I'm client)\n"); @@ -143,6 +144,8 @@ static boolean opt_in(Jconf *jconf, char *arg[], int argnum) { + jconf->input.plugin_source = -1; + jconf->input.type = INPUT_WAVEFORM; switch(arg[0][0]) { case 'm': #ifdef USE_MIC @@ -331,18 +334,50 @@ Jconf *jconf = recog->jconf; fprintf(stderr,"----\n"); - fprintf(stderr,"Input-Source: "); - switch(jconf->input.speech_input) { - case SP_RAWFILE: fprintf(stderr,"Wave File (filename from stdin)\n"); break; -#ifdef USE_MIC - case SP_MIC: fprintf(stderr,"Microphone\n"); break; -#endif + fprintf(stderr, "Input stream:\n"); + fprintf(stderr, "\t input type = "); + switch(jconf->input.type) { + case INPUT_WAVEFORM: + fprintf(stderr, "waveform\n"); + break; + case INPUT_VECTOR: + fprintf(stderr, "feature vector sequence\n"); + break; + } + fprintf(stderr, "\t input source = "); + if (jconf->input.plugin_source != -1) { + fprintf(stderr, "plugin\n"); + } else if (jconf->input.speech_input == SP_RAWFILE) { + fprintf(stderr, "waveform file\n"); + } else if (jconf->input.speech_input == SP_MFCFILE) { + fprintf(stderr, "feature vector file (HTK format)\n"); + } else if (jconf->input.speech_input == SP_STDIN) { + fprintf(stderr, "standard input\n"); + } else if (jconf->input.speech_input == SP_ADINNET) { + fprintf(stderr, "adinnet client\n"); #ifdef USE_NETAUDIO - case SP_NETAUDIO: fprintf(stderr,"NetAudio(DatLink) server on %s\n", jconf->input.netaudio_devname); break; + } else if (jconf->input.speech_input == SP_NETAUDIO) { + char *p; + fprintf(stderr, "NetAudio server on "); + if (jconf->input.netaudio_devname != NULL) { + fprintf(stderr, "%s\n", jconf->input.netaudio_devname); + } else if ((p = getenv("AUDIO_DEVICE")) != NULL) { + fprintf(stderr, "%s\n", p); + } else { + fprintf(stderr, "local port\n"); + } #endif - case SP_STDIN: fprintf(stderr,"Standard Input\n"); break; - case SP_ADINNET: fprintf(stderr,"adinnet client (port %d)\n", adinnet_port_in); break; + } else if (jconf->input.speech_input == SP_MIC) { + fprintf(stderr, "microphone\n"); + fprintf(stderr, "\t device API = "); + switch(jconf->input.device) { + case SP_INPUT_DEFAULT: fprintf(stderr, "default\n"); break; + case SP_INPUT_ALSA: fprintf(stderr, "alsa\n"); break; + case SP_INPUT_OSS: fprintf(stderr, "oss\n"); break; + case SP_INPUT_ESD: fprintf(stderr, "esd\n"); break; + } } + fprintf(stderr,"Segmentation: "); if (jconf->detect.silence_cut) { if (continuous_segment) { From sumomo @ users.sourceforge.jp Thu Sep 25 14:00:05 2008 From: sumomo @ users.sourceforge.jp (sumomo @ users.sourceforge.jp) Date: Thu, 25 Sep 2008 14:00:05 +0900 Subject: [Julius-cvs 255] CVS update: julius4/libjulius Message-ID: <1222318805.055911.7821.nullmailer@users.sourceforge.jp> Index: julius4/libjulius/Makefile.in diff -u julius4/libjulius/Makefile.in:1.3 julius4/libjulius/Makefile.in:1.4 --- julius4/libjulius/Makefile.in:1.3 Tue Jan 22 22:01:55 2008 +++ julius4/libjulius/Makefile.in Thu Sep 25 14:00:04 2008 @@ -5,7 +5,7 @@ # All rights reserved # -# $Id: Makefile.in,v 1.3 2008/01/22 13:01:55 sumomo Exp $ +# $Id: Makefile.in,v 1.4 2008/09/25 05:00:04 sumomo Exp $ # SHELL=/bin/sh .SUFFIXES: @@ -18,7 +18,7 @@ CC=@CC@ CFLAGS=@CFLAGS@ CPPFLAGS=-Iinclude -I$(LIBSENT)/include @CPPFLAGS@ `$(LIBSENT)/libsent-config --cflags` -LDFLAGS=@LDFLAGS@ -L$(LIBSENT) -lsent @LIBS@ `$(LIBSENT)/libsent-config --libs` -lm +LDFLAGS=@LDFLAGS@ @LIBS@ -L$(LIBSENT) `$(LIBSENT)/libsent-config --libs` RM=@RM@ -f AR=@AR@ r RANLIB=@RANLIB@ @@ -74,6 +74,7 @@ src/confnet.o \ src/gmm.o \ src/word_align.o \ +src/plugin.o \ src/version.o ############################################################ Index: julius4/libjulius/configure diff -u julius4/libjulius/configure:1.4 julius4/libjulius/configure:1.5 --- julius4/libjulius/configure:1.4 Tue May 27 18:16:39 2008 +++ julius4/libjulius/configure Thu Sep 25 14:00:04 2008 @@ -58,6 +58,8 @@ --enable-decoder-vad enable a new decoder-based VAD by NAIST team" ac_help="$ac_help --enable-power-reject enable post rejection by power" +ac_help="$ac_help + --disable-plugin disable plugin support" # Initialize some variables set by options. # The variables have the same names as the options, with @@ -851,6 +853,22 @@ fi +# Check whether --enable-plugin or --disable-plugin was given. +if test "${enable_plugin+set}" = set; then + enableval="$enable_plugin" + if test "$enableval" = yes; then + cat >> confdefs.h <<\EOF +#define ENABLE_PLUGIN 1 +EOF + +fi + +else + cat >> confdefs.h <<\EOF +#define ENABLE_PLUGIN 1 +EOF + +fi if test "$use_cm" = yes; then @@ -989,7 +1007,7 @@ fi echo $ac_n "checking host system type""... $ac_c" 1>&6 -echo "configure:993: checking host system type" >&5 +echo "configure:1011: checking host system type" >&5 host_alias=$host case "$host_alias" in @@ -1011,7 +1029,7 @@ echo $ac_n "checking host-specific optimization flag""... $ac_c" 1>&6 -echo "configure:1015: checking host-specific optimization flag" >&5 +echo "configure:1033: checking host-specific optimization flag" >&5 if test -z "$CFLAGS" ; then OPTFLAG=../support/cflags.${host_cpu}-${host_vendor}-${host_os} if test -f "$OPTFLAG" ; then @@ -1027,7 +1045,7 @@ # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1031: checking for $ac_word" >&5 +echo "configure:1049: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1057,7 +1075,7 @@ # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1061: checking for $ac_word" >&5 +echo "configure:1079: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1108,7 +1126,7 @@ # Extract the first word of "cl", so it can be a program name with args. set dummy cl; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1112: checking for $ac_word" >&5 +echo "configure:1130: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1140,7 +1158,7 @@ fi echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6 -echo "configure:1144: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5 +echo "configure:1162: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5 ac_ext=c # CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. @@ -1151,12 +1169,12 @@ cat > conftest.$ac_ext << EOF -#line 1155 "configure" +#line 1173 "configure" #include "confdefs.h" main(){return(0);} EOF -if { (eval echo configure:1160: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:1178: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then ac_cv_prog_cc_works=yes # If we can't run a trivial program, we are probably using a cross compiler. if (./conftest; exit) 2>/dev/null; then @@ -1182,12 +1200,12 @@ { echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; } fi echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6 -echo "configure:1186: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5 +echo "configure:1204: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5 echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6 cross_compiling=$ac_cv_prog_cc_cross echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6 -echo "configure:1191: checking whether we are using GNU C" >&5 +echo "configure:1209: checking whether we are using GNU C" >&5 if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1196,7 +1214,7 @@ yes; #endif EOF -if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:1200: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then +if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:1218: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then ac_cv_prog_gcc=yes else ac_cv_prog_gcc=no @@ -1215,7 +1233,7 @@ ac_save_CFLAGS="$CFLAGS" CFLAGS= echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6 -echo "configure:1219: checking whether ${CC-cc} accepts -g" >&5 +echo "configure:1237: checking whether ${CC-cc} accepts -g" >&5 if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1247,7 +1265,7 @@ fi echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6 -echo "configure:1251: checking how to run the C preprocessor" >&5 +echo "configure:1269: checking how to run the C preprocessor" >&5 # On Suns, sometimes $CPP names a directory. if test -n "$CPP" && test -d "$CPP"; then CPP= @@ -1262,13 +1280,13 @@ # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. cat > conftest.$ac_ext < Syntax Error EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1272: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:1290: \"$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 : @@ -1279,13 +1297,13 @@ rm -rf conftest* CPP="${CC-cc} -E -traditional-cpp" cat > conftest.$ac_ext < Syntax Error EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1289: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:1307: \"$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 : @@ -1296,13 +1314,13 @@ rm -rf conftest* CPP="${CC-cc} -nologo -E" cat > conftest.$ac_ext < Syntax Error EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1306: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:1324: \"$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 : @@ -1339,7 +1357,7 @@ # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" # ./install, which can be erroneously created by make from ./install.sh. echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6 -echo "configure:1343: checking for a BSD compatible install" >&5 +echo "configure:1361: checking for a BSD compatible install" >&5 if test -z "$INSTALL"; then if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -1394,7 +1412,7 @@ # Extract the first word of "rm", so it can be a program name with args. set dummy rm; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1398: checking for $ac_word" >&5 +echo "configure:1416: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_path_RM'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1429,7 +1447,7 @@ # Extract the first word of "ar", so it can be a program name with args. set dummy ar; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1433: checking for $ac_word" >&5 +echo "configure:1451: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_path_AR'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1464,7 +1482,7 @@ # Extract the first word of "ranlib", so it can be a program name with args. set dummy ranlib; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1468: checking for $ac_word" >&5 +echo "configure:1486: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1494,12 +1512,12 @@ echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6 -echo "configure:1498: checking for ANSI C header files" >&5 +echo "configure:1516: checking for ANSI C header files" >&5 if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include @@ -1507,7 +1525,7 @@ #include EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1511: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:1529: \"$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* @@ -1524,7 +1542,7 @@ if test $ac_cv_header_stdc = yes; then # SunOS 4.x string.h does not declare mem*, contrary to ANSI. cat > conftest.$ac_ext < EOF @@ -1542,7 +1560,7 @@ if test $ac_cv_header_stdc = yes; then # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. cat > conftest.$ac_ext < EOF @@ -1563,7 +1581,7 @@ : else cat > conftest.$ac_ext < #define ISLOWER(c) ('a' <= (c) && (c) <= 'z') @@ -1574,7 +1592,7 @@ exit (0); } EOF -if { (eval echo configure:1578: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:1596: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then : else @@ -1599,12 +1617,12 @@ echo $ac_n "checking for working const""... $ac_c" 1>&6 -echo "configure:1603: checking for working const" >&5 +echo "configure:1621: checking for working const" >&5 if eval "test \"`echo '$''{'ac_cv_c_const'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:1675: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_c_const=yes else @@ -1675,12 +1693,12 @@ echo $ac_n "checking return type of signal handlers""... $ac_c" 1>&6 -echo "configure:1679: checking return type of signal handlers" >&5 +echo "configure:1697: checking return type of signal handlers" >&5 if eval "test \"`echo '$''{'ac_cv_type_signal'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include @@ -1697,7 +1715,7 @@ int i; ; return 0; } EOF -if { (eval echo configure:1701: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:1719: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_type_signal=void else @@ -1721,18 +1739,18 @@ freebsd*) # FreeBSD echo $ac_n "checking for linking POSIX threaded process""... $ac_c" 1>&6 -echo "configure:1725: checking for linking POSIX threaded process" >&5 +echo "configure:1743: checking for linking POSIX threaded process" >&5 ac_save_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS -pthread" cat > conftest.$ac_ext < int main() { pthread_equal(NULL,NULL); ; return 0; } EOF -if { (eval echo configure:1736: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:1754: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* use_pthread=yes cat >> confdefs.h <<\EOF @@ -1753,18 +1771,18 @@ *) # other with libpthread echo $ac_n "checking for POSIX thread library in -lpthread""... $ac_c" 1>&6 -echo "configure:1757: checking for POSIX thread library in -lpthread" >&5 +echo "configure:1775: checking for POSIX thread library in -lpthread" >&5 ac_save_LIBS_p="$LIBS" LIBS="$LIBS -lpthread" cat > conftest.$ac_ext < int main() { pthread_equal(NULL,NULL); ; return 0; } EOF -if { (eval echo configure:1768: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:1786: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* use_pthread=yes cat >> confdefs.h <<\EOF Index: julius4/libjulius/configure.in diff -u julius4/libjulius/configure.in:1.4 julius4/libjulius/configure.in:1.5 --- julius4/libjulius/configure.in:1.4 Tue May 27 18:16:39 2008 +++ julius4/libjulius/configure.in Thu Sep 25 14:00:04 2008 @@ -4,7 +4,7 @@ dnl Copyright (c) 2005-2007 Julius project team, Nagoya Institute of Technology dnl All rights reserved dnl -dnl $Id: configure.in,v 1.4 2008/05/27 09:16:39 sumomo Exp $ +dnl $Id: configure.in,v 1.5 2008/09/25 05:00:04 sumomo Exp $ dnl AC_INIT(src/search_bestfirst_main.c) @@ -201,7 +201,13 @@ ,want_power_reject=no ) - +dnl plugin support +AC_ARG_ENABLE(plugin, +[ --disable-plugin disable plugin support], +if test "$enableval" = yes; then + AC_DEFINE(ENABLE_PLUGIN) +fi +,AC_DEFINE(ENABLE_PLUGIN)) dnl CM options check if test "$use_cm" = yes; then From sumomo @ users.sourceforge.jp Thu Sep 25 14:00:05 2008 From: sumomo @ users.sourceforge.jp (sumomo @ users.sourceforge.jp) Date: Thu, 25 Sep 2008 14:00:05 +0900 Subject: [Julius-cvs 256] CVS update: julius4/libjulius/include/julius Message-ID: <1222318805.606951.7848.nullmailer@users.sourceforge.jp> Index: julius4/libjulius/include/julius/config.h.in diff -u julius4/libjulius/include/julius/config.h.in:1.2 julius4/libjulius/include/julius/config.h.in:1.3 --- julius4/libjulius/include/julius/config.h.in:1.2 Tue Dec 18 17:45:49 2007 +++ julius4/libjulius/include/julius/config.h.in Thu Sep 25 14:00:05 2008 @@ -28,7 +28,7 @@ * @author Akinobu LEE * @date Sat Feb 19 12:53:54 2005 * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * */ @@ -245,3 +245,9 @@ * */ #undef POWER_REJECT + +/** + * If defined, enable plugin support using dynamic object loading + * + */ +#undef ENABLE_PLUGIN Index: julius4/libjulius/include/julius/extern.h diff -u julius4/libjulius/include/julius/extern.h:1.6 julius4/libjulius/include/julius/extern.h:1.7 --- julius4/libjulius/include/julius/extern.h:1.6 Tue Jun 17 10:20:50 2008 +++ julius4/libjulius/include/julius/extern.h Thu Sep 25 14:00:05 2008 @@ -12,7 +12,7 @@ * @author Akinobu LEE * @date Mon Mar 7 23:19:14 2005 * - * $Revision: 1.6 $ + * $Revision: 1.7 $ * */ /* @@ -143,6 +143,7 @@ void RealTimeCMNUpdate(MFCCCalc *mfcc, Recog *recog); void RealTimeTerminate(Recog *recog); void realbeam_free(Recog *recog); +int mfcc_go(Recog *recog, int (*ad_check)(Recog *)); /* word_align.c */ void word_align(WORD_ID *words, short wnum, HTK_Param *param, Sentence *s, RecogProcess *r); @@ -173,7 +174,6 @@ void system_bootup(Recog *recog); /* m_adin.c */ boolean adin_initialize(Recog *recog); -boolean adin_initialize_user(Recog *recog, void *arg); /* m_fusion.c */ boolean j_load_am(Recog *recog, JCONF_AM *amconf); boolean j_load_lm(Recog *recog, JCONF_LM *lmconf); @@ -290,3 +290,24 @@ void result_sentence_malloc(RecogProcess *r, int num); void result_sentence_free(RecogProcess *r); void clear_result(RecogProcess *r); + +/* plugin.c */ +int plugin_get_id(char *name); +void plugin_init(); +boolean plugin_load_file(char *file); +boolean plugin_load_dir(char *dir); +void plugin_load_dirs(char *dirent); +int plugin_find_optname(char *optfuncname, char *str); +FUNC_VOID plugin_get_func(int sid, char *name); +boolean plugin_exec_engine_startup(Recog *recog); +void plugin_exec_adin_captured(short *buf, int len); +void plugin_exec_adin_triggered(short *buf, int len); +void plugin_exec_vector_postprocess(VECT *vecbuf, int veclen, int nframe); +void plugin_exec_vector_postprocess_all(HTK_Param *param); +void plugin_exec_process_result(Recog *recog); +boolean mfc_module_init(MFCCCalc *mfcc, Recog *recog); +boolean mfc_module_set_header(MFCCCalc *mfcc, Recog *recog); +boolean mfc_module_standby(MFCCCalc *mfcc); +boolean mfc_module_begin(MFCCCalc *mfcc); +boolean mfc_module_end(MFCCCalc *mfcc); +int mfc_module_read(MFCCCalc *mfcc, int *new_t); Index: julius4/libjulius/include/julius/global.h diff -u julius4/libjulius/include/julius/global.h:1.3 julius4/libjulius/include/julius/global.h:1.4 --- julius4/libjulius/include/julius/global.h:1.3 Tue Mar 18 01:58:38 2008 +++ julius4/libjulius/include/julius/global.h Thu Sep 25 14:00:05 2008 @@ -14,7 +14,7 @@ * @author Akinobu Lee * @date Sun Sep 18 23:53:17 2005 * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * */ /* @@ -31,6 +31,7 @@ #include #include #include +#include /** * If GLOBAL_VARIABLE_DEFINE is defined, global variables are actually made. @@ -50,4 +51,8 @@ GLOBAL boolean debug2_flag GLOBAL_VAL(FALSE); GLOBAL boolean callback_debug_flag GLOBAL_VAL(FALSE); +/* function list for adin process callback */ +GLOBAL PLUGIN_ENTRY **global_plugin_list GLOBAL_VAL(NULL); +GLOBAL int global_plugin_loaded_file_num GLOBAL_VAL(0); + #endif /* __J_GLOBAL_H__ */ Index: julius4/libjulius/include/julius/jconf.h diff -u julius4/libjulius/include/julius/jconf.h:1.6 julius4/libjulius/include/julius/jconf.h:1.7 --- julius4/libjulius/include/julius/jconf.h:1.6 Thu Sep 25 13:22:57 2008 +++ julius4/libjulius/include/julius/jconf.h Thu Sep 25 14:00:05 2008 @@ -23,7 +23,7 @@ * @author Akinobu Lee * @date Fri Feb 16 13:42:28 2007 * - * $Revision: 1.6 $ + * $Revision: 1.7 $ * */ /* @@ -209,6 +209,11 @@ char *ssload_filename; } frontend; + /** + * Plugin source ID when using plugin (gprune_method is GPRUNE_SEL_USER) + */ + int gprune_plugin_source; + /* pointer to next instance */ struct __jconf_am__ *next; @@ -763,15 +768,29 @@ struct { /** + * Input source type. (waveform / mfc) + * + */ + int type; + + /** * Input source. * */ int speech_input; + /** * Input device. * */ int device; + + /** + * id of the selected plug-in if using plugin + * + */ + int plugin_source; + /** * Sampling frequency * Index: julius4/libjulius/include/julius/jfunc.h diff -u julius4/libjulius/include/julius/jfunc.h:1.3 julius4/libjulius/include/julius/jfunc.h:1.4 --- julius4/libjulius/include/julius/jfunc.h:1.3 Tue Jun 17 10:20:50 2008 +++ julius4/libjulius/include/julius/jfunc.h Thu Sep 25 14:00:05 2008 @@ -12,7 +12,7 @@ * @author Akinobu Lee * @date Tue Nov 6 22:41:00 2007 * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * */ /* @@ -51,7 +51,6 @@ Jconf *j_config_load_args_new(int argc, char *argv[]); Jconf *j_config_load_file_new(char *filename); boolean j_adin_init(Recog *recog); -boolean j_adin_init_user(Recog *recog, void *arg); char *j_get_current_filename(); void j_recog_info(Recog *recog); Recog *j_create_instance_from_jconf(Jconf *jconf); Index: julius4/libjulius/include/julius/julius.h diff -u julius4/libjulius/include/julius/julius.h:1.2 julius4/libjulius/include/julius/julius.h:1.3 --- julius4/libjulius/include/julius/julius.h:1.2 Tue Dec 18 17:45:49 2007 +++ julius4/libjulius/include/julius/julius.h Thu Sep 25 14:00:05 2008 @@ -12,7 +12,7 @@ * @author Akinobu LEE * @date Thu Mar 17 21:08:21 2005 * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * */ /* @@ -57,6 +57,9 @@ #include /* read Julius/Julian includes */ +#ifdef ENABLE_PLUGIN +#include +#endif #include #include #include Index: julius4/libjulius/include/julius/plugin.h diff -u /dev/null julius4/libjulius/include/julius/plugin.h:1.1 --- /dev/null Thu Sep 25 14:00:05 2008 +++ julius4/libjulius/include/julius/plugin.h Thu Sep 25 14:00:05 2008 @@ -0,0 +1,109 @@ +/** + * @file plugin.h + * + * + * @brief Plugin related header + * + * + * + * @brief プラグイン用ヘッダ + * + * + * @author Akinobu Lee + * @date Sat Aug 2 13:04:15 2008 + * + * $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, Nagoya Institute of Technology + * All rights reserved + */ + +#ifndef __JULIUS_PLUGIN__ +#define __JULIUS_PLUGIN__ + +#include + +/** + * Plug-in file suffix + * + */ +#define PLUGIN_SUFFIX ".jpi" + +/** + * List of plugin function names + * + */ +#define PLUGIN_FUNCTION_NAMELIST { \ + "adin_get_optname", \ + "adin_get_configuration", "adin_standby", \ + "adin_open", "adin_read", "adin_close", \ + "adin_resume", "adin_pause", "adin_terminate", \ + "adin_postprocess", "adin_postprocess_triggered", \ + "fvin_get_optname", \ + "fvin_get_configuration", "fvin_standby", \ + "fvin_open", "fvin_read", "fvin_close", \ + "fvin_resume", "fvin_pause", "fvin_terminate", \ + "fvin_postprocess", \ + "calcmix_get_optname", "calcmix", "calcmix_init", "calcmix_free", \ + "result_best_str", \ + "startup"} + +/** + * Typedef for loaded module + * + */ +#if defined(_WIN32) && !defined(__CYGWIN32__) +typedef HMODULE PLUGIN_MODULE; +#else +typedef void* PLUGIN_MODULE; +#endif + +/** + * define for "none" + * + */ +#define PLUGIN_NONE NULL + +/** + * Function definition + * + */ +typedef void (*FUNC_VOID)(); +typedef char * (*FUNC_STR)(); +typedef int (*FUNC_INT)(); + +/** + * Plugin function entry + * + */ +typedef struct __j_plugin_entry__ { + int id; + int source_id; + FUNC_VOID func; + struct __j_plugin_entry__ *next; +} PLUGIN_ENTRY; + +/* include headers for dynamic loading */ +/* unix, cygwin = dlopen */ +/* mingw, VS = non (should emulate using win32 func.) */ +#ifdef _WIN32 +# ifdef __CYGWIN32__ +# include +# else +# include +# include +# define dlopen(P,G) (void *)LoadLibrary(P) +# define dlsym(D, F) (void *)GetProcAddress((HMODULE)D, F) +# define dlclose(D) FreeLibrary((HMODULE)D) +/* dlerror() is defined in plugins.c */ +# define RTLD_LAZY 0 /* dummy */ +# endif +#else /* UNIX */ +# include +#endif + +#endif /* __JULIUS_PLUGIN__ */ Index: julius4/libjulius/include/julius/recog.h diff -u julius4/libjulius/include/julius/recog.h:1.3 julius4/libjulius/include/julius/recog.h:1.4 --- julius4/libjulius/include/julius/recog.h:1.3 Mon Jul 7 14:50:10 2008 +++ julius4/libjulius/include/julius/recog.h Thu Sep 25 14:00:05 2008 @@ -45,13 +45,13 @@ * +- MFCCCalc[] (linked list) (generated from HMM + GMM) * +- PROCESS_AM[] (linked list) * +- *pointer to JCONF_AM - * +- *pointer to MFCCCalc + * +- *pointer to MFCCCalc * +- hmminfo, hmm_gs * +- hmmwrk - * +- multipath, ccd_flag, cmn_loaded + * +- multipath, ccd_flag, cmn_loaded * +- PROCESS_LM[] (linked list) * +- *pointer to JCONF_LM - * +- *pointer to PROCESS_AM + * +- *pointer to PROCESS_AM * +- lmtype, lmvar * +- winfo * +- ngram or grammars @@ -60,8 +60,8 @@ * +- *pointer to JCONF_SEARCH * +- *pointer to PROCESS_AM * +- *pointer to PROCESS_LM - * +- lmtype, lmvar - * +- misc. param + * +- lmtype, lmvar + * +- misc. param * +- GMMCalc * +- *JCONF_AM for GMM * +- *pointer to MFCCCalc @@ -70,7 +70,7 @@ * @author Akinobu Lee * @date Fri Feb 16 13:42:28 2007 * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * */ /* @@ -129,9 +129,9 @@ #ifdef UNIGRAM_FACTORING /* for wordend processing with 1-gram factoring */ LOGPROB wordend_best_score; ///< Best score of word-end nodes - int wordend_best_node; ///< Node id of the best wordend nodes + int wordend_best_node; ///< Node id of the best wordend nodes TRELLIS_ATOM *wordend_best_tre; ///< Trellis word corresponds to above - WORD_ID wordend_best_last_cword; ///< Last context-aware word of above + WORD_ID wordend_best_last_cword; ///< Last context-aware word of above #endif int totalnodenum; ///< Allocated number of nodes in @a token @@ -155,15 +155,15 @@ boolean first_sparea; ///< TRUE when we are in the first pause area int sp_duration; ///< Number of current successive sp frame #ifdef SPSEGMENT_NAIST - boolean after_trigger; ///< TRUE if speech already triggered - int trigger_duration; ///< Current speech duration at uptrigger detection - boolean want_rewind; ///< TRUE if process wants mfcc rewinding - int rewind_frame; ///< Place to rewind to + boolean after_trigger; ///< TRUE if speech already triggered + int trigger_duration; ///< Current speech duration at uptrigger detection + boolean want_rewind; ///< TRUE if process wants mfcc rewinding + int rewind_frame; ///< Place to rewind to boolean want_rewind_reprocess; ///< TRUE if requires re-processing after rewind #endif - char *pausemodelnames; ///< pause model name string to detect segment - char **pausemodel; ///< each pause model name to detect segment - int pausemodelnum; ///< num of pausemodel + char *pausemodelnames; ///< pause model name string to detect segment + char **pausemodel; ///< each pause model name to detect segment + int pausemodelnum; ///< num of pausemodel } FSBeam; @@ -205,38 +205,38 @@ NODE *current; ///< Current node for debug #ifdef CONFIDENCE_MEASURE - LOGPROB cm_alpha; ///< alpha scaling value from jconf + LOGPROB cm_alpha; ///< alpha scaling value from jconf # ifdef CM_MULTIPLE_ALPHA - LOGPROB *cmsumlist; ///< Sum of cm score for each alpha coef. - int cmsumlistlen; ///< Allocated length of cmsumlist. + LOGPROB *cmsumlist; ///< Sum of cm score for each alpha coef. + int cmsumlistlen; ///< Allocated length of cmsumlist. # endif # ifdef CM_SEARCH LOGPROB cm_tmpbestscore; ///< Temporal best score for summing up scores # ifndef CM_MULTIPLE_ALPHA - LOGPROB cm_tmpsum; ///< Sum of CM score + LOGPROB cm_tmpsum; ///< Sum of CM score # endif - int l_stacksize; ///< Local stack size for CM - int l_stacknum; ///< Num of hypo. in local stack for CM - NODE *l_start; ///< Top node of local stack for CM - NODE *l_bottom; ///< bottom node of local stack for CM + int l_stacksize; ///< Local stack size for CM + int l_stacknum; ///< Num of hypo. in local stack for CM + NODE *l_start; ///< Top node of local stack for CM + NODE *l_bottom; ///< bottom node of local stack for CM # endif # ifdef CM_NBEST - LOGPROB *sentcm = NULL; ///< Confidence score of each sentence - LOGPROB *wordcm = NULL; ///< Confidence score of each word voted from @a sentcm - int sentnum; ///< Allocated length of @a sentcm + LOGPROB *sentcm = NULL; ///< Confidence score of each sentence + LOGPROB *wordcm = NULL; ///< Confidence score of each word voted from @a sentcm + int sentnum; ///< Allocated length of @a sentcm # endif #endif /* CONFIDENCE_MEASURE */ LOGPROB *wordtrellis[2]; ///< Buffer to compute viterbi path of a word - LOGPROB *g; ///< Buffer to hold source viterbi scores - HMM_Logical **phmmseq; ///< Phoneme sequence to be computed - int phmmlen_max; ///< Maximum length of @a phmmseq. - boolean *has_sp; ///< Mark which phoneme allow short pause for multi-path mode + LOGPROB *g; ///< Buffer to hold source viterbi scores + HMM_Logical **phmmseq; ///< Phoneme sequence to be computed + int phmmlen_max; ///< Maximum length of @a phmmseq. + boolean *has_sp; ///< Mark which phoneme allow short pause for multi-path mode #ifdef GRAPHOUT_PRECISE_BOUNDARY short *wend_token_frame[2]; ///< Propagating token of word-end frame to detect corresponding end-of-words at word head LOGPROB *wend_token_gscore[2]; ///< Propagating token of scores at word-end to detect corresponding end-of-words at word head - short *wef; ///< Work area for word-end frame tokens for v2 - LOGPROB *wes; ///< Work area for word-end score tokens for v2 + short *wef; ///< Work area for word-end frame tokens for v2 + LOGPROB *wes; ///< Work area for word-end score tokens for v2 #endif } StackDecode; @@ -257,10 +257,10 @@ */ typedef struct __gmm_calc__{ LOGPROB *gmm_score; ///< Current accumurated scores for each GMM - boolean *is_voice; ///< True if corresponding model designates speech, FALSE if noise + 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 + 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 @@ -272,24 +272,24 @@ VECT *OP_vec; ///< Local workarea to hold the input vector of current frame short OP_veclen; ///< Local workarea to hold the length of above HTK_HMM_Data *max_d; ///< Hold model of the maximum score - int max_i; ///< Index of max_d + int max_i; ///< Index of max_d #ifdef CONFIDENCE_MEASURE LOGPROB gmm_max_cm; ///< Hold maximum score #endif #ifdef GMM_VAD LOGPROB *rates; ///< voice rate of recent N frames (cycle buffer) - int nframe; ///< Length of rates + int nframe; ///< Length of rates boolean filled; - int framep; ///< Current frame pointer + int framep; ///< Current frame pointer - boolean in_voice; ///< TRUE if currently in voice area - boolean up_trigger; ///< TRUE when detect up trigger - boolean down_trigger; ///< TRUE when detect down trigger - boolean after_trigger; ///< TRUE when currently we are processing speech segment - boolean want_rewind; ///< TRUE if GMM wants rewinding its MFCC + boolean in_voice; ///< TRUE if currently in voice area + boolean up_trigger; ///< TRUE when detect up trigger + boolean down_trigger; ///< TRUE when detect down trigger + boolean after_trigger; ///< TRUE when currently we are processing speech segment + boolean want_rewind; ///< TRUE if GMM wants rewinding its MFCC boolean want_rewind_reprocess; ///< TRUE if GMM wants re-processing after rewind - int rewind_frame; ///< Frame to rewind - int duration; ///< Current GMM duration work + int rewind_frame; ///< Frame to rewind + int duration; ///< Current GMM duration work #endif } GMMCalc; @@ -298,7 +298,7 @@ * */ typedef struct __sentence__ { - WORD_ID word[MAXSEQNUM]; ///< Sequence of word ID + WORD_ID word[MAXSEQNUM]; ///< Sequence of word ID int word_num; ///< Number of words in the sentence LOGPROB score; ///< Likelihood (LM+AM) LOGPROB confidence[MAXSEQNUM]; ///< Word confidence scores @@ -345,6 +345,8 @@ boolean (*ad_resume)(); /// Pointer to function to pause recording boolean (*ad_pause)(); + /// Pointer to function to terminate current recording immediately + boolean (*ad_terminate)(); /// Pointer to function to read samples int (*ad_read)(SP16 *, int); @@ -366,7 +368,7 @@ int sblen; ///< Current length of @a swapbuf int rest_tail; ///< Samples not processed yet in swap buffer - ZEROCROSS zc; ///< Work area for zero-cross computation + ZEROCROSS zc; ///< Work area for zero-cross computation #ifdef HAVE_PTHREAD /* Variables related to POSIX threading */ @@ -388,6 +390,11 @@ * */ boolean adinthread_buffer_overflowed; + /** + * TRUE if adin thread ended + * + */ + boolean adinthread_ended; boolean ignore_speech_while_recog; ///< TRUE if ignore speech input between call, while waiting recognition process @@ -408,9 +415,12 @@ boolean end_of_stream; ///< TRUE if we have reached the end of stream boolean need_init; ///< if TRUE, initialize buffer on startup - DS_BUFFER *ds; ///< Filter buffer for 48-to-16 conversion + DS_BUFFER *ds; ///< Filter buffer for 48-to-16 conversion boolean rehash; ///< TRUE is want rehash at rewinding on decoder-based VAD + + boolean input_side_segment; ///< TRUE if segmentation requested by ad_read + } ADIn; /** @@ -440,7 +450,7 @@ WordGraph *wg; ///< List of word graph - CN_CLUSTER *confnet; ///< List of confusion network clusters + CN_CLUSTER *confnet; ///< List of confusion network clusters Sentence pass1; ///< Recognition result on the 1st pass @@ -642,6 +652,39 @@ */ boolean segmented; + /** + * TRUE if an input functionhas decided segmented + * + */ + boolean segmented_by_input; + + /** + * id of an plugin module if MFCC should be obtained via plugin + * + */ + int plugin_source; + + /** + * Function entry points for plugin input + * + */ + struct { + /// Pointer to function for device initialization (call once on startup) + boolean (*fv_standby)(); + /// Pointer to function to open audio stream for capturing + boolean (*fv_begin)(); + /// Pointer to function to read samples + int (*fv_read)(VECT *, int); + /// Pointer to function to close audio stream capturing + boolean (*fv_end)(); + /// Pointer to function to begin / restart recording + boolean (*fv_resume)(); + /// Pointer to function to pause recording + boolean (*fv_pause)(); + /// Pointer to function to terminate current recording immediately + boolean (*fv_terminate)(); + } func; + #ifdef POWER_REJECT float avg_power; #endif From sumomo @ users.sourceforge.jp Thu Sep 25 14:00:07 2008 From: sumomo @ users.sourceforge.jp (sumomo @ users.sourceforge.jp) Date: Thu, 25 Sep 2008 14:00:07 +0900 Subject: [Julius-cvs 257] CVS update: julius4/libsent/include/sent Message-ID: <1222318807.253395.7908.nullmailer@users.sourceforge.jp> Index: julius4/libsent/include/sent/adin.h diff -u julius4/libsent/include/sent/adin.h:1.3 julius4/libsent/include/sent/adin.h:1.4 --- julius4/libsent/include/sent/adin.h:1.3 Tue Jul 1 13:29:46 2008 +++ julius4/libsent/include/sent/adin.h Thu Sep 25 14:00:07 2008 @@ -19,7 +19,7 @@ * @author Akinobu LEE * @date Thu Feb 10 17:22:36 2005 * - * $Revision: 1.3 $ + * $Revision: 1.4 $ */ /* * Copyright (c) 1991-2007 Kawahara Lab., Kyoto University @@ -46,14 +46,21 @@ #define HAS_ESD #endif -/// To select speech input source +/// Speech input type +enum { + INPUT_WAVEFORM, + INPUT_VECTOR +}; + +/// Speech input source enum { SP_RAWFILE, ///< Wavefile - SP_MIC, ///< Live microphone device + SP_MIC, ///< Live microphone device, or plugin SP_ADINNET, ///< Network client (adintool etc.) SP_MFCFILE, ///< HTK parameter file SP_NETAUDIO, ///< Live NetAudio/DatLink input - SP_STDIN ///< Standard input + SP_STDIN, ///< Standard input + SP_MFCMODULE ///< parameter module }; /// Input device Index: julius4/libsent/include/sent/hmm_calc.h diff -u julius4/libsent/include/sent/hmm_calc.h:1.5 julius4/libsent/include/sent/hmm_calc.h:1.6 --- julius4/libsent/include/sent/hmm_calc.h:1.5 Sun Jul 20 01:51:34 2008 +++ julius4/libsent/include/sent/hmm_calc.h Thu Sep 25 14:00:07 2008 @@ -13,7 +13,7 @@ * @author Akinobu LEE * @date Thu Feb 10 14:54:06 2005 * - * $Revision: 1.5 $ + * $Revision: 1.6 $ * */ /* @@ -38,9 +38,10 @@ * - GPRUNE_SEL_SAFE: safe pruning * - GPRUNE_SEL_HEURISTIC: heuristic pruning * - GPRUNE_SEL_BEAM: beam pruning + * - GPRUNE_SEL_USER: user-defined function * */ -enum{GPRUNE_SEL_UNDEF, GPRUNE_SEL_NONE, GPRUNE_SEL_SAFE, GPRUNE_SEL_HEURISTIC, GPRUNE_SEL_BEAM}; +enum{GPRUNE_SEL_UNDEF, GPRUNE_SEL_NONE, GPRUNE_SEL_SAFE, GPRUNE_SEL_HEURISTIC, GPRUNE_SEL_BEAM, GPRUNE_SEL_USER}; /** * @brief Score beam offset for GPRUNE_SEL_BEAM. From sumomo @ users.sourceforge.jp Thu Sep 25 14:00:07 2008 From: sumomo @ users.sourceforge.jp (sumomo @ users.sourceforge.jp) Date: Thu, 25 Sep 2008 14:00:07 +0900 Subject: [Julius-cvs 258] CVS update: julius4/libsent/src/adin Message-ID: <1222318807.706877.7919.nullmailer@users.sourceforge.jp> Index: julius4/libsent/src/adin/adin_tcpip.c diff -u julius4/libsent/src/adin/adin_tcpip.c:1.2 julius4/libsent/src/adin/adin_tcpip.c:1.3 --- julius4/libsent/src/adin/adin_tcpip.c:1.2 Tue Dec 18 17:45:50 2007 +++ julius4/libsent/src/adin/adin_tcpip.c Thu Sep 25 14:00:07 2008 @@ -45,7 +45,7 @@ * @author Akinobu LEE * @date Mon Feb 14 14:55:03 2005 * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * */ /* @@ -61,7 +61,6 @@ static int adinnet_sd = -1; ///< Listen socket for adinserv static int adinnet_asd = -1; ///< Accept socket for adinserv -static boolean last_is_segmented = FALSE; ///< FALSE if last segment was an end of connection #ifdef FORK_ADINNET static pid_t child; /* child process ID (0 if myself is child) */ @@ -87,8 +86,6 @@ return FALSE; } - last_is_segmented = FALSE; - jlog("Stat: adin_tcpip: ready for server\n"); return TRUE; @@ -102,10 +99,6 @@ boolean adin_tcpip_begin() { - if (last_is_segmented) { - /* just wait for the next segment to be received */ - jlog("Stat: adin_tcpip: keep connection for next segment\n"); - } else { #ifdef FORK_ADINNET /***********************************/ /*** server infinite loop here!! ***/ @@ -137,7 +130,7 @@ } jlog("Stat: adin_tcpip: connected\n"); #endif /* FORK_ADINNET */ - } + return TRUE; } @@ -155,7 +148,6 @@ boolean adin_tcpip_end() { - if (!last_is_segmented) { /* end of connection */ close_socket(adinnet_asd); #ifdef FORK_ADINNET @@ -166,7 +158,7 @@ /* wait for the next connection */ jlog("Stat: adin_tcpip: connection end\n"); #endif - } /* else, end of segment: wait for next input in current socket */ + return TRUE; } @@ -191,12 +183,12 @@ fd_set rfds; struct timeval tv; int status; - + /* check if some commands are waiting in queue */ FD_ZERO(&rfds); FD_SET(adinnet_asd, &rfds); tv.tv_sec = 0; - tv.tv_usec = 1; + tv.tv_usec = 10000; /* 10msec */ status = select(adinnet_asd+1, &rfds, NULL, NULL, &tv); if (status < 0) { /* error */ jlog("Error: adin_tcpip: failed to poll socket\n"); @@ -207,15 +199,13 @@ ret = rd(adinnet_asd, (char *)buf, &cnt, sampnum * sizeof(SP16)); if (ret == 0) { /* end of segment mark */ - last_is_segmented = TRUE; - return -1; + return -3; } if (ret < 0) { /* end of input, mark */ - last_is_segmented = FALSE; return -1; } - } else { /* no data */ + } else { /* time out, no data */ cnt = 0; } cnt /= sizeof(SP16); @@ -253,11 +243,41 @@ { int count; char com; + int cnt, ret; + fd_set rfds; + struct timeval tv; + int status; + static char *tmpbuf = NULL; + + /* check if some commands are waiting in queue */ + count = 0; + do { + FD_ZERO(&rfds); + FD_SET(adinnet_asd, &rfds); + tv.tv_sec = 0; + tv.tv_usec = 0; + status = select(adinnet_asd+1, &rfds, NULL, NULL, &tv); + if (status < 0) { /* error */ + jlog("Error: adin_tcpip: failed to poll socket\n"); + return FALSE; /* error return */ + } + if (status > 0) { /* there are some data */ + if (tmpbuf == NULL) tmpbuf = (char *)mymalloc(MAXSPEECHLEN); + ret = rd(adinnet_asd, tmpbuf, &cnt, MAXSPEECHLEN * sizeof(SP16)); + } + if (cnt > 0) count += cnt; + } while (status != 0); + if (count > 0) { + jlog("Stat: %d samples transfered while pause are flushed\n", count); + } + /* send resume command to adinnet client */ com = '1'; count = wt(adinnet_asd, &com, 1); if (count < 0) jlog("Warning: adin_tcpip: cannot send resume command to client\n"); jlog("Stat: adin_tcpip: sent resume command to client\n"); + + /* flush current buffer */ return TRUE; } From sumomo @ users.sourceforge.jp Thu Sep 25 14:00:08 2008 From: sumomo @ users.sourceforge.jp (sumomo @ users.sourceforge.jp) Date: Thu, 25 Sep 2008 14:00:08 +0900 Subject: [Julius-cvs 259] CVS update: julius4/libsent/src/phmm Message-ID: <1222318808.041662.7928.nullmailer@users.sourceforge.jp> Index: julius4/libsent/src/phmm/outprob_init.c diff -u julius4/libsent/src/phmm/outprob_init.c:1.3 julius4/libsent/src/phmm/outprob_init.c:1.4 --- julius4/libsent/src/phmm/outprob_init.c:1.3 Mon Jul 7 14:50:12 2008 +++ julius4/libsent/src/phmm/outprob_init.c Thu Sep 25 14:00:07 2008 @@ -34,7 +34,7 @@ * @author Akinobu LEE * @date Thu Feb 17 13:35:37 2005 * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * */ /* @@ -92,7 +92,7 @@ #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"); + jlog("Error: outprob_init: only \"-gprune none\" is supported when MSD-HMM enabled\n"); return FALSE; } #endif @@ -117,6 +117,9 @@ wrk->compute_gaussset_init = gprune_beam_init; wrk->compute_gaussset_free = gprune_beam_free; break; + case GPRUNE_SEL_USER: + /* assume user functions are already registered to the entries */ + break; } /* select caching function to compute output probability of a mixture */ if (hmminfo->is_tied_mixture) { From sumomo @ users.sourceforge.jp Thu Sep 25 14:00:06 2008 From: sumomo @ users.sourceforge.jp (sumomo @ users.sourceforge.jp) Date: Thu, 25 Sep 2008 14:00:06 +0900 Subject: [Julius-cvs 260] CVS update: julius4/libjulius/src Message-ID: <1222318806.717623.7889.nullmailer@users.sourceforge.jp> Index: julius4/libjulius/src/adin-cut.c diff -u julius4/libjulius/src/adin-cut.c:1.7 julius4/libjulius/src/adin-cut.c:1.8 --- julius4/libjulius/src/adin-cut.c:1.7 Thu May 8 14:45:03 2008 +++ julius4/libjulius/src/adin-cut.c Thu Sep 25 14:00:06 2008 @@ -95,7 +95,7 @@ * @author Akinobu LEE * @date Sat Feb 12 13:20:53 2005 * - * $Revision: 1.7 $ + * $Revision: 1.8 $ * */ /* @@ -152,7 +152,7 @@ adin->strip_flag = jconf->preprocess.strip_zero_sample; adin->thres = jconf->detect.level_thres; #ifdef HAVE_PTHREAD - if (jconf->input.speech_input == SP_MIC && jconf->decodeopt.segment) { + if (adin->enable_thread && jconf->decodeopt.segment) { adin->ignore_speech_while_recog = FALSE; } else { adin->ignore_speech_while_recog = TRUE; @@ -334,14 +334,9 @@ /****************/ /* resume input */ /****************/ - /* restart speech input if paused on the last call */ - if (a->ad_resume != NULL) { - if ((*(a->ad_resume))() == FALSE) return(-1); - } - - if (!a->adin_cut_on && a->is_valid_data == TRUE) { - callback_exec(CALLBACK_EVENT_SPEECH_START, recog); - } + // if (!a->adin_cut_on && a->is_valid_data == TRUE) { + // callback_exec(CALLBACK_EVENT_SPEECH_START, recog); + // } /*************/ /* main loop */ @@ -378,8 +373,19 @@ } if (cnt < 0) { /* end of stream / segment or error */ /* set the end status */ - if (cnt == -2) end_status = -1; /* end by error */ - else if (cnt == -1) end_status = 0; /* end by normal end of stream */ + switch(cnt) { + case -1: /* end of stream */ + a->input_side_segment = FALSE; + end_status = 0; + break; + case -2: + a->input_side_segment = FALSE; + end_status = -1; + break; + case -3: + a->input_side_segment = TRUE; + end_status = 0; + } /* now the input has been ended, we should not get further speech input in the next loop, instead just process the samples in the temporary buffer until @@ -407,6 +413,9 @@ /* length can be modified in the functions. */ /*************************************************/ if (cnt > 0) { +#ifdef ENABLE_PLUGIN + plugin_exec_adin_captured(&(a->buffer[a->bp]), cnt); +#endif callback_exec_adin(CALLBACK_ADIN_CAPTURED, recog, &(a->buffer[a->bp]), cnt); } @@ -452,9 +461,13 @@ if ((i = (*ad_check)(recog)) < 0) { /* -1: soft termination -2: hard termination */ // if ((i == -1 && current_len == 0) || i == -2) { if (i == -2 || - (i == -1 && a->adin_cut_on && a->is_valid_data == FALSE) || - (i == -1 && !a->adin_cut_on && a->current_len == 0)) { + (i == -1 && a->is_valid_data == FALSE)) { end_status = -2; /* recognition terminated by outer function */ + /* execute callback */ + if (a->current_len > 0) { + callback_exec(CALLBACK_EVENT_SPEECH_STOP, recog); + } + a->need_init = TRUE; /* bufer status shoule be reset at next call */ goto break_input; } } @@ -571,6 +584,9 @@ #ifdef THREAD_DEBUG jlog("DEBUG: callback for buffered samples (%d bytes)\n", len - wstep); #endif +#ifdef ENABLE_PLUGIN + plugin_exec_adin_triggered(a->cbuf, len - wstep); +#endif callback_exec_adin(CALLBACK_ADIN_TRIGGERED, recog, a->cbuf, len - wstep); ad_process_ret = (*ad_process)(a->cbuf, len - wstep, recog); switch(ad_process_ret) { @@ -641,6 +657,9 @@ #ifdef THREAD_DEBUG jlog("DEBUG: callback for swapped %d samples\n", a->sblen); #endif +#ifdef ENABLE_PLUGIN + plugin_exec_adin_triggered(a->swapbuf, a->sblen); +#endif callback_exec_adin(CALLBACK_ADIN_TRIGGERED, recog, a->swapbuf, a->sblen); ad_process_ret = (*ad_process)(a->swapbuf, a->sblen, recog); a->sblen = 0; @@ -763,6 +782,9 @@ jlog("DEBUG: callback for input sample [%d-%d]\n", i, i+wstep); #endif /* call external function */ +#ifdef ENABLE_PLUGIN + plugin_exec_adin_triggered(&(a->buffer[i]), wstep); +#endif callback_exec_adin(CALLBACK_ADIN_TRIGGERED, recog, &(a->buffer[i]), wstep); ad_process_ret = (*ad_process)(&(a->buffer[i]), wstep, recog); switch(ad_process_ret) { @@ -843,13 +865,6 @@ /****************/ /* pause input */ /****************/ - /* stop speech input */ - if (a->ad_pause != NULL) { - if ((*(a->ad_pause))() == FALSE) { - jlog("ERROR: adin_cut: failed to pause recording\n"); - end_status = -1; - } - } if (a->end_of_stream) { /* input already ends */ /* execute callback */ callback_exec(CALLBACK_EVENT_SPEECH_STOP, recog); @@ -924,10 +939,20 @@ adin_thread_input_main(void *dummy) { Recog *recog; + int ret; recog = dummy; - adin_cut(adin_store_buffer, NULL, recog); + ret = adin_cut(adin_store_buffer, NULL, recog); + + if (ret == -1) { /* error */ + jlog("Error: adin thread exit with error\n"); + } else if (ret == 0) { /* EOF */ + jlog("Stat: adin thread end with EOF\n"); + } + recog->adin->adinthread_ended = TRUE; + + /* return to end this thread */ } /** @@ -956,6 +981,7 @@ a->transfer_online = FALSE; /* tell adin-mic thread to wait at initial */ a->adinthread_buffer_overflowed = FALSE; + a->adinthread_ended = FALSE; if (pthread_mutex_init(&(a->mutex), NULL) != 0) { /* error */ jlog("ERROR: adin_thread_create: failed to initialize mutex\n"); @@ -1009,6 +1035,7 @@ int i; boolean overflowed_p; boolean transfer_online_local; + boolean ended_p; ADIn *a; a = recog->adin; @@ -1030,7 +1057,13 @@ nowlen = a->speechlen; overflowed_p = a->adinthread_buffer_overflowed; transfer_online_local = a->transfer_online; + ended_p = a->adinthread_ended; pthread_mutex_unlock(&(a->mutex)); + /* check if thread is alive */ + if (ended_p) { + /* adin thread has already exited, so return EOF to stop this input */ + return(0); + } /* check if other input thread has overflowed */ if (overflowed_p) { jlog("WARNING: adin_thread_process: too long input (> %d samples), segmented now\n", MAXSPEECHLEN); @@ -1215,8 +1248,11 @@ boolean adin_begin(ADIn *a) { - if (a->need_zmean) zmean_reset(); - if (a->ad_begin != NULL) return(a->ad_begin()); + if (debug2_flag && a->input_side_segment) jlog("Stat: adin_begin: skip\n"); + if (a->input_side_segment == FALSE) { + if (a->need_zmean) zmean_reset(); + if (a->ad_begin != NULL) return(a->ad_begin()); + } return TRUE; } /** @@ -1237,7 +1273,10 @@ boolean adin_end(ADIn *a) { - if (a->ad_end != NULL) return(a->ad_end()); + if (debug2_flag && a->input_side_segment) jlog("Stat: adin_end: skip\n"); + if (a->input_side_segment == FALSE) { + if (a->ad_end != NULL) return(a->ad_end()); + } return TRUE; } Index: julius4/libjulius/src/default.c diff -u julius4/libjulius/src/default.c:1.7 julius4/libjulius/src/default.c:1.8 --- julius4/libjulius/src/default.c:1.7 Thu Sep 25 13:22:58 2008 +++ julius4/libjulius/src/default.c Thu Sep 25 14:00:06 2008 @@ -17,7 +17,7 @@ * @author Akinobu Lee * @date Fri Feb 16 15:05:43 2007 * - * $Revision: 1.7 $ + * $Revision: 1.8 $ * */ /* @@ -56,8 +56,10 @@ void jconf_set_default_values(Jconf *j) { + j->input.type = INPUT_WAVEFORM; j->input.speech_input = SP_MFCFILE; j->input.device = SP_INPUT_DEFAULT; + j->input.plugin_source = -1; j->input.sfreq = 16000; j->input.period = 625; j->input.framesize = DEF_FRAMESIZE; Index: julius4/libjulius/src/instance.c diff -u julius4/libjulius/src/instance.c:1.2 julius4/libjulius/src/instance.c:1.3 --- julius4/libjulius/src/instance.c:1.2 Sat May 17 13:06:30 2008 +++ julius4/libjulius/src/instance.c Thu Sep 25 14:00:06 2008 @@ -12,7 +12,7 @@ * @author Akinobu Lee * @date Sun Oct 28 18:06:20 2007 * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * */ /* @@ -51,6 +51,7 @@ mfcc->rest_param = NULL; mfcc->frontend.ssbuf = NULL; mfcc->cmn.loaded = FALSE; + mfcc->plugin_source = -1; if (amconf) { mfcc->para = &(amconf->analysis.para); mfcc->hmm_loaded = (amconf->analysis.para_hmm.loaded == 1) ? TRUE : FALSE; Index: julius4/libjulius/src/jfunc.c diff -u julius4/libjulius/src/jfunc.c:1.3 julius4/libjulius/src/jfunc.c:1.4 --- julius4/libjulius/src/jfunc.c:1.3 Tue Jun 17 10:20:50 2008 +++ julius4/libjulius/src/jfunc.c Thu Sep 25 14:00:06 2008 @@ -19,7 +19,7 @@ * @author Akinobu Lee * @date Wed Aug 8 15:04:28 2007 * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * */ /* @@ -57,10 +57,16 @@ recog->process_want_reload = TRUE; recog->process_active = FALSE; } - if (recog->jconf->input.speech_input == SP_ADINNET) { - /* when taking speech from adinnet client, - always tell the client to stop recording */ - adin_tcpip_send_pause(); + /* control the A/D-in module to stop recording */ + if (recog->jconf->input.type == INPUT_WAVEFORM) { + if (recog->adin->ad_pause != NULL) { + (*(recog->adin->ad_pause))(); + } + } else { + /* feature vector input */ + if (recog->jconf->input.speech_input == SP_MFCMODULE) { + if (recog->mfcclist->func.fv_pause) recog->mfcclist->func.fv_pause(); + } } } @@ -92,10 +98,16 @@ recog->process_want_reload = TRUE; recog->process_active = FALSE; } - if (recog->jconf->input.speech_input == SP_ADINNET) { - /* when taking speech input from adinnet client, - always tell the client to stop recording immediately */ - adin_tcpip_send_terminate(); + if (recog->jconf->input.type == INPUT_WAVEFORM) { + if (recog->adin->ad_terminate != NULL) { + /* control the A/D-in module to terminate recording imemdiately */ + (*(recog->adin->ad_terminate))(); + } + } else { + /* feature vector input */ + if (recog->jconf->input.speech_input == SP_MFCMODULE) { + if (recog->mfcclist->func.fv_terminate) recog->mfcclist->func.fv_terminate(); + } } } @@ -120,10 +132,16 @@ recog->process_want_terminate = FALSE; recog->process_active = TRUE; } - if (recog->jconf->input.speech_input == SP_ADINNET) { - /* when taking speech from adinnet client, - tell the client to restart recording */ - adin_tcpip_send_resume(); + /* control the A/D-in module to restart recording now */ + if (recog->jconf->input.type == INPUT_WAVEFORM) { + if (recog->adin->ad_resume != NULL) { + (*(recog->adin->ad_resume))(); + } + } else { + /* feature vector input */ + if (recog->jconf->input.speech_input == SP_MFCMODULE) { + if (recog->mfcclist->func.fv_resume) recog->mfcclist->func.fv_resume(); + } } } @@ -522,63 +540,22 @@ { boolean ret; - ret = adin_initialize(recog); - - /* initialize A/D-in device */ - /* create A/D-in thread here */ -#ifdef HAVE_PTHREAD - if (ret) { - if (recog->adin->enable_thread) { - if (adin_thread_create(recog) == FALSE) { + if (recog->jconf->input.type == INPUT_VECTOR) { + /* feature vector input */ + if (recog->jconf->input.speech_input == SP_MFCMODULE) { + if (mfc_module_init(recog->mfcclist, recog) == FALSE) { return FALSE; } + ret = mfc_module_standby(recog->mfcclist); + } else { + ret = TRUE; } + return ret; } -#endif - - return(ret); -} - -/** - * - * Initialize function when using user-defined A/D-in function. - * Almost the same with j_adin_init() except that it does not initialize - * an input device. - * - * - * - * ユーザ定義のA/D-in関数使用時の初期化関数. デバイスの初期化を行わない - * 以外は j_adin_init() と同じである. -* - * - * - * @param recog [in] engine instance - * @param arg [in] argument - * - * @return TRUE on success, else FALSE on error. - * - * @callgraph - * @callergraph - * @ingroup engine - */ -boolean -j_adin_init_user(Recog *recog, void *arg) -{ - boolean ret; - - ret = adin_initialize_user(recog, arg); + + /* initialize A/D-in device */ + ret = adin_initialize(recog); - /* initialize A/D-in device */ - /* create A/D-in thread here */ -#ifdef HAVE_PTHREAD - if (ret) { - if (recog->adin->enable_thread) { - if (adin_thread_create(recog) == FALSE) { - return FALSE; - } - } - } -#endif return(ret); } Index: julius4/libjulius/src/m_adin.c diff -u julius4/libjulius/src/m_adin.c:1.6 julius4/libjulius/src/m_adin.c:1.7 --- julius4/libjulius/src/m_adin.c:1.6 Fri Jul 18 07:56:21 2008 +++ julius4/libjulius/src/m_adin.c Thu Sep 25 14:00:06 2008 @@ -12,7 +12,7 @@ * @author Akinobu LEE * @date Fri Mar 18 16:17:23 2005 * - * $Revision: 1.6 $ + * $Revision: 1.7 $ * */ /* @@ -45,6 +45,7 @@ a->ad_end = adin_sndfile_end; a->ad_resume = NULL; a->ad_pause = NULL; + a->ad_terminate = NULL; a->ad_read = adin_sndfile_read; a->silence_cut_default = FALSE; a->enable_thread = FALSE; @@ -55,6 +56,7 @@ a->ad_end = adin_file_end; a->ad_resume = NULL; a->ad_pause = NULL; + a->ad_terminate = NULL; a->ad_read = adin_file_read; a->silence_cut_default = FALSE; a->enable_thread = FALSE; @@ -65,6 +67,7 @@ /* microphone input */ a->ad_resume = NULL; a->ad_pause = NULL; + a->ad_terminate = NULL; a->silence_cut_default = TRUE; a->enable_thread = TRUE; switch(dev) { @@ -111,6 +114,7 @@ a->ad_end = adin_netaudio_end; a->ad_resume = NULL; a->ad_pause = NULL; + a->ad_terminate = NULL; a->ad_read = adin_netaudio_read; a->silence_cut_default = TRUE; a->enable_thread = TRUE; @@ -121,8 +125,9 @@ a->ad_standby = adin_tcpip_standby; a->ad_begin = adin_tcpip_begin; a->ad_end = adin_tcpip_end; - a->ad_resume = NULL; - a->ad_pause = NULL; + a->ad_resume = adin_tcpip_send_resume; + a->ad_pause = adin_tcpip_send_pause; + a->ad_terminate = adin_tcpip_send_terminate; a->ad_read = adin_tcpip_read; a->silence_cut_default = FALSE; a->enable_thread = FALSE; @@ -134,6 +139,7 @@ a->ad_end = NULL; a->ad_resume = NULL; a->ad_pause = NULL; + a->ad_terminate = NULL; a->ad_read = adin_stdin_read; a->silence_cut_default = FALSE; a->enable_thread = FALSE; @@ -195,7 +201,9 @@ if (adin_setup_param(adin, jconf) == FALSE) { jlog("ERROR: m_adin: failed to set parameter for input device\n"); return FALSE; - } + } + + adin->input_side_segment = FALSE; return TRUE; } @@ -222,47 +230,76 @@ char *arg = NULL; ADIn *adin; Jconf *jconf; +#ifdef ENABLE_PLUGIN + FUNC_INT func; + int sid; +#endif adin = recog->adin; jconf = recog->jconf; - if (jconf->input.speech_input == SP_MFCFILE) { - return TRUE; /* no need to initialize */ - } - jlog("STAT: ###### initialize input device\n"); /* select input device: file, mic, netaudio, etc... */ - if (adin_select(adin, jconf->input.speech_input, jconf->input.device) == FALSE) { - jlog("ERROR: m_adin: failed to select input device\n"); - return FALSE; - } +#ifdef ENABLE_PLUGIN + sid = jconf->input.plugin_source; + if (sid >= 0) { + /* set plugin properties and functions to adin */ + func = (FUNC_INT) plugin_get_func(sid, "adin_get_configuration"); + if (func == NULL) { + jlog("ERROR: invalid plugin: adin_get_configuration() not exist\n"); + return FALSE; + } + adin->silence_cut_default = (*func)(1); + adin->enable_thread = (*func)(2); - /* set sampling frequency and device-dependent configuration - (argument is device-dependent) */ - switch(jconf->input.speech_input) { - case SP_ADINNET: /* arg: port number */ - arg = mymalloc(100); - sprintf(arg, "%d", jconf->input.adinnet_port); - break; - case SP_RAWFILE: /* arg: filename of file list (if any) */ - if (jconf->input.inputlist_filename != NULL) { - arg = mymalloc(strlen(jconf->input.inputlist_filename)+1); - strcpy(arg, jconf->input.inputlist_filename); - } else { - arg = NULL; + adin->ad_standby = (boolean (*)(int, void *)) plugin_get_func(sid, "adin_standby"); + adin->ad_begin = (boolean (*)()) plugin_get_func(sid, "adin_open"); + adin->ad_end = (boolean (*)()) plugin_get_func(sid, "adin_close"); + adin->ad_resume = (boolean (*)()) plugin_get_func(sid, "adin_resume"); + adin->ad_pause = (boolean (*)()) plugin_get_func(sid, "adin_pause"); + adin->ad_terminate = (boolean (*)()) plugin_get_func(sid, "adin_terminate"); + adin->ad_read = (int (*)(SP16 *, int)) plugin_get_func(sid, "adin_read"); + if (adin->ad_read == NULL) { + jlog("ERROR: m_adin: selected plugin has no function adin_read()\n"); + return FALSE; } - break; - case SP_STDIN: - arg = NULL; - break; + } else { +#endif + /* built-in */ + if (adin_select(adin, jconf->input.speech_input, jconf->input.device) == FALSE) { + jlog("ERROR: m_adin: failed to select input device\n"); + return FALSE; + } + + /* set sampling frequency and device-dependent configuration + (argument is device-dependent) */ + switch(jconf->input.speech_input) { + case SP_ADINNET: /* arg: port number */ + arg = mymalloc(100); + sprintf(arg, "%d", jconf->input.adinnet_port); + break; + case SP_RAWFILE: /* arg: filename of file list (if any) */ + if (jconf->input.inputlist_filename != NULL) { + arg = mymalloc(strlen(jconf->input.inputlist_filename)+1); + strcpy(arg, jconf->input.inputlist_filename); + } else { + arg = NULL; + } + break; + case SP_STDIN: + arg = NULL; + break; #ifdef USE_NETAUDIO - case SP_NETAUDIO: /* netaudio server/port name */ - arg = mymalloc(strlen(jconf->input.netaudio_devname)+1); - strcpy(arg, jconf->input.netaudio_devname); - break; + case SP_NETAUDIO: /* netaudio server/port name */ + arg = mymalloc(strlen(jconf->input.netaudio_devname)+1); + strcpy(arg, jconf->input.netaudio_devname); + break; #endif + } +#ifdef ENABLE_PLUGIN } +#endif if (adin_setup_all(adin, jconf, arg) == FALSE) { return FALSE; @@ -273,44 +310,4 @@ return TRUE; } -/** - * - * ユーザ指定のA/D-in関数を用いて音声入力デバイスをセットアップする. - * recog->adin にデバイス用の各種関数 (ad->*) とパラメータ - * (silence_cut_default, enable_thread)があらかじめ格納されていること. - * 詳細は adin_select() を参照のこと. - * - * @param recog [i/o] エンジンインスタンス - * @param arg [in] adin_initialize 用引数 - * - * - * - * Initialize audio input device using user-specified A/D-in functions. - * The user functions and parameters (silence_cut_default and enable_thread) - * should be defined beforehand. See adin_select() for details. - * - * @param recog [i/o] engine instance - * @param arg [in] argument for adin_initialize - * - * - * @callgraph - * @callergraph - */ -boolean -adin_initialize_user(Recog *recog, void *arg) -{ - boolean ret; - ADIn *adin; - Jconf *jconf; - - adin = recog->adin; - jconf = recog->jconf; - - jlog("STAT: ###### initialize input device (user defined)\n"); - /* skip adin_select() */ - ret = adin_setup_all(adin, jconf, arg); - /* create A/D-in thread here */ - - return ret; -} /* end of file */ Index: julius4/libjulius/src/m_chkparam.c diff -u julius4/libjulius/src/m_chkparam.c:1.4 julius4/libjulius/src/m_chkparam.c:1.5 --- julius4/libjulius/src/m_chkparam.c:1.4 Mon Jul 7 14:50:10 2008 +++ julius4/libjulius/src/m_chkparam.c Thu Sep 25 14:00:06 2008 @@ -20,7 +20,7 @@ * @author Akinobu LEE * @date Fri Mar 18 16:31:45 2005 * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * */ /* @@ -223,9 +223,9 @@ /* set default realtime flag according to input mode */ if (jconf->decodeopt.force_realtime_flag) { - if (jconf->input.speech_input == SP_MFCFILE) { - jlog("WARNING: m_chkparam: realtime decoding of mfcfile is not supported yet\n"); - jlog("WARNING: m_chkparam: realtime turned off\n"); + if (jconf->input.type == INPUT_VECTOR) { + jlog("WARNING: m_chkparam: real-time concurrent processing is not needed on feature vector input\n"); + jlog("WARNING: m_chkparam: real-time flag has turned off\n"); jconf->decodeopt.realtime_flag = FALSE; } else { jconf->decodeopt.realtime_flag = jconf->decodeopt.forced_realtime; Index: julius4/libjulius/src/m_fusion.c diff -u julius4/libjulius/src/m_fusion.c:1.9 julius4/libjulius/src/m_fusion.c:1.10 --- julius4/libjulius/src/m_fusion.c:1.9 Tue Aug 5 18:47:56 2008 +++ julius4/libjulius/src/m_fusion.c Thu Sep 25 14:00:06 2008 @@ -20,7 +20,7 @@ * @author Akinobu Lee * @date Thu May 12 13:31:47 2005 * - * $Revision: 1.9 $ + * $Revision: 1.10 $ * */ /* @@ -101,7 +101,7 @@ /* only MFCC is supported for audio input */ /* MFCC_{0|E}[_D][_A][_Z][_N] is supported */ /* check parameter type of this acoustic HMM */ - if (jconf->input.speech_input != SP_MFCFILE) { + if (jconf->input.type == INPUT_WAVEFORM) { /* Decode parameter extraction type according to the training parameter type in the header of the given acoustic HMM */ if ((hmminfo->opt.param_type & F_BASEMASK) != F_MFCC) { @@ -228,7 +228,7 @@ return NULL; } /* check parameter type of this acoustic HMM */ - if (jconf->input.speech_input != SP_MFCFILE) { + if (jconf->input.type == INPUT_WAVEFORM) { /* Decode parameter extraction type according to the training parameter type in the header of the given acoustic HMM */ if ((gmm->opt.param_type & F_BASEMASK) != F_MFCC) { @@ -638,9 +638,6 @@ { JCONF_AM *amconf; JCONF_LM *lmconf; - JCONF_SEARCH *sh; - PROCESS_AM *am; - PROCESS_LM *lm; /* set global jconf */ recog->jconf = jconf; @@ -1186,16 +1183,14 @@ boolean j_final_fusion(Recog *recog) { - RecogProcess *p; MFCCCalc *mfcc; JCONF_SEARCH *sconf; PROCESS_AM *am; - PROCESS_LM *lm; jlog("STAT: ------\n"); jlog("STAT: All models are ready, go for final fusion\n"); jlog("STAT: [1] create MFCC extraction instance(s)\n"); - if (recog->jconf->input.speech_input != SP_MFCFILE) { + if (recog->jconf->input.type == INPUT_WAVEFORM) { /***************************************************/ /* create MFCC calculation instance from AM config */ /* according to the fixated parameter information */ @@ -1225,6 +1220,26 @@ /* stage 4: setup output probability function for each AM */ jlog("STAT: [3] initialize for acoustic HMM calculation\n"); for(am=recog->amlist;am;am=am->next) { +#ifdef ENABLE_PLUGIN + /* set plugin function if specified */ + if (am->config->gprune_method == GPRUNE_SEL_USER) { + am->hmmwrk.compute_gaussset = (void (*)(HMMWork *, HTK_HMM_Dens **, int, int *, int)) plugin_get_func(am->config->gprune_plugin_source, "calcmix"); + if (am->hmmwrk.compute_gaussset == NULL) { + jlog("ERROR: calcmix plugin has no function \"calcmix\"\n"); + return FALSE; + } + am->hmmwrk.compute_gaussset_init = (boolean (*)(HMMWork *)) plugin_get_func(am->config->gprune_plugin_source, "calcmix_init"); + if (am->hmmwrk.compute_gaussset_init == NULL) { + jlog("ERROR: calcmix plugin has no function \"calcmix_init\"\n"); + return FALSE; + } + am->hmmwrk.compute_gaussset_free = (void (*)(HMMWork *)) plugin_get_func(am->config->gprune_plugin_source, "calcmix_free"); + if (am->hmmwrk.compute_gaussset_free == NULL) { + jlog("ERROR: calcmix plugin has no function \"calcmix_free\"\n"); + return FALSE; + } + } +#endif 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) { return FALSE; @@ -1239,7 +1254,7 @@ /* stage 5: initialize work area for input and realtime decoding */ jlog("STAT: [4] prepare MFCC storage(s)\n"); - if (recog->jconf->input.speech_input == SP_MFCFILE) { + if (recog->jconf->input.type == INPUT_VECTOR) { /* create an MFCC instance for MFCC input */ /* create new mfcc instance */ recog->mfcclist = j_mfcccalc_new(NULL); @@ -1256,7 +1271,7 @@ } /* initialize SS calculation work area */ - if (recog->jconf->input.speech_input != SP_MFCFILE) { + if (recog->jconf->input.type == INPUT_WAVEFORM) { for(mfcc=recog->mfcclist;mfcc;mfcc=mfcc->next) { if (mfcc->frontend.sscalc) { mfcc->frontend.mfccwrk_ss = WMP_work_new(mfcc->para); @@ -1275,15 +1290,25 @@ if (recog->jconf->decodeopt.realtime_flag) { 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"); - return FALSE; + if (recog->jconf->input.type == INPUT_WAVEFORM) { + if (RealTimeInit(recog) == FALSE) { + jlog("ERROR: m_fusion: failed to initialize recognition process\n"); + return FALSE; + } } } /* finished! */ jlog("STAT: All init successfully done\n\n"); + /* set-up callback plugin if any */ +#ifdef ENABLE_PLUGIN + if (plugin_exec_engine_startup(recog) == FALSE) { + jlog("ERROR: m_fusion: failed to execute callback setup in plugin\n"); + return FALSE; + } +#endif + return TRUE; } Index: julius4/libjulius/src/m_info.c diff -u julius4/libjulius/src/m_info.c:1.8 julius4/libjulius/src/m_info.c:1.9 --- julius4/libjulius/src/m_info.c:1.8 Tue Aug 5 18:47:56 2008 +++ julius4/libjulius/src/m_info.c Thu Sep 25 14:00:06 2008 @@ -12,7 +12,7 @@ * @author Akinobu Lee * @date Thu May 12 14:14:01 2005 * - * $Revision: 1.8 $ + * $Revision: 1.9 $ * */ /* @@ -169,16 +169,7 @@ /* print current argument setting to log */ print_jconf_overview(jconf); - /* for backward compatibility with scoring tool (IPA99)... :-( */ -#if 0 - if (jconf->input.speech_input == SP_RAWFILE) { - jlog("Speech input source: file\n\n"); - } else if (jconf->input.speech_input == SP_MFCFILE) { - jlog("Speech input source: MFCC parameter file (HTK format)\n\n"); - } -#endif - - if (jconf->input.speech_input != SP_MFCFILE) { + if (jconf->input.type == INPUT_WAVEFORM) { /* acoustic parameter conditions for this model */ jlog("------------------------------------------------------------\n"); @@ -201,7 +192,7 @@ put_para(fp, mfcc->para); - if (jconf->input.speech_input != SP_MFCFILE) { + if (jconf->input.type == INPUT_WAVEFORM) { jlog(" spectral subtraction = "); if (mfcc->frontend.ssload_filename || mfcc->frontend.sscalc) { if (mfcc->frontend.sscalc) { @@ -329,9 +320,11 @@ case GPRUNE_SEL_BEAM: jlog("beam"); break; case GPRUNE_SEL_HEURISTIC: jlog("heuristic"); break; case GPRUNE_SEL_SAFE: jlog("safe"); break; + case GPRUNE_SEL_USER: jlog("(use plugin function)"); break; } jlog(" (-gprune)\n"); - if (am->config->gprune_method != GPRUNE_SEL_NONE) { + if (am->config->gprune_method != GPRUNE_SEL_NONE + && am->config->gprune_method != GPRUNE_SEL_USER) { jlog(" top N mixtures to calc = %d / %d (-tmix)\n", am->config->mixnum_thres, am->hmminfo->maxcodebooksize); } if (am->config->hmm_gs_filename != NULL) { @@ -765,21 +758,32 @@ jlog("------------------------------------------------------------\n"); jlog("FrontEnd:\n\n"); - jlog(" Speech input:\n"); - jlog("\t speech input source = "); - if (jconf->input.speech_input == SP_RAWFILE) { - jlog("speech file\n"); + jlog(" Input stream:\n"); + jlog("\t input type = "); + switch(jconf->input.type) { + case INPUT_WAVEFORM: + jlog("waveform\n"); + break; + case INPUT_VECTOR: + jlog("feature vector sequence\n"); + break; + } + jlog("\t input source = "); + if (jconf->input.plugin_source != -1) { + jlog("plugin\n"); + } else if (jconf->input.speech_input == SP_RAWFILE) { + jlog("waveform file\n"); jlog("\t input filelist = "); if (jconf->input.inputlist_filename == NULL) { - jlog("(none, enter filenames from stdin)\n"); + jlog("(none, get file name from stdin)\n"); } else { jlog("%s\n", jconf->input.inputlist_filename); } } else if (jconf->input.speech_input == SP_MFCFILE) { - jlog("MFCC parameter file (HTK format)\n"); + jlog("feature vector file (HTK format)\n"); jlog("\t filelist = "); if (jconf->input.inputlist_filename == NULL) { - jlog("(none, enter filenames from stdin)\n"); + jlog("(none, get file name from stdin)\n"); } else { jlog("%s\n", jconf->input.inputlist_filename); } @@ -803,13 +807,13 @@ 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; + case SP_INPUT_DEFAULT: jlog("default\n"); break; + case SP_INPUT_ALSA: jlog("alsa\n"); break; + case SP_INPUT_OSS: jlog("oss\n"); break; + case SP_INPUT_ESD: jlog("esd\n"); break; } } - if (jconf->input.speech_input != SP_MFCFILE) { + if (jconf->input.type == INPUT_WAVEFORM) { if (jconf->input.speech_input == SP_RAWFILE || jconf->input.speech_input == SP_STDIN || jconf->input.speech_input == SP_ADINNET) { if (jconf->input.use_ds48to16) { jlog("\t sampling freq. = assume 48000Hz, then down to %dHz\n", jconf->input.sfreq); @@ -824,7 +828,7 @@ } } } - if (jconf->input.speech_input != SP_MFCFILE) { + if (jconf->input.type == INPUT_WAVEFORM) { jlog("\t threaded A/D-in = "); #ifdef HAVE_PTHREAD if (recog->adin->enable_thread) { @@ -841,7 +845,7 @@ } else { jlog("\t zero frames stripping = off\n"); } - if (jconf->input.speech_input != SP_MFCFILE) { + if (jconf->input.type == INPUT_WAVEFORM) { if (recog->adin->adin_cut_on) { jlog("\t silence cutting = on\n"); jlog("\t level thres = %d / 32767\n", jconf->detect.level_thres); Index: julius4/libjulius/src/m_options.c diff -u julius4/libjulius/src/m_options.c:1.14 julius4/libjulius/src/m_options.c:1.15 --- julius4/libjulius/src/m_options.c:1.14 Thu Sep 25 13:22:58 2008 +++ julius4/libjulius/src/m_options.c Thu Sep 25 14:00:06 2008 @@ -18,7 +18,7 @@ * @author Akinobu Lee * @date Thu May 12 18:52:07 2005 * - * $Revision: 1.14 $ + * $Revision: 1.15 $ * */ /* @@ -178,8 +178,12 @@ boolean unknown_opt; JCONF_AM *amconf, *atmp; JCONF_LM *lmconf, *ltmp; - JCONF_SEARCH *sconf, *stmp; + JCONF_SEARCH *sconf; char sname[JCONF_MODULENAME_MAXLEN]; +#ifdef ENABLE_PLUGIN + int sid; + FUNC_INT func; +#endif #define GET_TMPARG if ((tmparg = next_arg(&i, argc, argv)) == NULL) return FALSE for (i=1;iinput.speech_input = SP_RAWFILE; - jconf->decodeopt.realtime_flag = FALSE; - } else if (strmatch(tmparg,"rawfile")) { + jconf->input.plugin_source = -1; + if (strmatch(tmparg,"file") || strmatch(tmparg,"rawfile")) { + jconf->input.type = INPUT_WAVEFORM; jconf->input.speech_input = SP_RAWFILE; jconf->decodeopt.realtime_flag = FALSE; - } else if (strmatch(tmparg,"htkparam")) { - jconf->input.speech_input = SP_MFCFILE; - jconf->decodeopt.realtime_flag = FALSE; - } else if (strmatch(tmparg,"mfcfile")) { + } else if (strmatch(tmparg,"htkparam") || strmatch(tmparg,"mfcfile") || strmatch(tmparg,"mfc")) { + jconf->input.type = INPUT_VECTOR; jconf->input.speech_input = SP_MFCFILE; jconf->decodeopt.realtime_flag = FALSE; } else if (strmatch(tmparg,"stdin")) { + jconf->input.type = INPUT_WAVEFORM; jconf->input.speech_input = SP_STDIN; jconf->decodeopt.realtime_flag = FALSE; } else if (strmatch(tmparg,"adinnet")) { + jconf->input.type = INPUT_WAVEFORM; jconf->input.speech_input = SP_ADINNET; jconf->decodeopt.realtime_flag = TRUE; #ifdef USE_NETAUDIO } else if (strmatch(tmparg,"netaudio")) { + jconf->input.type = INPUT_WAVEFORM; jconf->input.speech_input = SP_NETAUDIO; jconf->decodeopt.realtime_flag = TRUE; #endif #ifdef USE_MIC } else if (strmatch(tmparg,"mic")) { + jconf->input.type = INPUT_WAVEFORM; jconf->input.speech_input = SP_MIC; jconf->input.device = SP_INPUT_DEFAULT; jconf->decodeopt.realtime_flag = TRUE; } else if (strmatch(tmparg,"alsa")) { #ifdef HAS_ALSA + jconf->input.type = INPUT_WAVEFORM; jconf->input.speech_input = SP_MIC; jconf->input.device = SP_INPUT_ALSA; jconf->decodeopt.realtime_flag = TRUE; @@ -343,6 +349,7 @@ #endif } else if (strmatch(tmparg,"oss")) { #ifdef HAS_OSS + jconf->input.type = INPUT_WAVEFORM; jconf->input.speech_input = SP_MIC; jconf->input.device = SP_INPUT_OSS; jconf->decodeopt.realtime_flag = TRUE; @@ -352,6 +359,7 @@ #endif } else if (strmatch(tmparg,"esd")) { #ifdef HAS_ESD + jconf->input.type = INPUT_WAVEFORM; jconf->input.speech_input = SP_MIC; jconf->input.device = SP_INPUT_ESD; jconf->decodeopt.realtime_flag = TRUE; @@ -360,12 +368,24 @@ return FALSE; #endif #endif - } else if (strmatch(tmparg,"file")) { /* for 1.1 compat */ - jconf->input.speech_input = SP_RAWFILE; - jconf->decodeopt.realtime_flag = FALSE; - } else if (strmatch(tmparg,"mfc")) { /* for 1.1 compat */ - jconf->input.speech_input = SP_MFCFILE; +#ifdef ENABLE_PLUGIN + } else if ((sid = plugin_find_optname("adin_get_optname", tmparg)) != -1) { /* adin plugin */ + jconf->input.plugin_source = sid; + jconf->input.type = INPUT_WAVEFORM; + jconf->input.speech_input = SP_MIC; + func = (FUNC_INT) plugin_get_func(sid, "adin_get_configuration"); + if (func == NULL) { + jlog("ERROR: invalid plugin: adin_get_configuration() not exist\n"); + jlog("ERROR: skip option \"-input %s\"\n", tmparg); + continue; + } + jconf->decodeopt.realtime_flag = (*func)(0); + } else if ((sid = plugin_find_optname("fvin_get_optname", tmparg)) != -1) { /* vector input plugin */ + jconf->input.plugin_source = sid; + jconf->input.type = INPUT_VECTOR; + jconf->input.speech_input = SP_MFCMODULE; jconf->decodeopt.realtime_flag = FALSE; +#endif } else { jlog("ERROR: m_options: unknown speech input source \"%s\"\n", tmparg); return FALSE; @@ -978,6 +998,11 @@ jconf->amnow->gprune_method = GPRUNE_SEL_NONE; } else if (strmatch(tmparg,"default")) { jconf->amnow->gprune_method = GPRUNE_SEL_UNDEF; +#ifdef ENABLE_PLUGIN + } else if ((sid = plugin_find_optname("calcmix_get_optname", tmparg)) != -1) { /* mixture calculation plugin */ + jconf->amnow->gprune_method = GPRUNE_SEL_USER; + jconf->amnow->gprune_plugin_source = sid; +#endif } else { jlog("ERROR: m_options: no such pruning method \"%s\"\n", argv[0], tmparg); return FALSE; @@ -1221,6 +1246,12 @@ if (!check_section(jconf, argv[i], JCONF_OPT_SR)) return FALSE; jconf->searchnow->sw.fallback_pass1_flag = TRUE; continue; +#ifdef ENABLE_PLUGIN + } else if (strmatch(argv[i],"-plugindir")) { + GET_TMPARG; + plugin_load_dirs(tmparg); + continue; +#endif } if (argv[i][0] == '-' && strlen(argv[i]) == 2) { /* 1-letter options */ Index: julius4/libjulius/src/m_usage.c diff -u julius4/libjulius/src/m_usage.c:1.10 julius4/libjulius/src/m_usage.c:1.11 --- julius4/libjulius/src/m_usage.c:1.10 Thu Sep 25 13:22:58 2008 +++ julius4/libjulius/src/m_usage.c Thu Sep 25 14:00:06 2008 @@ -12,7 +12,7 @@ * @author Akinobu Lee * @date Fri May 13 15:04:34 2005 * - * $Revision: 1.10 $ + * $Revision: 1.11 $ * */ /* @@ -45,7 +45,13 @@ j_output_argument_help(FILE *fp) { Jconf *jconf; - +#ifdef ENABLE_PLUGIN + int id; + char buf[64]; + PLUGIN_ENTRY *p; + FUNC_VOID func; +#endif + /* load default values */ jconf = j_jconf_new(); @@ -59,18 +65,17 @@ fprintf(fp, " (Can extract only MFCC based features from waveform)\n"); fprintf(fp, " [-input devname] input source (default = htkparam)\n"); fprintf(fp, " htkparam/mfcfile HTK parameter file\n"); - fprintf(fp, " file/rawfile waveform file\n"); - fprintf(fp, " (format: %s)\n", SUPPORTED_WAVEFILE_FORMAT); + fprintf(fp, " file/rawfile waveform file (%s)\n", SUPPORTED_WAVEFILE_FORMAT); #ifdef USE_MIC - fprintf(fp, " mic microphone device\n"); + fprintf(fp, " mic default microphone device\n"); # ifdef HAS_ALSA - fprintf(fp, " alsa use ALSA interface\n"); + fprintf(fp, " alsa use ALSA interface\n"); # endif # ifdef HAS_OSS - fprintf(fp, " oss use OSS interface\n"); + fprintf(fp, " oss use OSS interface\n"); # endif # ifdef HAS_ESD - fprintf(fp, " esd use ESounD interface\n"); + fprintf(fp, " esd use ESounD interface\n"); # endif #endif #ifdef USE_NETAUDIO @@ -78,6 +83,24 @@ #endif fprintf(fp, " adinnet adinnet client (TCP/IP)\n"); fprintf(fp, " stdin standard input\n"); +#ifdef ENABLE_PLUGIN + if (global_plugin_list) { + if ((id = plugin_get_id("adin_get_optname")) >= 0) { + for(p=global_plugin_list[id];p;p=p->next) { + func = (FUNC_VOID) p->func; + (*func)(buf, (int)64); + fprintf(fp, " %-18s(adin plugin #%d)\n", buf, p->source_id); + } + } + if ((id = plugin_get_id("fvin_get_optname")) >= 0) { + for(p=global_plugin_list[id];p;p=p->next) { + func = (FUNC_VOID) p->func; + (*func)(buf, (int)64); + fprintf(fp, " %-18s(feature vector input plugin #%d)\n", buf, p->source_id); + } + } + } +#endif fprintf(fp, " [-filelist file] filename of input file list\n"); #ifdef USE_NETAUDIO fprintf(fp, " [-NA host:unit] get audio from NetAudio server at host:unit\n"); @@ -200,6 +223,17 @@ fprintf(fp, " beam beam pruning\n"); #endif fprintf(fp, " none no pruning (default for non tmix models)\n"); +#ifdef ENABLE_PLUGIN + if (global_plugin_list) { + if ((id = plugin_get_id("calcmix_get_optname")) >= 0) { + for(p=global_plugin_list[id];p;p=p->next) { + func = (FUNC_VOID) p->func; + (*func)(buf, (int)64); + fprintf(fp, " %-14s(calculation plugin #%d)\n", buf, p->source_id); + } + } + } +#endif fprintf(fp, " [-tmix gaussnum] Gaussian num threshold per mixture for pruning (%d)\n", jconf->am_root->mixnum_thres); fprintf(fp, " [-gshmm hmmdefs] monophone hmmdefs for GS\n"); fprintf(fp, " [-gsnum N] N-best state will be selected (%d)\n", jconf->am_root->gs_statenum); Index: julius4/libjulius/src/plugin.c diff -u /dev/null julius4/libjulius/src/plugin.c:1.1 --- /dev/null Thu Sep 25 14:00:06 2008 +++ julius4/libjulius/src/plugin.c Thu Sep 25 14:00:06 2008 @@ -0,0 +1,607 @@ +/** + * @file plugin.c + * + * + * @brief Load plugin + * + * + * + * @brief プラグイン読み込み + * + * + * @author Akinobu Lee + * @date Sat Aug 2 09:46:09 2008 + * + * $Revision: 1.1 $ + * + */ +/* + * Copyright (c) 1991-2007 Kawahara Lab., Kyoto University + * Copyright (c) 2000-2005 Shikano Lab., Nara Institute of Science and Technology + * Copyright (c) 2005-2007 Julius project team, Nagoya Institute of Technology + * All rights reserved + */ + +#include + +#ifdef ENABLE_PLUGIN + +#include +#include + +/** + * Plugin file path suffix + * + */ +static char *plugin_suffix = PLUGIN_SUFFIX; + +/** + * Function names to be loaded + * + */ +static char *plugin_function_namelist[] = PLUGIN_FUNCTION_NAMELIST; + + +/**************************************************************/ + +#if defined(_WIN32) && !defined(__CYGWIN32__) +/** + * Return error string. + * + * @return the error string. + */ +static const char* dlerror() +{ + static char szMsgBuf[256]; + FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, + NULL, + GetLastError(), + MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), + szMsgBuf, + sizeof szMsgBuf, + NULL); + return szMsgBuf; +} +#endif + +/**************************************************************/ +static int +plugin_namelist_num() +{ + return(sizeof(plugin_function_namelist) / sizeof(char *)); +} + +static void +plugin_free_all() +{ + PLUGIN_ENTRY *p, *ptmp; + int i, num; + + num = plugin_namelist_num(); + for(i=0;inext; + free(p); + p = ptmp; + } + } + free(global_plugin_list); +} + + +int +plugin_get_id(char *name) +{ + int i, num; + num = plugin_namelist_num(); + for(i=0;i= plugin_suffix && p >= filename && *x == *p) { + x--; p--; + } + if (x < plugin_suffix) { + return TRUE; + } + + return FALSE; +} + +/** + * Load a plugin file. + * + * @param file [in] plugin file path + * + * @return TRUE on success, FALSE on failure. + */ +boolean +plugin_load_file(char *file) +{ + PLUGIN_MODULE handle; + FUNC_INT func; + FUNC_VOID entfunc; + int ret, number, num; + char buf[256]; + int buflen = 256; + PLUGIN_ENTRY *p; + int i; + + if (global_plugin_list == NULL) plugin_init(); + + /* open file */ + handle = dlopen(file, RTLD_LAZY); + if (!handle) { + jlog("ERROR: plugin_load: failed to open: %s\n", dlerror()); + return(FALSE); + } + + /* call initialization function */ + func = dlsym(handle, "initialize"); + if (func) { + ret = (*func)(); + if (ret == -1) { + jlog("WARNING: plugin_load: %s: initialize() returns no, skip this file\n", file); + dlclose(handle); + return(FALSE); + } + } + + /* call information function */ + func = dlsym(handle, "get_plugin_info"); + if (func == NULL) { + jlog("ERROR: plugin_load: %s: get_plugin_info(): %s\n", file, dlerror()); + dlclose(handle); + return(FALSE); + } + number = 0; + ret = (*func)(number, buf, buflen); + if (ret == -1) { + jlog("ERROR: plugin_load: %s: get_plugin_info(0) returns error\n", file); + dlclose(handle); + return(FALSE); + } + buf[buflen-1] = '\0'; + jlog("#%d [%s]\n", global_plugin_loaded_file_num, buf); + + /* register plugin functions */ + num = plugin_namelist_num(); + for(i=0;iid = i; + p->source_id = global_plugin_loaded_file_num; + p->func = entfunc; + p->next = global_plugin_list[i]; + global_plugin_list[i] = p; + } + } + + /* increment file counter */ + global_plugin_loaded_file_num++; + + return(TRUE); +} + +/** + * Search for plugin file in a directory and load them. + * + * @param dir [in] directory + * + * @return TRUE on success, FALSE on failure + */ +boolean +plugin_load_dir(char *dir) +{ + DIR *d; + struct dirent *f; + static char buf[512]; + int cnt; + + if ((d = opendir(dir)) == NULL) { + jlog("ERROR: plugin_load: cannot open plugins dir \"%s\"\n", dir); + return FALSE; + } + cnt = 0; + while((f = readdir(d)) != NULL) { + if (is_plugin_obj(f->d_name)) { + snprintf(buf, 512, "%s/%s", dir, f->d_name); + jlog("STAT: file: %-23s ", f->d_name); + if (plugin_load_file(buf)) cnt++; + } + } + closedir(d); + jlog("STAT: %d files loaded\n", cnt); + + return TRUE; +} + +/** + * read in plugins in multiple directories + * + * @param dirent [i/o] directory entry in form of + * "dir1:dir2:dir3:...". + * + */ +void +plugin_load_dirs(char *dirent) +{ + char *p, *s; + char c; + + if (dirent == NULL) return; + + if (debug2_flag) { + jlog("DEBUG: loading dirs: %s\n", dirent); + } + + p = dirent; + do { + s = p; + while(*p != '\0' && *p != ':') p++; + c = *p; + *p = '\0'; + jlog("STAT: loading plugins at \"%s\":\n", dirent); + plugin_load_dir(s); + if (c != '\0') { + *p = c; + p++; + } + } while (*p != '\0'); +} + + +/************************************************************************/ + +int +plugin_find_optname(char *optfuncname, char *str) +{ + char buf[64]; + int id; + PLUGIN_ENTRY *p; + FUNC_VOID func; + + if ((id = plugin_get_id(optfuncname)) < 0) return -1; + + for(p=global_plugin_list[id];p;p=p->next) { + func = (FUNC_VOID) p->func; + (*func)(buf, (int)64); + if (strmatch(buf, str)) { + return p->source_id; + } + } + return -1; +} + +FUNC_VOID +plugin_get_func(int sid, char *name) +{ + int id; + PLUGIN_ENTRY *p; + FUNC_VOID func; + + if ((id = plugin_get_id(name)) < 0) return NULL; + + for(p=global_plugin_list[id];p;p=p->next) { + if (p->source_id == sid) return p->func; + } + return NULL; +} + +/************************************************************************/ +boolean +plugin_exec_engine_startup(Recog *recog) +{ + int id; + PLUGIN_ENTRY *p; + FUNC_INT func; + boolean ok_p; + + if (global_plugin_list == NULL) return TRUE; + + if ((id = plugin_get_id("startup")) < 0) return FALSE; + + ok_p = TRUE; + for(p=global_plugin_list[id];p;p=p->next) { + func = (FUNC_INT) p->func; + if ((*func)(recog) != 0) { + jlog("WARNING: plugin #%d: failed in startup()\n", p->source_id); + ok_p = FALSE; + } + } + + return ok_p; +} + + +/************************************************************************/ +void +plugin_exec_adin_captured(short *buf, int len) +{ + int id; + PLUGIN_ENTRY *p; + FUNC_VOID adfunc; + + if (global_plugin_list == NULL) return; + + if ((id = plugin_get_id("adin_postprocess")) < 0) return; + for(p=global_plugin_list[id];p;p=p->next) { + adfunc = (FUNC_VOID) p->func; + (*adfunc)(buf, len); + } +} + +void +plugin_exec_adin_triggered(short *buf, int len) +{ + int id; + PLUGIN_ENTRY *p; + FUNC_VOID adfunc; + + if (global_plugin_list == NULL) return; + + if ((id = plugin_get_id("adin_postprocess_triggered")) < 0) return; + for(p=global_plugin_list[id];p;p=p->next) { + adfunc = (FUNC_VOID) p->func; + (*adfunc)(buf, len); + } +} + +void +plugin_exec_vector_postprocess(VECT *vecbuf, int veclen, int nframe) +{ + int id; + PLUGIN_ENTRY *p; + FUNC_INT func; + + if (global_plugin_list == NULL) return; + + if ((id = plugin_get_id("fvin_postprocess")) < 0) return; + for(p=global_plugin_list[id];p;p=p->next) { + func = (FUNC_INT) p->func; + (*func)(vecbuf, veclen, nframe); + } +} +void +plugin_exec_vector_postprocess_all(HTK_Param *param) +{ + int id; + PLUGIN_ENTRY *p; + FUNC_INT func; + int t; + + if (global_plugin_list == NULL) return; + + if ((id = plugin_get_id("fvin_postprocess")) < 0) return; + for(t=0;tsamplenum;t++) { + for(p=global_plugin_list[id];p;p=p->next) { + func = (FUNC_INT) p->func; + (*func)(param->parvec[t], param->veclen, t); + } + } +} + +void +plugin_exec_process_result(Recog *recog) +{ + int id; + PLUGIN_ENTRY *p; + FUNC_VOID func; + + RecogProcess *rtmp, *r; + Sentence *s; + int i; + int len; + char *str; + + if (global_plugin_list == NULL) return; + + /* for result_str(), return the best sentence string among processes */ + s = NULL; + for(rtmp=recog->process_list;rtmp;rtmp=rtmp->next) { + if (! rtmp->live) continue; + if (rtmp->result.status >= 0 && rtmp->result.sentnum > 0) { /* recognition succeeded */ + if (s == NULL || rtmp->result.sent[0].score > s->score) { + r = rtmp; + s = &(r->result.sent[0]); + } + } + } + if (s == NULL) { + str = NULL; + } else { + len = 0; + for(i=0;iword_num;i++) len += strlen(r->lm->winfo->woutput[s->word[i]]) + 1; + str = (char *)mymalloc(len); + str[0]='\0'; + for(i=0;iword_num;i++) { + if (strlen(r->lm->winfo->woutput[s->word[i]]) == 0) continue; + if (strlen(str) > 0) strcat(str, " "); + strcat(str, r->lm->winfo->woutput[s->word[i]]); + } + } + + if ((id = plugin_get_id("result_best_str")) < 0) return; + for(p=global_plugin_list[id];p;p=p->next) { + func = (FUNC_VOID) p->func; + (*func)(str); + } + + if (str != NULL) free(str); +} + + +/************************************************************************/ +/* assume only one MFCC module! */ + +/************************************************************************/ + +boolean +mfc_module_init(MFCCCalc *mfcc, Recog *recog) +{ + mfcc->plugin_source = recog->jconf->input.plugin_source; + if (mfcc->plugin_source < 0) { + jlog("ERROR: SP_MDCMODULE selected but plugin is missing?\n"); + return FALSE; + } + mfcc->func.fv_standby = (boolean (*)()) plugin_get_func(mfcc->plugin_source, "fvin_standby"); + mfcc->func.fv_begin = (boolean (*)()) plugin_get_func(mfcc->plugin_source, "fvin_open"); + mfcc->func.fv_read = (int (*)(VECT *, int)) plugin_get_func(mfcc->plugin_source, "fvin_read"); + mfcc->func.fv_end = (boolean (*)()) plugin_get_func(mfcc->plugin_source, "fvin_close"); + mfcc->func.fv_resume = (boolean (*)()) plugin_get_func(mfcc->plugin_source, "fvin_resume"); + mfcc->func.fv_pause = (boolean (*)()) plugin_get_func(mfcc->plugin_source, "fvin_pause"); + mfcc->func.fv_terminate= (boolean (*)()) plugin_get_func(mfcc->plugin_source, "fvin_terminate"); + + if (mfcc->func.fv_read == NULL) { + jlog("ERROR: FEATURE_INPUT plugin: fvin_read() not found!\n"); + return FALSE; + } + + return TRUE; +} + +boolean +mfc_module_set_header(MFCCCalc *mfcc, Recog *recog) +{ + FUNC_INT func; + unsigned int ret; + + func = (FUNC_INT) plugin_get_func(mfcc->plugin_source, "fvin_get_configuration"); + if (func == NULL) { + jlog("ERROR: feature vector input plugin: fvin_get_configuration() not found\n"); + return FALSE; + } + + /* vector length in unit */ + mfcc->param->veclen = (*func)(0); + mfcc->param->header.sampsize = mfcc->param->veclen * sizeof(VECT); + /* frame shift in msec */ + mfcc->param->header.wshift = (*func)(1) * 10000.0; + /* parameter type for checking (return 0xffff to disable the check) */ + ret = (*func)(2); + if (ret == 0xffff) { + /* disable type checking */ + recog->jconf->input.paramtype_check_flag = FALSE; + } else { + mfcc->param->header.samptype = ret; + } + + return TRUE; +} + +boolean +mfc_module_standby(MFCCCalc *mfcc) +{ + FUNC_INT func; + int ret; + + if (mfcc->func.fv_standby) ret = mfcc->func.fv_standby(); + else ret = TRUE; + mfcc->segmented_by_input = FALSE; + return ret; +} + +boolean +mfc_module_begin(MFCCCalc *mfcc) +{ + FUNC_INT func; + int ret; + + if (mfcc->segmented_by_input) return TRUE; /* do nothing if last was segmented */ + + if (mfcc->func.fv_begin) ret = mfcc->func.fv_begin(); + else ret = TRUE; + return ret; +} + +boolean +mfc_module_end(MFCCCalc *mfcc) +{ + FUNC_INT func; + int ret; + + if (mfcc->segmented_by_input) return TRUE; /* do nothing if last was segmented */ + + if (mfcc->func.fv_end) ret = mfcc->func.fv_end(); + else ret = TRUE; + return ret; +} + +int +mfc_module_read(MFCCCalc *mfcc, int *new_t) +{ + FUNC_INT func; + int ret; + + /* expand area if needed */ + if (param_alloc(mfcc->param, mfcc->f + 1, mfcc->param->veclen) == FALSE) { + jlog("ERROR: FEATURE_INPUT plugin: failed to allocate memory\n"); + return -2; + } + /* get data */ + ret = mfcc->func.fv_read(mfcc->param->parvec[mfcc->f], mfcc->param->veclen); + if (ret == -3) { + /* function requests segmentation of the current recognition */ + mfcc->segmented_by_input = TRUE; + *new_t = mfcc->f; + return -3; + } else if (ret == -1) { + /* end of input */ + mfcc->segmented_by_input = FALSE; + *new_t = mfcc->f; + return -1; + } else if (ret == -2) { + /* error */ + jlog("ERROR: FEATURE_INPUT plugin: fvin_read() returns error (-2)\n"); + return -2; + } + + *new_t = mfcc->f + 1; + + return 0; +} + +#endif /* ENABLE_PLUGIN */ + +/* end of file */ Index: julius4/libjulius/src/realtime-1stpass.c diff -u julius4/libjulius/src/realtime-1stpass.c:1.4 julius4/libjulius/src/realtime-1stpass.c:1.5 --- julius4/libjulius/src/realtime-1stpass.c:1.4 Tue Jun 17 10:20:50 2008 +++ julius4/libjulius/src/realtime-1stpass.c Thu Sep 25 14:00:06 2008 @@ -111,7 +111,7 @@ * @author Akinobu Lee * @date Tue Aug 23 11:44:14 2005 * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * */ /* @@ -175,11 +175,6 @@ mfcc->param->header.wshift = para->smp_period * para->frameshift; mfcc->param->header.sampsize = para->veclen * sizeof(VECT); /* not compressed */ mfcc->param->veclen = para->veclen; - /* フレームごとのパラメータベクトル保存の領域を確保 */ - /* あとで必要に応じて伸長される */ - if (param_alloc(mfcc->param, 1, mfcc->param->veclen) == FALSE) { - j_internal_error("ERROR: segmented: failed to allocate memory for rest param\n"); - } /* 認識処理中/終了後にセットされる変数: param->parvec (パラメータベクトル系列) @@ -189,6 +184,9 @@ param->parvec (parameter vector sequence) param->header.samplenum, param->samplenum (total number of frames) */ + /* MAP-CMN の初期化 */ + /* Prepare for MAP-CMN */ + if (mfcc->para->cmn || mfcc->para->cvn) CMN_realtime_prepare(mfcc->cmn.wrk); } /** @@ -230,6 +228,10 @@ jconf = recog->jconf; r = &(recog->real); + /* 最大フレーム長を最大入力時間数から計算 */ + /* set maximum allowed frame length */ + r->maxframelen = MAXSPEECHLEN / recog->jconf->input.frameshift; + /* -ssload 指定時, SS用のノイズスペクトルをファイルから読み込む */ /* if "-ssload", load noise spectrum for spectral subtraction from file */ for(mfcc = recog->mfcclist; mfcc; mfcc = mfcc->next) { @@ -280,9 +282,6 @@ } } - /* 最大フレーム長を最大入力時間数から計算 */ - /* set maximum allowed frame length */ - r->maxframelen = MAXSPEECHLEN / recog->jconf->input.frameshift; /* 窓長をセット */ /* set window length */ r->windowlen = recog->jconf->input.framesize + 1; @@ -321,7 +320,6 @@ reset_mfcc(Recog *recog) { Value *para; - PROCESS_AM *am; MFCCCalc *mfcc; RealBeam *r; @@ -342,11 +340,6 @@ if (para->acc) WMP_deltabuf_prepare(mfcc->ab); } - /* 音響尤度計算用キャッシュを準備 */ - /* prepare cache area for acoustic computation of HMM states and mixtures */ - for(am=recog->amlist;am;am=am->next) { - outprob_prepare(&(am->hmmwrk), r->maxframelen); - } } /** @@ -394,26 +387,41 @@ for(mfcc = recog->mfcclist; mfcc; mfcc = mfcc->next) { /* パラメータ初期化 */ /* parameter initialization */ - init_param(mfcc); + if (recog->jconf->input.speech_input == SP_MFCMODULE) { + if (mfc_module_set_header(mfcc, recog) == FALSE) return FALSE; + } else { + init_param(mfcc); + } + /* フレームごとのパラメータベクトル保存の領域を確保 */ + /* あとで必要に応じて伸長される */ + if (param_alloc(mfcc->param, 1, mfcc->param->veclen) == FALSE) { + j_internal_error("ERROR: segmented: failed to allocate memory for rest param\n"); + } /* フレーム数をリセット */ /* reset frame count */ mfcc->f = 0; - /* MAP-CMN の初期化 */ - /* Prepare for MAP-CMN */ - if (mfcc->para->cmn || mfcc->para->cvn) CMN_realtime_prepare(mfcc->cmn.wrk); } /* 準備した param 構造体のデータのパラメータ型を音響モデルとチェックする */ /* check type coherence between param and hmminfo here */ - for(am=recog->amlist;am;am=am->next) { - if (!check_param_coherence(am->hmminfo, am->mfcc->param)) { - jlog("ERROR: input parameter type does not match AM\n"); - return FALSE; + if (recog->jconf->input.paramtype_check_flag) { + for(am=recog->amlist;am;am=am->next) { + if (!check_param_coherence(am->hmminfo, am->mfcc->param)) { + jlog("ERROR: input parameter type does not match AM\n"); + return FALSE; + } } } /* 計算用のワークエリアを準備 */ /* prepare work area for calculation */ - reset_mfcc(recog); + if (recog->jconf->input.type == INPUT_WAVEFORM) { + reset_mfcc(recog); + } + /* 音響尤度計算用キャッシュを準備 */ + /* prepare cache area for acoustic computation of HMM states and mixtures */ + for(am=recog->amlist;am;am=am->next) { + outprob_prepare(&(am->hmmwrk), r->maxframelen); + } #ifdef BACKEND_VAD if (recog->jconf->decodeopt.segment) { @@ -564,10 +572,149 @@ /* CMN を計算 */ /* perform CMN */ if (para->cmn || para->cvn) CMN_realtime(mfcc->cmn.wrk, tmpmfcc); - + return TRUE; } +static int +proceed_one_frame(Recog *recog) +{ + MFCCCalc *mfcc; + RealBeam *r; + int maxf; + PROCESS_AM *am; + int rewind_frame; + boolean reprocess; + boolean ok_p; + + r = &(recog->real); + + /* call recognition start callback */ + ok_p = FALSE; + maxf = 0; + for (mfcc = recog->mfcclist; mfcc; mfcc = mfcc->next) { + if (!mfcc->valid) continue; + if (maxf < mfcc->f) maxf = mfcc->f; + if (mfcc->f == 0) { + ok_p = TRUE; + } + } + if (ok_p && maxf == 0) { + /* call callback when at least one of MFCC has initial frame */ + if (recog->jconf->decodeopt.segment) { +#ifdef BACKEND_VAD + /* not exec pass1 begin callback here */ +#else + if (!recog->process_segment) { + callback_exec(CALLBACK_EVENT_RECOGNITION_BEGIN, recog); + } + callback_exec(CALLBACK_EVENT_SEGMENT_BEGIN, recog); + callback_exec(CALLBACK_EVENT_PASS1_BEGIN, recog); + recog->triggered = TRUE; +#endif + } else { + callback_exec(CALLBACK_EVENT_RECOGNITION_BEGIN, recog); + callback_exec(CALLBACK_EVENT_PASS1_BEGIN, recog); + recog->triggered = TRUE; + } + } + /* 各インスタンスについて mfcc->f の認識処理を1フレーム進める */ + switch (decode_proceed(recog)) { + case -1: /* error */ + return -1; + break; + case 0: /* success */ + break; + case 1: /* segmented */ + /* 認識処理のセグメント要求で終わったことをフラグにセット */ + /* set flag which indicates that the input has ended with segmentation request */ + r->last_is_segmented = TRUE; + /* tell the caller to be segmented by this function */ + /* 呼び出し元に,ここで入力を切るよう伝える */ + return 1; + } +#ifdef BACKEND_VAD + /* check up trigger in case of VAD segmentation */ + if (recog->jconf->decodeopt.segment) { + if (recog->triggered == FALSE) { + if (spsegment_trigger_sync(recog)) { + if (!recog->process_segment) { + callback_exec(CALLBACK_EVENT_RECOGNITION_BEGIN, recog); + } + callback_exec(CALLBACK_EVENT_SEGMENT_BEGIN, recog); + callback_exec(CALLBACK_EVENT_PASS1_BEGIN, recog); + recog->triggered = TRUE; + } + } + } +#endif + + if (spsegment_need_restart(recog, &rewind_frame, &reprocess) == TRUE) { + /* set total length to the current frame */ + for (mfcc = recog->mfcclist; mfcc; mfcc = mfcc->next) { + if (!mfcc->valid) continue; + mfcc->param->header.samplenum = mfcc->f + 1; + mfcc->param->samplenum = mfcc->f + 1; + } + /* do rewind for all mfcc here */ + spsegment_restart_mfccs(recog, rewind_frame, reprocess); + /* also tell adin module to rehash the concurrent audio input */ + recog->adin->rehash = TRUE; + /* reset outprob cache for all AM */ + for(am=recog->amlist;am;am=am->next) { + outprob_prepare(&(am->hmmwrk), am->mfcc->param->samplenum); + } + if (reprocess) { + /* process the backstep MFCCs here */ + while(1) { + ok_p = TRUE; + for (mfcc = recog->mfcclist; mfcc; mfcc = mfcc->next) { + if (! mfcc->valid) continue; + mfcc->f++; + if (mfcc->f < mfcc->param->samplenum) { + mfcc->valid = TRUE; + ok_p = FALSE; + } else { + mfcc->valid = FALSE; + } + } + if (ok_p) { + /* すべての MFCC が終わりに達したのでループ終了 */ + /* all MFCC has been processed, end of loop */ + for (mfcc = recog->mfcclist; mfcc; mfcc = mfcc->next) { + if (! mfcc->valid) continue; + mfcc->f--; + } + break; + } + /* 各インスタンスについて mfcc->f の認識処理を1フレーム進める */ + switch (decode_proceed(recog)) { + case -1: /* error */ + return -1; + break; + case 0: /* success */ + break; + case 1: /* segmented */ + /* ignore segmentation while in the backstep segment */ + break; + } + /* call frame-wise callback */ + callback_exec(CALLBACK_EVENT_PASS1_FRAME, recog); + } + } + } + /* call frame-wise callback if at least one of MFCC is valid at this frame */ + for (mfcc = recog->mfcclist; mfcc; mfcc = mfcc->next) { + if (mfcc->valid) { + callback_exec(CALLBACK_EVENT_PASS1_FRAME, recog); + break; + } + } + + return 0; +} + + /** * * @brief 第1パス平行音声認識処理のメイン @@ -639,17 +786,9 @@ int RealTimePipeLine(SP16 *Speech, int nowlen, Recog *recog) /* Speech[0...nowlen] = input */ { - int i, now; + int i, now, ret; MFCCCalc *mfcc; RealBeam *r; - int maxf; - boolean ok_p; - - RecogProcess *p; - PROCESS_AM *am; - int rewind_frame; - boolean reprocess; - boolean all_false, all_true; r = &(recog->real); @@ -700,8 +839,12 @@ /* calculate a parameter vector from current waveform windows and store to r->tmpmfcc */ if ((*(recog->calc_vector))(mfcc, r->window, r->windowlen)) { - mfcc->valid = TRUE; +#ifdef ENABLE_PLUGIN + /* call post-process plugin if exist */ + plugin_exec_vector_postprocess(mfcc->tmpmfcc, mfcc->param->veclen, mfcc->f); +#endif /* MFCC完成,登録 */ + mfcc->valid = TRUE; /* now get the MFCC vector of current frame, now store it to param */ if (param_alloc(mfcc->param, mfcc->f + 1, mfcc->param->veclen) == FALSE) { jlog("ERROR: failed to allocate memory for incoming MFCC vectors\n"); @@ -714,148 +857,29 @@ } } - /* call recognition start callback */ - ok_p = FALSE; - maxf = 0; - for (mfcc = recog->mfcclist; mfcc; mfcc = mfcc->next) { - if (!mfcc->valid) continue; - if (maxf < mfcc->f) maxf = mfcc->f; - if (mfcc->f == 0) { - ok_p = TRUE; - } - } - if (ok_p && maxf == 0) { - /* call callback when at least one of MFCC has initial frame */ - if (recog->jconf->decodeopt.segment) { -#ifdef BACKEND_VAD - /* not exec pass1 begin callback here */ -#else - if (!recog->process_segment) { - callback_exec(CALLBACK_EVENT_RECOGNITION_BEGIN, recog); - } - callback_exec(CALLBACK_EVENT_SEGMENT_BEGIN, recog); - callback_exec(CALLBACK_EVENT_PASS1_BEGIN, recog); - recog->triggered = TRUE; -#endif - } else { - callback_exec(CALLBACK_EVENT_RECOGNITION_BEGIN, recog); - callback_exec(CALLBACK_EVENT_PASS1_BEGIN, recog); - recog->triggered = TRUE; - } - } - - /* 各インスタンスについて mfcc->f の認識処理を1フレーム進める */ - switch (decode_proceed(recog)) { - case -1: /* error */ - return -1; - break; - case 0: /* success */ - break; - case 1: /* segmented */ - /* 認識処理のセグメント要求で終わったことをフラグにセット */ - /* set flag which indicates that the input has ended with segmentation request */ - r->last_is_segmented = TRUE; - if (recog->jconf->decodeopt.segment) { - /* ショートポーズセグメンテーション: バッファに残っているデータを - 別に保持して,次回の最初に処理する */ - /* short pause segmentation: there is some data left in buffer, so - we should keep them for next processing */ - r->rest_len = nowlen - now; - if (r->rest_len > 0) { - /* copy rest samples to rest_Speech */ - if (r->rest_Speech == NULL) { - r->rest_alloc_len = r->rest_len; - r->rest_Speech = (SP16 *)mymalloc(sizeof(SP16)*r->rest_alloc_len); - } else if (r->rest_alloc_len < r->rest_len) { - r->rest_alloc_len = r->rest_len; - r->rest_Speech = (SP16 *)myrealloc(r->rest_Speech, sizeof(SP16)*r->rest_alloc_len); - } - memcpy(r->rest_Speech, &(Speech[now]), sizeof(SP16) * r->rest_len); + /* 処理を1フレーム進める */ + /* proceed one frame */ + ret = proceed_one_frame(recog); + + if (ret == 1 && recog->jconf->decodeopt.segment) { + /* ショートポーズセグメンテーション: バッファに残っているデータを + 別に保持して,次回の最初に処理する */ + /* short pause segmentation: there is some data left in buffer, so + we should keep them for next processing */ + r->rest_len = nowlen - now; + if (r->rest_len > 0) { + /* copy rest samples to rest_Speech */ + if (r->rest_Speech == NULL) { + r->rest_alloc_len = r->rest_len; + r->rest_Speech = (SP16 *)mymalloc(sizeof(SP16)*r->rest_alloc_len); + } else if (r->rest_alloc_len < r->rest_len) { + r->rest_alloc_len = r->rest_len; + r->rest_Speech = (SP16 *)myrealloc(r->rest_Speech, sizeof(SP16)*r->rest_alloc_len); } - } - /* tell the caller to be segmented by this function */ - /* 呼び出し元に,ここで入力を切るよう伝える */ - return 1; - } - -#ifdef BACKEND_VAD - /* check up trigger in case of VAD segmentation */ - if (recog->jconf->decodeopt.segment) { - if (recog->triggered == FALSE) { - if (spsegment_trigger_sync(recog)) { - if (!recog->process_segment) { - callback_exec(CALLBACK_EVENT_RECOGNITION_BEGIN, recog); - } - callback_exec(CALLBACK_EVENT_SEGMENT_BEGIN, recog); - callback_exec(CALLBACK_EVENT_PASS1_BEGIN, recog); - recog->triggered = TRUE; - } - } - } -#endif - - if (spsegment_need_restart(recog, &rewind_frame, &reprocess) == TRUE) { - /* set total length to the current frame */ - for (mfcc = recog->mfcclist; mfcc; mfcc = mfcc->next) { - if (!mfcc->valid) continue; - mfcc->param->header.samplenum = mfcc->f + 1; - mfcc->param->samplenum = mfcc->f + 1; - } - /* do rewind for all mfcc here */ - spsegment_restart_mfccs(recog, rewind_frame, reprocess); - /* also tell adin module to rehash the concurrent audio input */ - recog->adin->rehash = TRUE; - /* reset outprob cache for all AM */ - for(am=recog->amlist;am;am=am->next) { - outprob_prepare(&(am->hmmwrk), am->mfcc->param->samplenum); - } - if (reprocess) { - /* process the backstep MFCCs here */ - while(1) { - ok_p = TRUE; - for (mfcc = recog->mfcclist; mfcc; mfcc = mfcc->next) { - if (! mfcc->valid) continue; - mfcc->f++; - if (mfcc->f < mfcc->param->samplenum) { - mfcc->valid = TRUE; - ok_p = FALSE; - } else { - mfcc->valid = FALSE; - } - } - if (ok_p) { - /* すべての MFCC が終わりに達したのでループ終了 */ - /* all MFCC has been processed, end of loop */ - for (mfcc = recog->mfcclist; mfcc; mfcc = mfcc->next) { - if (! mfcc->valid) continue; - mfcc->f--; - } - break; - } - /* 各インスタンスについて mfcc->f の認識処理を1フレーム進める */ - switch (decode_proceed(recog)) { - case -1: /* error */ - return -1; - break; - case 0: /* success */ - break; - case 1: /* segmented */ - /* ignore segmentation while in the backstep segment */ - break; - } - /* call frame-wise callback */ - callback_exec(CALLBACK_EVENT_PASS1_FRAME, recog); - } - } - } - - /* call frame-wise callback if at least one of MFCC is valid at this frame */ - for (mfcc = recog->mfcclist; mfcc; mfcc = mfcc->next) { - if (mfcc->valid) { - callback_exec(CALLBACK_EVENT_PASS1_FRAME, recog); - break; + memcpy(r->rest_Speech, &(Speech[now]), sizeof(SP16) * r->rest_len); } } + if (ret != 0) return ret; /* 1フレーム処理が進んだのでポインタを進める */ /* proceed frame pointer */ @@ -919,12 +943,20 @@ #ifdef SPSEGMENT_NAIST RecogProcess *p; #endif + PROCESS_AM *am; r = &(recog->real); /* 計算用のワークエリアを準備 */ /* prepare work area for calculation */ - reset_mfcc(recog); + if (recog->jconf->input.type == INPUT_WAVEFORM) { + reset_mfcc(recog); + } + /* 音響尤度計算用キャッシュを準備 */ + /* prepare cache area for acoustic computation of HMM states and mixtures */ + for(am=recog->amlist;am;am=am->next) { + outprob_prepare(&(am->hmmwrk), r->maxframelen); + } /* param にある全パラメータを処理する準備 */ /* prepare to process all data in param */ @@ -1017,15 +1049,16 @@ } /* 前回のセグメント時に入力をシフトしていない分をシフトする */ /* do the last shift here */ - memmove(r->window, &(r->window[recog->jconf->input.frameshift]), sizeof(SP16) * (r->windowlen - recog->jconf->input.frameshift)); - r->windownum -= recog->jconf->input.frameshift; - - /* これで再開の準備が整ったので,まずは前回の処理で残っていた音声データから - 処理する */ - /* now that the search status has been prepared for the next input, we - first process the rest unprocessed samples at the last session */ - if (r->rest_len > 0) { - return(RealTimePipeLine(r->rest_Speech, r->rest_len, recog)); + if (recog->jconf->input.type == INPUT_WAVEFORM) { + memmove(r->window, &(r->window[recog->jconf->input.frameshift]), sizeof(SP16) * (r->windowlen - recog->jconf->input.frameshift)); + r->windownum -= recog->jconf->input.frameshift; + /* これで再開の準備が整ったので,まずは前回の処理で残っていた音声データから + 処理する */ + /* now that the search status has been prepared for the next input, we + first process the rest unprocessed samples at the last session */ + if (r->rest_len > 0) { + return(RealTimePipeLine(r->rest_Speech, r->rest_len, recog)); + } } /* 新規の入力に対して認識処理は続く… */ @@ -1103,6 +1136,17 @@ return(TRUE); } + if (recog->jconf->input.type == INPUT_VECTOR) { + /* finalize real-time 1st pass */ + for (mfcc = recog->mfcclist; mfcc; mfcc = mfcc->next) { + mfcc->param->header.samplenum = mfcc->f; + mfcc->param->samplenum = mfcc->f; + } + /* 最終フレーム処理を行い,認識の結果出力と終了処理を行う */ + decode_end(recog); + return TRUE; + } + /* MFCC計算の終了処理を行う: 最後の遅延フレーム分を処理 */ /* finish MFCC computation for the last delayed frames */ for (mfcc = recog->mfcclist; mfcc; mfcc = mfcc->next) { @@ -1207,6 +1251,10 @@ } /* store to mfcc->f */ memcpy(mfcc->param->parvec[mfcc->f], mfcc->tmpmfcc, sizeof(VECT) * mfcc->param->veclen); +#ifdef ENABLE_PLUGIN + /* call postprocess plugin if any */ + plugin_exec_vector_postprocess(mfcc->param->parvec[mfcc->f], mfcc->param->veclen, mfcc->f); +#endif } /* call recognition start callback */ @@ -1308,7 +1356,6 @@ void RealTimeCMNUpdate(MFCCCalc *mfcc, Recog *recog) { - float mseclen; boolean cmn_update_p; Value *para; Jconf *jconf; @@ -1408,4 +1455,108 @@ } } + + +/************************************************************************/ +/************************************************************************/ +/************************************************************************/ +/************************************************************************/ + +/* MFCC realtime input */ +/** + * + * + * + * + * + * + * + * @param recog + * @param ad_check + * + * @return 2 when input termination requested by recognition process, + * 1 when segmentation request returned from input module, 0 when end + * of input returned from input module, -1 on error, -2 when input + * termination requested by ad_check(). + * + */ +int +mfcc_go(Recog *recog, int (*ad_check)(Recog *)) +{ + RealBeam *r; + MFCCCalc *mfcc; + int new_f; + int ret, ret3; + + r = &(recog->real); + + r->last_is_segmented = FALSE; + + while(1/*in_data_vec*/) { + + ret = mfc_module_read(recog->mfcclist, &new_f); + + if (debug2_flag) { + if (recog->mfcclist->f < new_f) { + jlog("%d: %d (%d)\n", recog->mfcclist->f, new_f, ret); + } + } + + /* callback poll */ + if (ad_check != NULL) { + if ((ret3 = (*(ad_check))(recog)) < 0) { + if ((ret3 == -1 && mfcc->f == 0) || ret3 == -2) { + return(-2); + } + } + } + + while(recog->mfcclist->f < new_f) { + + recog->mfcclist->valid = TRUE; + +#ifdef ENABLE_PLUGIN + /* call post-process plugin if exist */ + plugin_exec_vector_postprocess(recog->mfcclist->param->parvec[recog->mfcclist->f], recog->mfcclist->param->veclen, mfcc->f); +#endif + + /* 処理を1フレーム進める */ + /* proceed one frame */ + + switch(proceed_one_frame(recog)) { + case -1: /* error */ + return -1; + case 0: /* normal */ + break; + case 1: /* segmented by process */ + return 2; + } + + /* 1フレーム処理が進んだのでポインタを進める */ + /* proceed frame pointer */ + for (mfcc = recog->mfcclist; mfcc; mfcc = mfcc->next) { + if (!mfcc->valid) continue; + mfcc->f++; + } + } + + /* check if input end */ + switch(ret) { + case -1: /* end of input */ + return 0; + case -2: /* error */ + return -1; + case -3: /* end of segment request */ + return 1; + } + } + /* 与えられた音声セグメントに対する認識処理が全て終了 + 呼び出し元に, 入力を続けるよう伝える */ + /* input segment is fully processed + tell the caller to continue input */ + return(1); +} + /* end of file */ + + Index: julius4/libjulius/src/recogmain.c diff -u julius4/libjulius/src/recogmain.c:1.6 julius4/libjulius/src/recogmain.c:1.7 --- julius4/libjulius/src/recogmain.c:1.6 Thu Jun 19 01:22:08 2008 +++ julius4/libjulius/src/recogmain.c Thu Sep 25 14:00:06 2008 @@ -12,7 +12,7 @@ * @author Akinobu Lee * @date Wed Aug 8 14:53:53 2007 * - * $Revision: 1.6 $ + * $Revision: 1.7 $ * */ @@ -399,16 +399,6 @@ perform immediate termination at this callback, but just ignore the results in the main.c. */ #if 1 -/* - * if (recog->jconf->input.speech_input != SP_ADINNET) { - * if (recog->process_want_terminate) { - * return(-2); - * } - * if (recog->process_want_reload) { - * return(-1); - * } - * } - */ if (recog->process_want_terminate) { /* TERMINATE ... force termination */ return(-2); } @@ -454,33 +444,45 @@ jconf = recog->jconf; - if (jconf->input.speech_input == SP_MFCFILE) { - /* read parameter file */ - param_init_content(recog->mfcclist->param); - if (rdparam(file_or_dev_name, recog->mfcclist->param) == FALSE) { - jlog("ERROR: error in reading parameter file: %s\n", file_or_dev_name); - return -1; - } - /* check and strip invalid frames */ - if (jconf->preprocess.strip_zero_sample) { - param_strip_zero(recog->mfcclist->param); - } - - /* output frame length */ - callback_exec(CALLBACK_STATUS_PARAM, recog); - } else { /* raw speech input */ + if (jconf->input.type == INPUT_WAVEFORM) { /* begin A/D input */ if (adin_begin(recog->adin) == FALSE) { return -2; } - } - -#if 0 - /* if not module mode, process becomes online after all initialize done */ - process_online = TRUE; - callback_exec(CALLBACK_EVENT_PROCESS_ONLINE, recog); + /* create A/D-in thread here */ +#ifdef HAVE_PTHREAD + if (recog->adin->enable_thread && ! recog->adin->input_side_segment) { + if (adin_thread_create(recog) == FALSE) { + return -2; + } + } #endif - + } else { + switch(jconf->input.speech_input) { + case SP_MFCMODULE: + param_init_content(recog->mfcclist->param); + if (mfc_module_begin(recog->mfcclist) == FALSE) return -2; + break; + case SP_MFCFILE: + /* read parameter file */ + param_init_content(recog->mfcclist->param); + if (rdparam(file_or_dev_name, recog->mfcclist->param) == FALSE) { + jlog("ERROR: error in reading parameter file: %s\n", file_or_dev_name); + return -1; + } + /* check and strip invalid frames */ + if (jconf->preprocess.strip_zero_sample) { + param_strip_zero(recog->mfcclist->param); + } + /* output frame length */ + callback_exec(CALLBACK_STATUS_PARAM, recog); + break; + default: + jlog("ERROR: none of SP_MFC_*??\n"); + return -2; + } + } + return 0; } @@ -520,6 +522,9 @@ if (ok_p) { /* had some input */ /* output as rejected */ callback_exec(CALLBACK_RESULT, recog); +#ifdef ENABLE_PLUGIN + plugin_exec_process_result(recog); +#endif } } @@ -570,10 +575,33 @@ PROCESS_LM *lm; boolean ok_p; boolean process_segment_last; + boolean on_the_fly; jconf = recog->jconf; - if (jconf->input.speech_input != SP_MFCFILE) { + /* determine whether on-the-fly decoding should be done */ + on_the_fly = FALSE; + switch(jconf->input.type) { + case INPUT_VECTOR: + switch(jconf->input.speech_input) { + case SP_MFCFILE: + on_the_fly = FALSE; + break; + case SP_MFCMODULE: + on_the_fly = TRUE; + break; + } + break; + case INPUT_WAVEFORM: + if (jconf->decodeopt.realtime_flag) { + on_the_fly = TRUE; + } else { + on_the_fly = FALSE; + } + break; + } + + if (jconf->input.type == INPUT_WAVEFORM || jconf->input.speech_input == SP_MFCMODULE) { for(mfcc=recog->mfcclist;mfcc;mfcc=mfcc->next) { param_init_content(mfcc->param); } @@ -692,106 +720,48 @@ goto start_recog; } - /**************************************/ - /* getting input and perform 1st pass */ - /**************************************/ - if (jconf->input.speech_input == SP_MFCFILE) { - /************************/ - /* parameter file input */ - /************************/ - /********************************/ - /* check the analized parameter */ - /********************************/ - /* parameter type check --- compare the type to that of HMM, - and adjust them if necessary */ - if (jconf->input.paramtype_check_flag) { - for(am=recog->amlist;am;am=am->next) { - /* return param itself or new malloced param */ - if (param_check_and_adjust(am->hmminfo, am->mfcc->param, verbose_flag) == -1) { /* failed */ - - for(mfcc=recog->mfcclist;mfcc;mfcc=mfcc->next) { - param_init_content(mfcc->param); - } - /* tell failure */ - result_error(recog, J_RESULT_STATUS_FAIL); - goto end_recog; - } + + /******************/ + /* start 1st pass */ + /******************/ + if (on_the_fly) { + + /********************************************/ + /* REALTIME ON-THE-FLY DECODING OF 1ST-PASS */ + /********************************************/ + /* store, analysis and search in a pipeline */ + /* main function is RealTimePipeLine() at realtime-1stpass.c, and + it will be periodically called for each incoming input segment + from the AD-in function adin_go(). RealTimePipeLine() will be + called as a callback function from adin_go() */ + /* after this part, directly jump to the beginning of the 2nd pass */ + + if (recog->process_segment) { + /*****************************************************************/ + /* short-pause segmentation: process last remaining frames first */ + /*****************************************************************/ + /* last was segmented by short pause */ + /* the margin segment in the last input will be re-processed first, + and then the speech input will be processed */ + /* process the last remaining parameters */ + ret = RealTimeResume(recog); + if (ret < 0) { /* error end in the margin */ + jlog("ERROR: failed to process last remaining samples on RealTimeResume\n"); /* exit now! */ + return -1; } - } - /* whole input is already read, so set input status to end of stream */ - /* and jump to the start point of 1st pass */ - ret = 0; - } else { - /****************************************************/ - /* raw wave data input (mic, file, adinnet, etc...) */ - /****************************************************/ - if (jconf->decodeopt.realtime_flag) { - /********************************************/ - /* REALTIME ON-THE-FLY DECODING OF 1ST-PASS */ - /********************************************/ - /* store, analysis and search in a pipeline */ - /* main function is RealTimePipeLine() at realtime-1stpass.c, and - it will be periodically called for each incoming input segment - from the AD-in function adin_go(). RealTimePipeLine() will be - called as a callback function from adin_go() */ - /* after this part, directly jump to the beginning of the 2nd pass */ - - if (recog->process_segment) { - /*****************************************************************/ - /* short-pause segmentation: process last remaining frames first */ - /*****************************************************************/ - /* last was segmented by short pause */ - /* the margin segment in the last input will be re-processed first, - and then the speech input will be processed */ - /* process the last remaining parameters */ - ret = RealTimeResume(recog); - if (ret < 0) { /* error end in the margin */ - jlog("ERROR: failed to process last remaining samples on RealTimeResume\n"); /* exit now! */ - return -1; - } - if (ret != 1) { /* if segmented again in the margin, not process the rest */ - /* last parameters has been processed, so continue with the - current input as normal */ - /* process the incoming input */ + if (ret != 1) { /* if segmented again in the margin, not process the rest */ + /* last parameters has been processed, so continue with the + current input as normal */ + /* process the incoming input */ + if (jconf->input.type == INPUT_WAVEFORM) { + /* get speech and process it on real-time */ ret = adin_go(RealTimePipeLine, callback_check_in_adin, recog); - if (ret < 0) { /* error end in adin_go */ - if (ret == -2 || recog->process_want_terminate) { - /* terminated by callback */ - RealTimeTerminate(recog); - /* reset param */ - for(mfcc=recog->mfcclist;mfcc;mfcc=mfcc->next) { - param_init_content(mfcc->param); - } - /* execute callback at end of pass1 */ - if (recog->triggered) { - callback_exec(CALLBACK_EVENT_PASS1_END, recog); - /* output result terminate */ - result_error(recog, J_RESULT_STATUS_TERMINATE); - } - goto end_recog; /* cancel this recognition */ - } - jlog("ERROR: an error occured at on-the-fly 1st pass decoding\n"); /* exit now! */ - return(-1); - } + } else { + /* get feature vector and process it */ + ret = mfcc_go(recog, callback_check_in_adin); } - - } else { - - /***********************************************************/ - /* last was not segmented, process the new incoming input */ - /***********************************************************/ - /* end of this input will be determined by either end of stream - (in case of file input), or silence detection by adin_go(), or - 'TERMINATE' command from module (if module mode) */ - /* prepare work area for on-the-fly processing */ - if (RealTimePipeLinePrepare(recog) == FALSE) { - jlog("ERROR: failed to prepare for on-the-fly 1st pass decoding"); - return (-1); - } - /* process the incoming input */ - ret = adin_go(RealTimePipeLine, callback_check_in_adin, recog); if (ret < 0) { /* error end in adin_go */ - if (ret == -2 || recog->process_want_terminate) { + if (ret == -2 || recog->process_want_terminate) { /* terminated by callback */ RealTimeTerminate(recog); /* reset param */ @@ -804,168 +774,244 @@ /* output result terminate */ result_error(recog, J_RESULT_STATUS_TERMINATE); } - goto end_recog; + goto end_recog; /* cancel this recognition */ } jlog("ERROR: an error occured at on-the-fly 1st pass decoding\n"); /* exit now! */ return(-1); } } - /******************************************************************/ - /* speech stream has been processed on-the-fly, and 1st pass ends */ - /******************************************************************/ - /* last procedure of 1st-pass */ - if (RealTimeParam(recog) == FALSE) { - jlog("ERROR: fatal error occured, program terminates now\n"); - return -1; - } + + } else { -#ifdef BACKEND_VAD - /* if not triggered, skip this segment */ - if (recog->jconf->decodeopt.segment && ! recog->triggered) { - goto end_recog; + /***********************************************************/ + /* last was not segmented, process the new incoming input */ + /***********************************************************/ + /* end of this input will be determined by either end of stream + (in case of file input), or silence detection by adin_go(), or + 'TERMINATE' command from module (if module mode) */ + /* prepare work area for on-the-fly processing */ + if (RealTimePipeLinePrepare(recog) == FALSE) { + jlog("ERROR: failed to prepare for on-the-fly 1st pass decoding\n"); + return (-1); + } + /* process the incoming input */ + if (jconf->input.type == INPUT_WAVEFORM) { + /* get speech and process it on real-time */ + ret = adin_go(RealTimePipeLine, callback_check_in_adin, recog); + } else { + /* get feature vector and process it */ + ret = mfcc_go(recog, callback_check_in_adin); } + + if (ret < 0) { /* error end in adin_go */ + if (ret == -2 || recog->process_want_terminate) { + /* terminated by callback */ + RealTimeTerminate(recog); + /* reset param */ + for(mfcc=recog->mfcclist;mfcc;mfcc=mfcc->next) { + param_init_content(mfcc->param); + } + /* execute callback at end of pass1 */ + if (recog->triggered) { + callback_exec(CALLBACK_EVENT_PASS1_END, recog); + /* output result terminate */ + result_error(recog, J_RESULT_STATUS_TERMINATE); + } + goto end_recog; + } + jlog("ERROR: an error occured at on-the-fly 1st pass decoding\n"); /* exit now! */ + return(-1); + } + } + /******************************************************************/ + /* speech stream has been processed on-the-fly, and 1st pass ends */ + /******************************************************************/ + /* last procedure of 1st-pass */ + if (RealTimeParam(recog) == FALSE) { + jlog("ERROR: fatal error occured, program terminates now\n"); + return -1; + } + +#ifdef BACKEND_VAD + /* if not triggered, skip this segment */ + if (recog->jconf->decodeopt.segment && ! recog->triggered) { + goto end_recog; + } #endif - /* execute callback for 1st pass result */ - /* result.status <0 must be skipped inside callback */ - callback_exec(CALLBACK_RESULT_PASS1, recog); + /* execute callback for 1st pass result */ + /* result.status <0 must be skipped inside callback */ + callback_exec(CALLBACK_RESULT_PASS1, recog); #ifdef WORD_GRAPH - /* result.wg1 == NULL should be skipped inside callback */ - callback_exec(CALLBACK_RESULT_PASS1_GRAPH, recog); + /* result.wg1 == NULL should be skipped inside callback */ + callback_exec(CALLBACK_RESULT_PASS1_GRAPH, recog); #endif - /* execute callback at end of pass1 */ - callback_exec(CALLBACK_EVENT_PASS1_END, recog); - /* output frame length */ - callback_exec(CALLBACK_STATUS_PARAM, recog); - /* if terminate signal has been received, discard this input */ - if (recog->process_want_terminate) { - result_error(recog, J_RESULT_STATUS_TERMINATE); - goto end_recog; - } + /* execute callback at end of pass1 */ + callback_exec(CALLBACK_EVENT_PASS1_END, recog); + /* output frame length */ + callback_exec(CALLBACK_STATUS_PARAM, recog); + /* if terminate signal has been received, discard this input */ + if (recog->process_want_terminate) { + result_error(recog, J_RESULT_STATUS_TERMINATE); + goto end_recog; + } - /* end of 1st pass, jump to 2nd pass */ - goto end_1pass; - - } /* end of realtime_flag && speech stream input */ - - /******************************************/ - /* buffered speech input (not on-the-fly) */ - /******************************************/ - if (!recog->process_segment) { /* no segment left */ - - /****************************************/ - /* store raw speech samples to speech[] */ - /****************************************/ - recog->speechlen = 0; - for(mfcc=recog->mfcclist;mfcc;mfcc=mfcc->next) { - param_init_content(mfcc->param); - } - /* tell module to start recording */ - /* the "adin_cut_callback_store_buffer" simply stores - the input speech to a buffer "speech[]" */ - /* end of this input will be determined by either end of stream - (in case of file input), or silence detection by adin_go(), or - 'TERMINATE' command from module (if module mode) */ - ret = adin_go(adin_cut_callback_store_buffer, callback_check_in_adin, recog); - if (ret < 0) { /* error end in adin_go */ - if (ret == -2 || recog->process_want_terminate) { - /* terminated by module */ - /* output fail */ - result_error(recog, J_RESULT_STATUS_TERMINATE); - goto end_recog; + /* END OF ON-THE-FLY INPUT AND DECODING OF 1ST PASS */ + + } else { + + /******************/ + /* buffered input */ + /******************/ + + if (jconf->input.type == INPUT_VECTOR) { + /***********************/ + /* feature vector input */ + /************************/ + if (jconf->input.speech_input == SP_MFCFILE) { + /************************/ + /* parameter file input */ + /************************/ + /* parameter type check --- compare the type to that of HMM, + and adjust them if necessary */ + if (jconf->input.paramtype_check_flag) { + for(am=recog->amlist;am;am=am->next) { + /* return param itself or new malloced param */ + if (param_check_and_adjust(am->hmminfo, am->mfcc->param, verbose_flag) == -1) { /* failed */ + + for(mfcc=recog->mfcclist;mfcc;mfcc=mfcc->next) { + param_init_content(mfcc->param); + } + /* tell failure */ + result_error(recog, J_RESULT_STATUS_FAIL); + goto end_recog; + } + } } - jlog("ERROR: an error occured while recording input\n"); - return -1; + /* whole input is already read, so set input status to end of stream */ + /* and jump to the start point of 1st pass */ + ret = 0; } + } else { + /*************************/ + /* buffered speech input */ + /*************************/ + if (!recog->process_segment) { /* no segment left */ + + /****************************************/ + /* store raw speech samples to speech[] */ + /****************************************/ + recog->speechlen = 0; + for(mfcc=recog->mfcclist;mfcc;mfcc=mfcc->next) { + param_init_content(mfcc->param); + } + /* tell module to start recording */ + /* the "adin_cut_callback_store_buffer" simply stores + the input speech to a buffer "speech[]" */ + /* end of this input will be determined by either end of stream + (in case of file input), or silence detection by adin_go(), or + 'TERMINATE' command from module (if module mode) */ + ret = adin_go(adin_cut_callback_store_buffer, callback_check_in_adin, recog); + if (ret < 0) { /* error end in adin_go */ + if (ret == -2 || recog->process_want_terminate) { + /* terminated by module */ + /* output fail */ + result_error(recog, J_RESULT_STATUS_TERMINATE); + goto end_recog; + } + jlog("ERROR: an error occured while recording input\n"); + return -1; + } + + /* output recorded length */ + seclen = (float)recog->speechlen / (float)jconf->input.sfreq; + jlog("STAT: %d samples (%.2f sec.)\n", recog->speechlen, seclen); + + /* -rejectshort 指定時, 入力が指定時間以下であれば + ここで入力を棄却する */ + /* when using "-rejectshort", and input was shorter than + specified, reject the input here */ + if (jconf->reject.rejectshortlen > 0) { + if (seclen * 1000.0 < jconf->reject.rejectshortlen) { + result_error(recog, J_RESULT_STATUS_REJECT_SHORT); + goto end_recog; + } + } - /* output recorded length */ - seclen = (float)recog->speechlen / (float)jconf->input.sfreq; - jlog("STAT: %d samples (%.2f sec.)\n", recog->speechlen, seclen); - - /* -rejectshort 指定時, 入力が指定時間以下であれば - ここで入力を棄却する */ - /* when using "-rejectshort", and input was shorter than - specified, reject the input here */ - if (jconf->reject.rejectshortlen > 0) { - if (seclen * 1000.0 < jconf->reject.rejectshortlen) { - result_error(recog, J_RESULT_STATUS_REJECT_SHORT); + /**********************************************/ + /* acoustic analysis and encoding of speech[] */ + /**********************************************/ + jlog("STAT: ### speech analysis (waveform -> MFCC)\n"); + /* CMN will be computed for the whole buffered input */ + if (wav2mfcc(recog->speech, recog->speechlen, recog) == FALSE) { + /* error end, end stream */ + ret = -1; + /* tell failure */ + result_error(recog, J_RESULT_STATUS_FAIL); goto end_recog; } + + /* if terminate signal has been received, cancel this input */ + if (recog->process_want_terminate) { + result_error(recog, J_RESULT_STATUS_TERMINATE); + goto end_recog; + } + + /* output frame length */ + callback_exec(CALLBACK_STATUS_PARAM, recog); } - - /**********************************************/ - /* acoustic analysis and encoding of speech[] */ - /**********************************************/ - jlog("STAT: ### speech analysis (waveform -> MFCC)\n"); - /* CMN will be computed for the whole buffered input */ - if (wav2mfcc(recog->speech, recog->speechlen, recog) == FALSE) { - /* error end, end stream */ - ret = -1; - /* tell failure */ - result_error(recog, J_RESULT_STATUS_FAIL); - goto end_recog; - } - - /* if terminate signal has been received, cancel this input */ - if (recog->process_want_terminate) { - result_error(recog, J_RESULT_STATUS_TERMINATE); - goto end_recog; + } + +#ifdef ENABLE_PLUGIN + /* call post-process plugin if exist */ + plugin_exec_vector_postprocess_all(recog->mfcclist->param); +#endif + + /******************************************************/ + /* 1st-pass --- backward search to compute heuristics */ + /******************************************************/ + if (!jconf->decodeopt.realtime_flag) { + /* prepare for outprob cache for each HMM state and time frame */ + /* assume all MFCCCalc has params of the same sample num */ + for(am=recog->amlist;am;am=am->next) { + outprob_prepare(&(am->hmmwrk), am->mfcc->param->samplenum); } - - /* output frame length */ - callback_exec(CALLBACK_STATUS_PARAM, recog); - } - } /* end of data input */ - /* parameter has been got in 'param' */ - - /******************************************************/ - /* 1st-pass --- backward search to compute heuristics */ - /******************************************************/ - /* (for buffered speech input and HTK parameter file input) */ - if (!jconf->decodeopt.realtime_flag) { - /* prepare for outprob cache for each HMM state and time frame */ - /* assume all MFCCCalc has params of the same sample num */ - for(am=recog->amlist;am;am=am->next) { - outprob_prepare(&(am->hmmwrk), am->mfcc->param->samplenum); + + /* if terminate signal has been received, cancel this input */ + if (recog->process_want_terminate) { + result_error(recog, J_RESULT_STATUS_TERMINATE); + goto end_recog; } - } - - /* if terminate signal has been received, cancel this input */ - if (recog->process_want_terminate) { - result_error(recog, J_RESULT_STATUS_TERMINATE); - goto end_recog; - } - - /****************************************************/ - /* execute computation of left-to-right backtrellis */ - /****************************************************/ - if (get_back_trellis(recog) == FALSE) { - jlog("ERROR: fatal error occured, program terminates now\n"); - return -1; - } + /* execute computation of left-to-right backtrellis */ + if (get_back_trellis(recog) == FALSE) { + jlog("ERROR: fatal error occured, program terminates now\n"); + return -1; + } #ifdef BACKEND_VAD - /* if not triggered, skip this segment */ - if (recog->jconf->decodeopt.segment && ! recog->triggered) { - goto end_recog; - } + /* if not triggered, skip this segment */ + if (recog->jconf->decodeopt.segment && ! recog->triggered) { + goto end_recog; + } #endif - - /* execute callback for 1st pass result */ - /* result.status <0 must be skipped inside callback */ - callback_exec(CALLBACK_RESULT_PASS1, recog); + + /* execute callback for 1st pass result */ + /* result.status <0 must be skipped inside callback */ + callback_exec(CALLBACK_RESULT_PASS1, recog); #ifdef WORD_GRAPH - /* result.wg1 == NULL should be skipped inside callback */ - callback_exec(CALLBACK_RESULT_PASS1_GRAPH, recog); + /* result.wg1 == NULL should be skipped inside callback */ + callback_exec(CALLBACK_RESULT_PASS1_GRAPH, recog); #endif + + /* execute callback at end of pass1 */ + if (recog->triggered) { + callback_exec(CALLBACK_EVENT_PASS1_END, recog); + } - /* execute callback at end of pass1 */ - if (recog->triggered) { - callback_exec(CALLBACK_EVENT_PASS1_END, recog); - } + /* END OF BUFFERED 1ST PASS */ - end_1pass: + } /**********************************/ /* end processing of the 1st-pass */ @@ -1069,6 +1115,9 @@ /* output result */ callback_exec(CALLBACK_RESULT, recog); +#ifdef ENABLE_PLUGIN + plugin_exec_process_result(recog); +#endif /* output graph */ /* r->result.wg == NULL should be skipped inside the callback */ ok_p = FALSE; @@ -1108,7 +1157,7 @@ /**********************/ /* update CMN info for next input (in case of realtime wave input) */ - if (jconf->input.speech_input != SP_MFCFILE && jconf->decodeopt.realtime_flag) { + if (jconf->input.type == INPUT_WAVEFORM && jconf->decodeopt.realtime_flag) { for(mfcc=recog->mfcclist;mfcc;mfcc=mfcc->next) { if (mfcc->param->samplenum > 0) { RealTimeCMNUpdate(mfcc, recog); @@ -1167,16 +1216,12 @@ } /* END OF STREAM LOOP */ - /* input stream ended. it will happen when - - input speech file has reached the end of file, - - adinnet input has received end of segment mark from client, - - adinnet input has received end of input from client, - - adinnet client disconnected. - */ - - if (jconf->input.speech_input != SP_MFCFILE) { - /* close the stream */ - adin_end(recog->adin); + /* close the stream */ + if (jconf->input.type == INPUT_WAVEFORM) { + if (adin_end(recog->adin) == FALSE) return -1; + } + if (jconf->input.speech_input == SP_MFCMODULE) { + if (mfc_module_end(recog->mfcclist) == FALSE) return -1; } /* return to the opening of input stream */ From sumomo @ users.sourceforge.jp Thu Sep 25 14:00:08 2008 From: sumomo @ users.sourceforge.jp (sumomo @ users.sourceforge.jp) Date: Thu, 25 Sep 2008 14:00:08 +0900 Subject: [Julius-cvs 261] CVS update: julius4/plugin Message-ID: <1222318808.489289.7961.nullmailer@users.sourceforge.jp> Index: julius4/plugin/00readme-ja.txt diff -u /dev/null julius4/plugin/00readme-ja.txt:1.1 --- /dev/null Thu Sep 25 14:00:08 2008 +++ julius4/plugin/00readme-ja.txt Thu Sep 25 14:00:08 2008 @@ -0,0 +1,59 @@ +????????? + + +? ????????? + +Julius-4.1 ???????????????????? +????????????????????????????????? + +?????????????????????????????? +Juliusbook ???????? +??????????????????????????????D + + +? ?????? + + 00readme.txt ?????? + plugin_defs.h ??????????? + adin_oss.c ???????????????OSS????? + audio_postprocess.c ?????v??????????? + fvin.c ????????????????? + feature_postprocess.c ??????v??????????? + calcmix.c ???????v??????????? + Makefile Linux ? Makefile + + +? ?????????????????? + +?????????????? .jpi ??? +?????タ????????????????? +gcc ???????????????????????? + + % gcc -shared -o adin_oss.jpi adin_oss.c + + +? Julius ??????????????? + +Julius ?????? "-plugindir dirname" ??????dirname ???? +????????????????????????? +????????????????? .jpi ????????????? + +??????????????????????????"-plugindir" ? +??????????????w???????????? + + +? ????? + +??? adin_oss.c ??OSS API ??????????????????? +Julius ????? "-input myadin" ???????? + +Julius ????????????????????????? + + % cd plugin (????????) + % make adin_oss.jpi + % cd .. + % ./julius/julius -plugindir plugin -input myadin + +????????????? adintool ? adinrec ?????????D + + % ./adinrec/adinrec -plugindir plugin -input myadin Index: julius4/plugin/00readme.txt diff -u /dev/null julius4/plugin/00readme.txt:1.1 --- /dev/null Thu Sep 25 14:00:08 2008 +++ julius4/plugin/00readme.txt Thu Sep 25 14:00:08 2008 @@ -0,0 +1,59 @@ +Plugin samples +================ + +From rev.4.1, plugin is supported. This directory contains exmaple +sample source codes of plugins. + +Function specifications of plugin are fully documented within the +source. See the instruction below. + + +Files +====== + + 00readme.txt This file + plugin_defs.h Plugin related typedefs for C. + adin_oss.c A/D-in plugin example: OSS mic input + audio_postprocess.c A/D-in postprocess plugin + fvin.c Feature vector input plugin + feature_postprocess.c Feature vector postprocess plugin + calcmix.c AM Mixture calculation plugin + Makefile Makefile for Linux / mingw + + +How to compile +=============== + +The source should be compiled into a dynamic shared object. +The object file should have a suffix of ".jpi". +For example, you can compile "adin_oss.c" using gcc like this: + + % gcc -shared -o adin_oss.jpi adin_oss.c + + +How to use +=========== + +Add option "-plugindir dirname" to Julius. The "dirname" should be +a directory (or colon-separated list of directories). All the .jpi +files in the specified directory will be loaded into Julius at startup. + + +How to test +============ + +You can test the OSS API audio input plugin written at "adin_oss.c". +The loaded plugin component "adin_oss.jpi" will be selected as input +by specifying "-input myadin", where the string "myadin" is the +string which the function "adin_get_optname()" returns in adin_oss.c. + + % cd plugin + % make adin_oss.jpi + % cd .. + % ./julius/julius -plugindir plugin -input myadin + +This adin plugin can be used from adintool and adinrec like this: + + % ./adinrec/adinrec -plugindir plugin -input myadin + + Index: julius4/plugin/Makefile diff -u /dev/null julius4/plugin/Makefile:1.1 --- /dev/null Thu Sep 25 14:00:08 2008 +++ julius4/plugin/Makefile Thu Sep 25 14:00:08 2008 @@ -0,0 +1,23 @@ +SHELL=/bin/sh + +.SUFFIXES: +.SUFFIXES: .c .jpi +.c.jpi: + $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< + +CC=gcc +CFLAGS=-shared +LDFLAGS= +J_CFLAGS=-I../libsent/include -I../libjulius/include `../libsent/libsent-config --cflags` `../libjulius/libjulius-config --cflags` +J_LDFLAGS=-L../libjulius `../libjulius/libjulius-config --libs` -L../libsent `../libsent/libsent-config --libs` + +all: adin_oss.jpi audio_postprocess.jpi fvin.jpi feature_postprocess.jpi calcmix.jpi generic_callback.jpi result.jpi + +calcmix.jpi: calcmix.c + $(CC) $(CFLAGS) $(J_CFLAGS) -o calcmix.jpi $(LDFLAGS) $(J_LDFLAGS) calcmix.c + +generic_callback.jpi: generic_callback.c + $(CC) $(CFLAGS) $(J_CFLAGS) -o generic_callback.jpi generic_callback.c $(LDFLAGS) $(J_LDFLAGS) + +clean: + rm *.jpi Index: julius4/plugin/adin_oss.c diff -u /dev/null julius4/plugin/adin_oss.c:1.1 --- /dev/null Thu Sep 25 14:00:08 2008 +++ julius4/plugin/adin_oss.c Thu Sep 25 14:00:08 2008 @@ -0,0 +1,805 @@ +/** + * @file adin_oss.c + * + * + * @brief A reference sample of A/D-in plugin + * + * This file describes the specifications of plugin functions to be + * defined to make an A/D-in plugin. An A/D-in plugin will extend a + * new audio sream input into Julius by addin a new choice to the + * "-input" option. + * + * The recording format should be 16 bit (signed short), and sampling + * rate should be set to the given value at adin_standby(). + * + * + * + * + * @brief オーディオ入力プラグインのひな形 + * + * このファイルは,オーディオ入力プラグインを作成する際に定義すべきプ + * ラグイン関数について解説している.オーディオ入力プラグインは, + * Julius に新たな音声入力デバイスを追加する."-input" に新たな選択肢 + * が追加され,実行時に Julius に対してそれを指定することで,このプラ + * グイン経由で音声を取り込み認識することができる. + * + * オーディオ入力プラグインで取り込むべきデータのフォーマットは 16bit で + * あること.さらに,サンプリングレートを adin_standby() 呼び出し時に + * 与えられるレートに合わせること. + * + * + * + * Common functions that can be defined in any type of plugin: + * - get_plugin_info() + * - initialize() + * + * A/D-in plugin functions: + * + * Required: + * - adin_get_optname() + * - adin_get_configuration() + * - adin_standby() + * - adin_open() + * - adin_read() + * - adin_close() + * + * Optional: + * - adin_terminate() + * - adin_pause() + * - adin_resume() + * + * + * @author Akinobu Lee + * @date Thu Aug 7 14:28:37 2008 + * + * $Revision: 1.1 $ + * + */ + +/***************************************************************************/ + +#include +#include +#include +#include "plugin_defs.h" + +/** + * + * Description string of this plugin file. + * + * + * このプラグインファイルの説明文字列. + * + * + */ +#define PLUGIN_TITLE "A/D-in plugin for Julius" + +/** + * + * string to be specified at "-input" option at Julius to use this plugin + * as input module. + * + * + * このプラグインを使用して音声入力を行う際に,Juliusの "-input" オプション + * に与えるべき文字列. + * + * + */ +#define INPUT_OPT "myadin" + +/** + * + * @brief Initialization at loading time (optional) + * + * If defined, this will be called just before this plugin is loaded to Julius. + * if this returns -1, the whole functions in this file will not be loaded. + * + * This function is OPTIONAL. + * + * + * @brief 読み込み時の初期化(任意) + * + * 起動時,Julius がこのプラグインを読み込む際に最初に呼ばれる. + * -1 を返すと,このプラグイン全体が読み込まれなくなる. + * 実行可能性のチェックに使える. + * + * + * + * + * @return 0 on success, -1 on failure. + * + */ +int +initialize() +{ + return 0; +} + +/** + * + * @brief Get information of this plugin (required) + * + * This function should return informations of this plugin file. + * The required info will be specified by opcode: + * - 0: return description string of this file into buf + * + * This will be called just after Julius find this file and after + * initialize(). + * + * @param opcode [in] requested operation code + * @param buf [out] buffer to store the return string + * @param buflen [in] maximum length of buf + * + * @return 0 on success, -1 on failure. On failure, Julius will ignore this + * plugin. + * + * + * + * @brief プラグイン情報取得(必須) + * + * このプラグインに関する情報を返す.与えられた opcode によって動作する. + * - 0 の場合,このプラグインファイルの名称を与えられたバッファに格納する + * + * この関数は,Julius がこのプラグインを読み込んだ直後に呼ばれる. + * + * @param opcode [in] 要求動作コード (現在 0 のみ実装) + * @param buf [out] 値を格納するバッファ + * @param buflen [in] buf の最大長 + * + * @return エラー時 -1, 成功時 0 を返す.エラーとして -1 を返した場合, + * このプラグイン全体は読み込まれない. + * + * + */ +int +get_plugin_info(int opcode, char *buf, int buflen) +{ + switch(opcode) { + case 0: + /* plugin description string */ + strncpy(buf, PLUGIN_TITLE, buflen); + break; + } + + return 0; +} + +/************************************************************************/ +/************************************************************************/ +/* A/D-in plugin functions */ + +/** + * + * @brief Return option string to select at option. (required) + * + * This function should return option string which should be specified + * as an argument "-input" option, to be used on Julius. The returning + * string should not be the same with any existing value. + * + * This function will be called several times at option parsing at startup. + * + * @param buf [out] buffer to store the return string + * @param buflen [in] maximum length of buf + * + * + * @brief 音声入力選択用のオプション文字列を返す(必須) + * + * このプラグインを入力として選択する際に,"-input" オプションで指定す + * べき文字列を格納して返す.返す文字は,システムにすでにあるものや, + * 他のプラグインが使用しているものと同じでないこと. + * (もし同じだった場合システム側が優先される) + * + * この関数は,起動時のオプション解析時に何度か呼ばれる. + * + * @param buf [out] 値を格納して返すバッファ + * @param buflen [in] buf の最大長 + * + * + */ +void +adin_get_optname(char *buf, int buflen) +{ + strncpy(buf, INPUT_OPT, buflen); +} + +/** + * + * @brief Return decoder parameter values related to this adin plugin (required) + * + * This function should return configuration values about how to set up + * decoder to use this adin plugin. The return value is dependent on + * the given opcode, as described below: + * + * opcode = 0: return whether real-time processing of 1st pass + * should be enabled by default. + * + * if returns 0 (disabled) , Julius will do buffered input, spooling + * the incoming input till EOF or silence cut segmentation, extract + * feature vector, then recognize the whole. If returns 1 (enabled), + * on-the-fly decoding will be performed, reading input and decoding + * it concurrently. + * + * A real-time decoding uses some approximation on feature extraction + * related to sentence-based normalization i.e. CMN or energy normalization. + * This value is typically 0 on off-line recognition, and 1 for on-line + * recognition. + * + * This value is device-dependent default value, and can be overridden by + * user option "-realtime" and "-norealtime". + * + * opcode = 1: return whether silence cut segmentation should be + * enabled by default + * + * return 0 to disable, 1 to enable. + * + * On file input, you can choose whether silence detection and + * segmentation should be performed before recognition. On live input + * like microphone, where input stream is infinite, you would perfer + * choose 1 to enable it. + * + * This value is device-dependent default value, and can be overridden by + * user option "-cutsilence" and "-nocutsilence". + * + * opcode = 2: return whether input threading is necessary or not. + * + * On Unix, when set to 1, Julius forks a separate thread for A/D-in + * input. It can be useful when recognition is slow and some audio + * inputs are dropped. Note that this should be enabled only for + * infinite input like microphone or line input, since EOF handling on + * threaded mode is not supported yet. Recommended value is 1 for + * microphone input, 0 for file and network (tcp/ip) input. + * Ignored on Win32. + * + * @param opcode [in] requested operation code + * + * @return values required for the opcode as described. + * + * + * + * @brief 入力の扱いに関するパラメータ設定を返す(必須) + * + * Julius がこの入力プラグインをどう扱うべきかについて,設定パラメータを + * 返す.与えられた以下の opcode ごとに,値を返す. + * + * opcode = 0: リアルタイム認識を行うかどうかのデフォルト値 + * + * 1 を返すと,Julius は入力に対して特徴抽出と認識処理を平行して行う + * リアルタイム認識を行う.0 の場合,いったん入力を終端(あるいは区切り) + * まで受け取ってから,特徴抽出を行い,その後認識を開始する. + * リアルタイム処理では,CMN やエネルギー平均など,発話全体を用いた + * 特徴量の正規化が近似される. + * + * 通常,マイク入力などリアルタイムな結果が欲しい場合は 1, + * ファイル入力などオフライン認識の場合は 0 を返すことが多い. + * + * なお,ここの値は,この入力が規定するデフォルト値であり, + * Juliusの実行時オプション "-realtime", "-norealtime" でも変更できる. + * オプションが指定された場合はその指定が優先される. + * + * opcode = 1: 無音区間検出による入力区切りのデフォルト値 + * + * Julius は入力音声に対して振幅と零交差による入力判定を行い,振幅が一 + * 定レベル以下の部分をスキップし,そこで区切って入力とすることができ + * る.この無音での自動区切りのデフォルトを,返値 1 で有効, 0 で無効 + * とできる. + * + * 通常,マイクなどの直接入力では 1,1発話ごとの音声ファイルでは 0 を + * 返すことが多い. + * + * なお,ここの値は,この入力が規定するデフォルト値であり, + * Juliusの実行時オプション "-cutsilence", "-nocutsilence" でも変更できる. + * オプションが指定された場合はその指定が優先される. + * + * opcode = 2: 音声入力をスレッド化するかのデフォルト値 + * + * 音声入力取り込み部を別スレッドにするかどうかを選択する. + * 音声認識の速度が遅く,音声データの取りこぼしが発生する場合に有効である. + * ただし,現在のJuliusでは,EOF による認識終了を正しく扱えないので, + * マイク入力などの入力長が有限でない入力についてのみスレッド化を有効に + * すべきである. + * + * 通常,マイク UDP などでは 1 にし,ファイルや TCP/IP ソケットでは + * 0 にする. + * + * @param opcode [in] 要求動作コード (現在 0 のみ実装) + * + * @return opcode ごとに要求された値を返す. + * + */ +int +adin_get_configuration(int opcode) +{ + /* For your convenience, UNCOMMENT ONE OF THEM BELOW that match your needs */ + + /* typical values for live microphone/line input */ + switch(opcode) { + case 0: + return 1; + case 1: + return 1; + case 2: + return 1; + } + /* typical values for offline file input */ + /* + * switch(opcode) { + * case 0: + * return 0; + * case 1: + * return 0; + * case 2: + * return 0; + * } + */ + /* typical setting for tcpip input */ + /* assuming speech to be segmented at sender */ + /* + * switch(opcode) { + * case 0: + * return 1; + * case 1: + * return 0; + * case 2: + * return 0; + * } + */ + /* typical setting for tcpip input */ + /* assuming receiving continous speech stream and segmented + should be done at Julius side */ + /* + * switch(opcode) { + * case 0: + * return 1; + * case 1: + * return 1; + * case 2: + * return 0; + * } + */ +} + + +/************************************************************************/ + +#include +#include +#include +#include +static int audio_fd; +static int freq; + +/** + * + * @brief Initialize input device (required) + * + * This will be called only once at start up of Julius. You can + * initialize the device, check if the device exists or prepare a socket + * for connection. + * + * If this function returns FALSE, Julius will exit. + * + * JuliusLib: this function will be called at j_adin_init(). + * + * @param sfreq [in] required sampling frequency + * @param dummy [in] a dummy data + * + * @return TRUE on success, FALSE on failure. + * + * + * @brief デバイスを初期化する(必須) + * + * この関数は起動時に一回だけ呼ばれる.ここではデバイスのチェックや + * ソケットの用意といった,音声入力のための準備を行うのに使う. + * + * FALSE を返した場合,Julius は終了する. + * + * JuliusLib: この関数は j_adin_init() で呼ばれる. + * + * @param sfreq [in] サンプリングレート + * @param dummy [in] ダミーデータ(未使用) + * + * @return 成功時 TRUE,失敗時 FALSE を返す. + * + */ +boolean +adin_standby(int sfreq, void *dummy) +{ + /* store the frequency */ + freq = sfreq; + return TRUE; +} + +/** + * + * @brief Open an input stream (required) + * + * This function should open a new audio stream for input. + * You may open a capture device, open an audio file, or wait for + * connection with other network client at this function. + * + * If this function returns FALSE, Julius will exit recognition loop. + * + * JuliusLib: this will be called at j_open_stream(). + * + * @return TRUE on success, FALSE on failure. + * + * + * @brief 入力音声ストリームを開く(必須) + * + * 入力音声ストリームを新規に開く.通常,デバイスやファイルのオープン, + * ネットワーククライアントからの接続などをここで行う. + * + * FALSE を返したとき,Julius は認識ループを抜ける. + * + * JuliusLib: この関数は j_open_stream() 内で呼ばれる. + * + * @return 成功時 TRUE,失敗時 FALSE を返す. + * + */ +boolean +adin_open() +{ + /* do open the device */ + int fmt; + int stereo; + int ret; + int s; + char buf[2]; + + if ((audio_fd = open("/dev/dsp", O_RDONLY)) == -1) { + printf("Error: cannot open /dev/dsp\n"); + return FALSE; + } + fmt = AFMT_S16_LE; /* 16bit signed (little endian) */ + if (ioctl(audio_fd, SNDCTL_DSP_SETFMT, &fmt) == -1) { + printf("Error: failed set format to 16bit signed\n"); + return FALSE; + } + stereo = 0; /* mono */ + ret = ioctl(audio_fd, SNDCTL_DSP_STEREO, &stereo); + if (ret == -1 || stereo != 0) { + stereo = 1; + ret = ioctl(audio_fd, SNDCTL_DSP_CHANNELS, &stereo); + if (ret == -1 || stereo != 1) { + printf("Error: failed to set monoral channel\n"); + return FALSE; + } + } + s = freq; + if (ioctl(audio_fd, SNDCTL_DSP_SPEED, &s) == -1) { + printf("Erorr: failed to set sample rate to %dHz\n", freq); + return FALSE; + } + + /* start recording... */ + read(audio_fd, buf, 2); + + return(TRUE); +} + +/** + * + * @brief Read samples from device (required) + * + * This function is for reading samples to be recognized from input stream. + * This will be called repeatedly at each time the read samples are fully + * processed. + * + * The sampling format should be 16bit, 1 channel. + * + * @a sampnum is the maximum number of samples that can be read into @a buf. + * The actual number of read samples should be returned. + * + * Impotant notes about I/O blocking: + * - Do not wait until all the @a sampnum samples are read. + * Blocking inside this function will block the whole recognition process. + * If device allows, it is better to read only the available data + * in the stream and return immediately. + * - Avoid returning value of 0 when no data is available, wait for some + * data to come inside this function. When you are using non-blocking + * operation, you may want to return 0 when no data is available. + * However, returning 0 will cause Julius to call again this function + * immediately, and cause busy loop to make CPU load to reach 100%. + * + * So the ideal operation will be first wait_for_some_data_to_come, and + * if any data becomes available, read them at most @a sampnum samples + * and return the number of read samples. + * + * Positive return value should be the number of read samples, or one + * of ADIN_EOF, ADIN_SEGMENT or ADIN_ERROR. Return value of ADIN_EOF + * tells end of stream, which causes Julius to finish current + * recognition and close stream. ADIN_SEGMENT requests Julius to + * segment the current input. The current recognition will be stopped + * at this point, recognition result will be output, and then Julius + * continues to the next input. The behavior of ADIN_SEGMENT is + * similar to ADIN_EOF except that ADIN_SEGMENT does not close/open + * stream, but just stop and restart the recognition. At last, return + * value should be ADIN_ERROR on error, in which Julius exits itself + * immediately. + * + * @param buf [out] output buffer to store samples obtained. + * @param sampnum [in] maximum number of samples that can be stored in @a buf. + * + * @return actural number of read samples, ADIN_EOF on end of stream, + * ADIN_SEGMENT to request segmentation to Julius, or ADIN_ERROR on error. + * + * + * @brief デバイスからサンプルを読み込む(必須) + * + * この関数は入力ストリームから音声サンプルを読み込む. + * + * バッファに格納して返す音声データの形式は 16bit, 1 チャンネルであること. + * + * @a sampnum は @a buf に格納することのできる最大のサンプル数である. + * 返り値として,実際に読み込まれたサンプル数,あるいは以下で説明する + * エラーコードを返す. + * + * この関数は認識中に何度も呼ばれ,ここで読まれたデータが Julius によっ + * て 認識処理される.読み込んだ分の処理が終了すると,次の入力を読み込 + * むためにこの関数が再度呼ばれる. + * + * この関数内での I/O blocking については以下の注意が必要である: + * + * - 長時間のブロックは避けること(@a sampnum は要求サンプル数ではな + * く@a buf に格納可能な最大数である).この関数内でブロックすると認 + * 識処理全体がブロックする.読み込みが長時間ブロックしないよう,数百 + * サンプル程度だけ読み込んで返すか,あるいは最初にバッファ内にあるブ + * ロックせずに読み込み可能なデータサンプル数を取得し,その分だけ読み + * 込むようにするのがよい. + * + * - non-blocking モードを用いる場合, 0 を返さないこと. + * バッファにデータが存在しないとき,0 を返すと Julius はサンプル + * 無しのためまた即座にこの関数を呼び出す.これがビジーウェイトを + * 発生させ,CPUロードがあがってしまう.バッファにデータが無いとき, + * 即座に 0 を返さず,数十msec でよいのでこの関数内で待つ + * ことが望ましい. + * + * 返り値は,実際に読み込んだサンプル数を正の値として返すか,あるいは + * ADIN_EOF, ADIN_SEGMENT, ADIN_ERROR のどれかを返す.ADIN_EOF はスト + * リームが終端まで達したことを表す,これを返すと,Julius は現在の認識 + * 処理を終了させ,ストリームを閉じる.ADIN_ERROR はこの関数内で深刻な + * エラーが生じた場合に返す.これが返された場合,Julius はその場で異常 + * 終了する. + * + * ADIN_SEGMENT を返すことで,Julius に現在の認識を現時点で区切ること + * を要求することができる.現在の認識処理はこの時点でいったん区切られ, + * そこまでの認識結果が確定・出力されたあと,次の認識処理が始まりこの + * 関数が呼ばれる.ADIN_SEGMENT は ADIN_EOF と動作が似ているが, + * ADIN_EOF が adin_close(), adin_open() を呼んでストリームを終了させ + * るのに対して,ADIN_SEGMENT はこれらを呼ばずに入力を続行する.この機 + * 能は,たとえばネットワーク経由で音声データを受信しているときに,送 + * 信側から音声認識のON/OFFやVADをコントロールしたい場合などに + * 使うことができる. + * + * @param buf [out] 得られたサンプルを格納するバッファ + * @param sampnum [in] @a buf 内に格納できる最大サンプル数 + * + * @return 実際に読み込まれたサンプル数,あるいは end of stream 時に ADIN_EOF, + * Julius に区切り要求を出すときには ADIN_SEGMENT, エラー時はADIN_ERROR を + * 返す. + * + */ +int +adin_read(SP16 *buf, int sampnum) +{ + audio_buf_info info; + int size, cnt; + + /* get sample num that can be read without blocking */ + if (ioctl(audio_fd, SNDCTL_DSP_GETISPACE, &info) == -1) { + printf("Error: adin_oss: failed to get number of samples in the buffer\n"); + return(ADIN_ERROR); + } + /* get them as much as possible */ + size = sampnum * sizeof(SP16); + if (size > info.bytes) size = info.bytes; + size &= ~ 1; /* Force 16bit alignment */ + cnt = read(audio_fd, buf, size); + if ( cnt < 0 ) { + printf("Error: adin_oss: failed to read samples\n"); + return (ADIN_ERROR); + } + cnt /= sizeof(short); + + return(cnt); +} + +/** + * + * @brief Close the current input stream (required) + * + * This function will be called when the input stream has reached + * end of file (i.e. the last call of adin_read() returns ADIN_EOF) + * + * You may close a capture device, close an audio file, or + * disconnect network client. + * + * If this function returns TRUE, Julius will go again to adin_open() + * to open another stream. If returns FALSE, Julius will exit + * the recognition loop. + * + * JuliusLib: This will be called at the end of j_recognize_stream(). + * + * @return TRUE on success, FALSE on failure. + * + * + * @brief 入力ストリームを閉じる(必須) + * + * 現在のストリームを閉じる.この関数は,入力ストリームが終端(EOF) + * に達したとき(すなわち adin_read() が ADIN_EOF を返したとき)に + * 呼ばれる.デバイスを閉じる,ファイルを閉じる,あるいはネットワーク接続を + * 切断するのに使うことができる. + * + * 正常終了としてTRUEを返したとき,Julius は adin_open() に戻って + * 他のストリームを開こうとする. FALSE を返したときは,Julius は + * 認識ループを抜ける. + * + * JuliusLib: この関数は j_recognize_stream() の最後で呼ばれる. + * + * @return 成功時 TRUE,失敗時 FALSE を返す. + * + */ +boolean +adin_close() +{ + close(audio_fd); + return TRUE; +} + +/************************************************************************/ + +/** + * + * @brief A hook for Termination request (optional) + * + * This function will be called when Julius receives a Termination + * request to stop running. This can be used to synchronize input + * facility with Julius's running status. + * + * Termination will occur when Julius is running on module mode and + * received TERMINATE command from client, or j_request_terminate() + * is called inside application. On termination, Julius will stop + * recognition immediately (discard current input if in process), + * and wait until received RESUME command or call of j_request_resume(). + * + * This hook function will be called just after a Termination request. + * Please note that this will be called when Julius receives request, + * not on actual termination. + * + * @return TRUE on success, FALSE on failure. + * + * + * @brief 中断要求用フック(任意) + * + * この関数を定義すると,Julius は中断要求を受け取った際にこの関数を呼び出す. + * これを使って,Julius の中断・再開と同期した入力同期処理を実装することが + * できる.(例:入力送信元に対して送信中断要求を出すなど) + * + * 中断要求は,Julius がアプリケーションやクライアントより受け取る + * 認識中断の要求である.具体的には,Julius がモジュールモードで動作して + * いる時に TERMINATE コマンドをクライアントから受け取ったときや, + * JuliusLibを組み込んだアプリケーションが j_request_terminate() を + * 呼んだときに発生する. + * + * 中断要求を受け取ると,Julius は現在の認識処理を中断する. + * 認識途中であった場合,その入力を破棄して即時中断する. + * 処理の再開は,RESUME コマンドか j_request_resume() の呼び出しで行われる. + * + * この関数は中断要求を Julius が受け取った時点で呼ばれる. + * 実際に処理が中断した後で呼ばれるのではないことに注意されたい. + * + * @return 成功時 TRUE, エラー時 FALSE を返す. + * + * + */ +boolean +adin_terminate() +{ + printf("terminate request\n"); + return TRUE; +} + +/** + * + * @brief A hook for Pause request (optional) + * + * This function will be called when Julius receives a Pause request + * to stop running. This can be used to synchronize input facility + * with Julius's running status. + * + * Pause will occur when Julius is running on module mode and + * received PAUSE command from client, or j_request_pause() + * is called inside application. On pausing, Julius will + * stop recognition and then wait until it receives RESUME command + * or j_request_resume() is called. When pausing occurs while recognition is + * running, Julius will process it to the end before stops. + * + * This hook function will be called just after a Pause request. + * Please note that this will be called when Julius receives request, + * not on actual pause. + * + * @return TRUE on success, FALSE on failure. + * + * + * @brief 停止要求用フック(任意) + * + * この関数を定義すると,Julius は停止要求を受け取った際にこの関数を呼び出す. + * これを使って,Julius の中断・再開と同期した入力同期処理を実装することが + * できる.(例:入力送信元に対して送信中断要求を出すなど) + * + * 停止要求は,Julius がアプリケーションやクライアントより受け取る, + * 認識の一時停止の要求である.具体的には,Julius がモジュールモードで動作して + * いる時に PAUSE コマンドをクライアントから受け取ったときや, + * JuliusLibを組み込んだアプリケーションが j_request_pause() を + * 呼んだときに発生する. + * + * 停止要求を受け取ると,Julius は現在の認識処理を中断する. + * 認識途中であった場合,その認識が終わるまで待ってから中断する. + * 処理の再開は,RESUME コマンドか j_request_resume() の呼び出しで行われる. + * + * 中断要求 (adin_terminate) との違いは,認識途中に要求を受けたときの動作が + * 異なる.中断要求では強制中断するが,停止要求ではその認識が終わるまで + * 待ってから停止する. + * + * この関数は停止要求を Julius が受け取った時点で呼ばれる. + * 実際に処理が停止した後で呼ばれるのではないことに注意されたい. + * + * @return 成功時 TRUE, エラー時 FALSE を返す. + * + * + */ +boolean +adin_pause() +{ + printf("pause request\n"); + return TRUE; +} + +/** + * + * @brief A hook for Resume request (optional) + * + * This function will be called when Julius received a resume request + * to recover from pause/termination status. + * + * Resume will occur when Julius has been stopped by receiving RESUME + * command from client on module mode, or j_request_resume() is called + * inside application. + * + * This hook function will be called just after a resume request. + * This can be used to make this A/D-in plugin cooperate with the + * pause/resume status, for example to tell audio client to restart + * audio streaming. + * + * This function is totally optional. + * + * @return TRUE on success, FALSE on failure. + * + * + * @brief 認識再開要求用フック(任意) + * + * この関数を定義すると,Julius は停止状態からの認識再開要求の際に + * この関数を呼び出す. + * + * 認識再開要求は,Julius がモジュールモードで動作して RESUME コマンドを + * クライアントから受け取ったときや,JuliusLibを組み込んだアプリケーション + * が j_request_resume() を呼んだときに発生する.この再開要求が発生 + * すると,Julius は停止していた認識を再開する. + * + * 注意:この関数は,実際に停止したときに呼ばれるのではなく,Julius が + * 要求を受け取った時点で,そのたびに呼ばれる.複数回呼ばれることや, + * すでに動作中である場合にさらにこのコマンドを受け取ったときにも呼ば + * れることがあることに注意されたい. + * + * @return 成功時 TRUE, エラー時 FALSE を返す. + * + * + */ +boolean +adin_resume() +{ + printf("resume request\n"); + return TRUE; +} + +/* end of file */ Index: julius4/plugin/audio_postprocess.c diff -u /dev/null julius4/plugin/audio_postprocess.c:1.1 --- /dev/null Thu Sep 25 14:00:08 2008 +++ julius4/plugin/audio_postprocess.c Thu Sep 25 14:00:08 2008 @@ -0,0 +1,167 @@ +/** + * @file audio_postprocess.c + * + * + * @brief A sample audio postprocessing plugin + * + * + * + * @brief オーディオ入力の後処理プラグインのサンプル + * + * + * @author Akinobu Lee + * @date Sun Aug 10 15:12:50 2008 + * + * $Revision: 1.1 $ + * + */ + +/** + * Required for a file + * - get_plugin_info() + * + * Optional for a file + * - initialize() + * + */ +/** + * A/D-in postprocessing functions + * + * Required: + * - adin_postprocess() + * + */ + +/***************************************************************************/ + +#include +#include +#include "plugin_defs.h" + +#define PLUGIN_TITLE "audio postprocess plugin for Julius" + +/** + * + * @brief Initialization at loading time (optional) + * + * If defined, this will be called just before this plugin is loaded to Julius. + * if this returns -1, the whole functions in this file will not be loaded. + * + * This function is OPTIONAL. + * + * + * @brief 読み込み時の初期化(任意) + * + * 起動時,Julius がこのプラグインを読み込む際に最初に呼ばれる. + * -1 を返すと,このプラグイン全体が読み込まれなくなる. + * 実行可能性のチェックに使える. + * + * + * + * + * @return 0 on success, -1 on failure. + * + */ +int +initialize() +{ + return 0; +} + +/** + * + * @brief Get information of this plugin (required) + * + * This function should return informations of this plugin file. + * The required info will be specified by opcode: + * - 0: return description string of this file into buf + * + * This will be called just after Julius find this file and after + * initialize(). + * + * @param opcode [in] requested operation code + * @param buf [out] buffer to store the return string + * @param buflen [in] maximum length of buf + * + * @return 0 on success, -1 on failure. On failure, Julius will ignore this + * plugin. + * + * + * + * @brief プラグイン情報取得(必須) + * + * このプラグインに関する情報を返す.与えられた opcode によって動作する. + * - 0 の場合,このプラグインファイルの名称を与えられたバッファに格納する + * + * この関数は,Julius がこのプラグインを読み込んだ直後に呼ばれる. + * + * @param opcode [in] 要求動作コード (現在 0 のみ実装) + * @param buf [out] 値を格納するバッファ + * @param buflen [in] buf の最大長 + * + * @return エラー時 -1, 成功時 0 を返す.エラーとして -1 を返した場合, + * このプラグイン全体は読み込まれない. + * + * + */ +int +get_plugin_info(int opcode, char *buf, int buflen) +{ + switch(opcode) { + case 0: + /* plugin description string */ + strncpy(buf, PLUGIN_TITLE, buflen); + break; + } + + return 0; +} + +/** + * + * @brief Post-processing function for captured audio + * + * When defined, this function will be called at every audio input + * fragments before any feature analysis. @a buf contains the small + * fragment of captured audio input at a length of @a len, and this + * will be called successively as input goes. + * + * You can monitor the incoming audio stream, and also can modify or + * overwrite the content of @a buf to do some audio processing for the + * incoming data like noise supression etc. + * + * If multiple plugins have this functions, they are all executed in order + * of loading. + * + * @param buf [i/o] a fragment of audio inputs + * @param len [in] length of @a buf (in samples) + * + * + * + * @brief 音声入力に対する後処理 + * + * この関数が定義された場合,Julius は入力された音声データに対して,特 + * 徴量抽出を行う前にこの関数を呼び出す.@a buf には @a len の長さの音 + * 声入力データ断片が入っている.この関数は,入力が進むたびにその短い + * 断片ごとに繰り返し呼ばれる. + * + * この関数を使って入力音声データをモニタできるほかに,バッファ上の + * データを直接書き換えることもできる.音声認識はこの関数が終わったあとの + * データに対して行われるので,例えば雑音抑圧処理などをここで行う + * ことも可能である. + * + * 複数のプラグインでこの関数が指定されている場合,それらは読み込み順に + * 実行される. + * + * @param buf [i/o] 音声入力データ断片の入ったバッファ + * @param len [in] @a buf の長さ(サンプル数) + * + * + * + */ +void +adin_postprocess(SP16 *buf, int len) +{ + //printf("%d\n", len); +} +/* end of file */ Index: julius4/plugin/calcmix.c diff -u /dev/null julius4/plugin/calcmix.c:1.1 --- /dev/null Thu Sep 25 14:00:08 2008 +++ julius4/plugin/calcmix.c Thu Sep 25 14:00:08 2008 @@ -0,0 +1,325 @@ +/** + * @file calcmix.c + * + * + * @brief A sample plugin for calculating Gaussians + * + * This sample uses Julius libraries. + * + * + * + * @brief ガウス分布計算プラグインのサンプル + * + * このサンプルは julius のライブラリを使用します. + * + * + * @author Akinobu Lee + * @date Mon Aug 11 15:29:45 2008 + * + * $Revision: 1.1 $ + * + */ +/** + * Required for a file + * - get_plugin_info() + * + * Optional for a file + * - initialize() + * + */ +/** + * Gaussian mixture calculation plugin: + * + * Required: + * - calcmix_get_optname() + * - calcmix() + * - calcmix_init() + * - calcmix_free() + * + */ + +/***************************************************************************/ + +/* we refer to Julius libsent header */ +#include +#include + +//#include "plugin_defs.h" + +#define PLUGIN_TITLE "Gaussian calculation plugin for Julius" +#define GPRUNE_OPT "mycalc" + +/** + * + * @brief Initialization at loading time (optional) + * + * If defined, this will be called just before this plugin is loaded to Julius. + * if this returns -1, the whole functions in this file will not be loaded. + * + * This function is OPTIONAL. + * + * + * @brief 読み込み時の初期化(任意) + * + * 起動時,Julius がこのプラグインを読み込む際に最初に呼ばれる. + * -1 を返すと,このプラグイン全体が読み込まれなくなる. + * 実行可能性のチェックに使える. + * + * + * + * + * @return 0 on success, -1 on failure. + * + */ +int +initialize() +{ + return 0; +} + +/** + * + * @brief Get information of this plugin (required) + * + * This function should return informations of this plugin file. + * The required info will be specified by opcode: + * - 0: return description string of this file into buf + * + * This will be called just after Julius find this file and after + * initialize(). + * + * @param opcode [in] requested operation code + * @param buf [out] buffer to store the return string + * @param buflen [in] maximum length of buf + * + * @return 0 on success, -1 on failure. On failure, Julius will ignore this + * plugin. + * + * + * + * @brief プラグイン情報取得(必須) + * + * このプラグインに関する情報を返す.与えられた opcode によって動作する. + * - 0 の場合,このプラグインファイルの名称を与えられたバッファに格納する + * + * この関数は,Julius がこのプラグインを読み込んだ直後に呼ばれる. + * + * @param opcode [in] 要求動作コード (現在 0 のみ実装) + * @param buf [out] 値を格納するバッファ + * @param buflen [in] buf の最大長 + * + * @return エラー時 -1, 成功時 0 を返す.エラーとして -1 を返した場合, + * このプラグイン全体は読み込まれない. + * + * + */ +int +get_plugin_info(int opcode, char *buf, int buflen) +{ + switch(opcode) { + case 0: + /* plugin description string */ + strncpy(buf, PLUGIN_TITLE, buflen); + break; + } + + return 0; +} + +/************************************************************************/ +/************************************************************************/ + +/** + * + * @brief Return option string to select at option. (required) + * + * This function should return option string which should be specified + * as an argument "-gprune" option, to be used on Julius. The returning + * string should not be the same with any existing value. + * + * This function will be called several times at option parsing at startup. + * + * @param buf [out] buffer to store the return string + * @param buflen [in] maximum length of buf + * + * + * @brief 計算方法選択用オプションのための文字列を返す(必須) + * + * Julius で起動時に "-gprune ここで返す値" と指定するとこのプラグイン + * が使用される.この関数では,上記の "-gprune" に与えるべき文字列を格 + * 納して返す.返す文字は,システムの "-gprune" オプションにすでにある + * ものや,他のプラグインが使用しているものと同じでないこと.(もし同 + * じだった場合システム側が優先される) + * + * この関数は,起動時のオプション解析時に何度か呼ばれる. + * + * @param buf [out] 値を格納して返すバッファ + * @param buflen [in] buf の最大長 + * + * + */ +void +calcmix_get_optname(char *buf, int buflen) +{ + strncpy(buf, GPRUNE_OPT, buflen); +} + +/** + * + * @brief A basic implementaion of computing Gaussians + * + * This function should compute output probabilities for each + * Gaussians. after this function returns, Julius will do addlog to + * get the final output log probability. + * + * The input vector to be computed is located at wrk->OP_vec[], at a + * length of wrk->OP_veclen. Gaussians are given by g[], at a number + * of num. last_id and lnum is for internal use for pruning, just ignore + * them. + * + * The scores for each Gaussians computed in this function should be + * stored in OP_calced_score[], with their corresponding Gaussian ids + * to OP_calced_id. The total number of calculated mixtures shuold + * also stored in OP_calced_num. + * + * @param wrk [i/o] HMM computation work area to store data + * @param g [in] set of Gaussian densities to compute the output probability. + * @param num [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 + * + * + * @brief ガウス分布計算関数 + * + * この関数では,与えられた複数のガウス分布に対して入力ベクトルの + * 出力確率を求める.この関数が行うのは,複数のガウス分布それぞれの + * 出力確率の算出と格納のみであり,混合分布としての重み計算や addlog + * はこの関数が返ったあとに Julius 側で行われる. + * + * 入力ベクトルは wrk->OP_vec[] に格納されており,長さは wrk->OP_veclen + * である.ガウス分布定義は g[] に配列として複数渡され,その数は num である. + * + * なお,last_id と lnum はこのガウス分布集合 g[] において直前の入力フ + * レームで計算されたものの id が入っている.Julius の内部処理用なので, + * 使わなくても差し支えない. + * + * 各ガウス分布に対する入力ベクトルの対数出力確率は,そのガウス分布の + * ID (0 から始まる配列の添え字) を wrk->OP_calced_id に,値を + * wrk->OP_calced_score に格納すること.また,実際に計算された + * ガウス分布の数を wrk->OP_calced_num に格納すること. + * (これは Gaussian pruning を想定した実装である) + * + * 以下は,pruning 等を行わない単純な出力確率計算を実装したものである. + * ガウス分布は対角共分散を仮定している.なお Julius では読み込み時に + * HTK でいうところの gconst 値はあらかじめ計算される.このため,計算時に + * 下記の dens->gconst のように利用できる. + * + * @param wrk [i/o] HMM計算用ワークエリア + * @param g [in] 出力確率を計算するガウス分布の列 + * @param num [in] @a g のガウス分布の数 + * @param last_id [in] 直前入力フレームで上位だったガウス分布のIDリスト, + * または内場合は NULL + * @param lnum [in] @a last_id の長さ + * + */ +void +calcmix(HMMWork *wrk, HTK_HMM_Dens **g, int num, int *last_id, int lnum) +{ + int i; + HTK_HMM_Dens *dens; + LOGPROB *prob = wrk->OP_calced_score; + int *id = wrk->OP_calced_id; + VECT tmp, x; + VECT *mean; + VECT *var; + VECT *vec; + short veclen; + + for(i=0; imean; + var = dens->var->vec; + tmp = dens->gconst; + vec = wrk->OP_vec; + veclen = wrk->OP_veclen; + for (; veclen > 0; veclen--) { + x = *(vec++) - *(mean++); + tmp += x * x * *(var++); + } + tmp *= -0.5; + /* store it */ + *(prob++) = tmp; + } + wrk->OP_calced_num = num; +} + +/** + * + * Free work area. + * You should free all allocated at clacmix_init(). + * + * @param wrk [i/o] HMM computation work area + * + * + * calcmix_init() で確保されたワークエリアを開放する. + * + * @param wrk [i/o] HMM 計算用ワークエリア + * + * + */ +void +calcmix_free(HMMWork *wrk) +{ + free(wrk->OP_calced_score); + free(wrk->OP_calced_id); +} + +/** + * + * @brief Initialize and setup work area for Gaussian computation. + * + * You should set value for OP_calced_maxnum, and allocate OP_calced_score + * and OP_calced_id. Remaining the content below is safe. + * + * This will be called once on instance initialization at startup. + * + * @param wrk [i/o] HMM computation work area + * + * @return TRUE on success, FALSE on failure. + * + * + * @brief 計算用のワークエリアを確保する. + * + * ガウス分布計算用のワークエリアを確保する.下記にすでに書いてある分は, + * そのまま Julius の内部でも使用しているので,削らないこと. + * + * この関数は最初に音響尤度計算インスタンスが作成されるときに呼び出される. + * + * @param wrk [i/o] HMM 計算用ワークエリア + * + * @return 成功時 TRUE,失敗時 FALSE を返す. + * + */ +boolean +calcmix_init(HMMWork *wrk) +{ + /* maximum Gaussian set size = maximum mixture size * nstream */ + wrk->OP_calced_maxnum = wrk->OP_hmminfo->maxmixturenum * wrk->OP_nstream; + wrk->OP_calced_score = (LOGPROB *)malloc(sizeof(LOGPROB) * wrk->OP_calced_maxnum); + wrk->OP_calced_id = (int *)malloc(sizeof(int) * wrk->OP_calced_maxnum); + /* force gprune_num to the max number */ + wrk->OP_gprune_num = wrk->OP_calced_maxnum; + return TRUE; +} + +/* end of file */ Index: julius4/plugin/feature_postprocess.c diff -u /dev/null julius4/plugin/feature_postprocess.c:1.1 --- /dev/null Thu Sep 25 14:00:08 2008 +++ julius4/plugin/feature_postprocess.c Thu Sep 25 14:00:08 2008 @@ -0,0 +1,173 @@ +/** + * @file feature_postprocess.c + * + * + * @brief A sample plugin for feature vector postprocessing + * + * + * + * @brief 特徴量の後処理プラグインのサンプル + * + * + * @author Akinobu Lee + * @date Sun Aug 10 15:14:19 2008 + * + * $Revision: 1.1 $ + * + */ + +/** + * Required for a file + * - get_plugin_info() + * + * Optional for a file + * - initialize() + * + */ +/** + * Feature vector input postprocessing functions + * + * Required: + * - fvin_postprocess() + * + */ + +/***************************************************************************/ + +#include +#include +#include "plugin_defs.h" + +#define PLUGIN_TITLE "feature vector postprocess plugin for Julius" + +/** + * + * @brief Initialization at loading time (optional) + * + * If defined, this will be called just before this plugin is loaded to Julius. + * if this returns -1, the whole functions in this file will not be loaded. + * + * This function is OPTIONAL. + * + * + * @brief 読み込み時の初期化(任意) + * + * 起動時,Julius がこのプラグインを読み込む際に最初に呼ばれる. + * -1 を返すと,このプラグイン全体が読み込まれなくなる. + * 実行可能性のチェックに使える. + * + * + * + * + * @return 0 on success, -1 on failure. + * + */ +int +initialize() +{ + return 0; +} + +/** + * + * @brief Get information of this plugin (required) + * + * This function should return informations of this plugin file. + * The required info will be specified by opcode: + * - 0: return description string of this file into buf + * + * This will be called just after Julius find this file and after + * initialize(). + * + * @param opcode [in] requested operation code + * @param buf [out] buffer to store the return string + * @param buflen [in] maximum length of buf + * + * @return 0 on success, -1 on failure. On failure, Julius will ignore this + * plugin. + * + * + * + * @brief プラグイン情報取得(必須) + * + * このプラグインに関する情報を返す.与えられた opcode によって動作する. + * - 0 の場合,このプラグインファイルの名称を与えられたバッファに格納する + * + * この関数は,Julius がこのプラグインを読み込んだ直後に呼ばれる. + * + * @param opcode [in] 要求動作コード (現在 0 のみ実装) + * @param buf [out] 値を格納するバッファ + * @param buflen [in] buf の最大長 + * + * @return エラー時 -1, 成功時 0 を返す.エラーとして -1 を返した場合, + * このプラグイン全体は読み込まれない. + * + * + */ +int +get_plugin_info(int opcode, char *buf, int buflen) +{ + switch(opcode) { + case 0: + /* plugin description string */ + strncpy(buf, PLUGIN_TITLE, buflen); + break; + } + + return 0; +} + +/** + * + * @brief Post-processing function for a feature vector + * + * When defined, this function will be called at every input vector + * before recognition. This will be called successively for every input + * at each frame. + * + * You can monitor the feature vector to be recognized, and also can + * modify or overwrite the content to do some transformation like a + * feature-space adaptation. + * + * If multiple plugins have this functions, they are all executed in order + * of loading. + * + * @param vecbuf [i/o] a feature vector + * @param veclen [in] length of @a vecbuf + * @param nframe [in] frame number in a recognition, staring with 0. + * + * + * + * @brief 特徴量ベクトルに対する後処理関数 + * + * この関数が定義された場合,Julius は個々の特徴量ベクトルについて, + * 認識が行われる前にこの関数を呼び出す.この関数は,入力が進むたびに + * その各フレームの特徴量ベクトルについて呼ばれる. + * + * この関数を使って入力の特徴量ベクトルをモニタできるほか,バッファ上の + * データを直接書き換えることもできる.音声認識はこの関数が終わったあとの + * データに対して行われるので,例えば話者適応や話者正規化のような処理を + * ここで行うことも可能である. + * + * 複数のプラグインでこの関数が指定されている場合,それらは読み込み順に + * 実行される. + * + * @param vecbuf [i/o] 特徴量ベクトル + * @param veclen [in] @a vecbuf の長さ + * @param nframe [in] フレーム番号 + * + * + * + */ +void +fvin_postprocess(float *vecbuf, int veclen, int nframe) +{ + int i; + /* just output the vectors to stdout */ + printf("%d:", nframe); + for(i=0;i + * @brief A skeleton code of feature input plugin + * + * + * + * @brief 特徴量入力プラグインのひな形 + * + * + * @author Akinobu Lee + * @date Mon Aug 11 17:05:17 2008 + * + * $Revision: 1.1 $ + * + */ + +/** + * Required for a file + * - get_plugin_info() + * + * Optional for a file + * - initialize() + * + */ + +/** + * feature input plugin functions + * + * Required: + * - fvin_get_optname() + * - fvin_get_configuration() + * - fvin_standby() + * - fvin_open() + * - fvin_read() + * - fvin_close() + * + * Optional: + * - fvin_terminate() + * - fvin_pause() + * - fvin_resume() + * + */ + +#include +#include +#include "plugin_defs.h" + +#define PLUGIN_TITLE "Feature vector input plugin for Julius" +#define INPUT_OPT "myfvin" + +/************************************************************************/ + +/** + * + * @brief Initialization at loading time (optional) + * + * If defined, this will be called just before this plugin is loaded to Julius. + * if this returns -1, the whole functions in this file will not be loaded. + * + * This function is OPTIONAL. + * + * + * @brief 読み込み時の初期化(任意) + * + * 起動時,Julius がこのプラグインを読み込む際に最初に呼ばれる. + * -1 を返すと,このプラグイン全体が読み込まれなくなる. + * 実行可能性のチェックに使える. + * + * + * + * + * @return 0 on success, -1 on failure. + * + */ +int +initialize() +{ + return 0; +} + +/** + * + * @brief Get information of this plugin (required) + * + * This function should return informations of this plugin file. + * The required info will be specified by opcode: + * - 0: return description string of this file into buf + * + * This will be called just after Julius find this file and after + * initialize(). + * + * @param opcode [in] requested operation code + * @param buf [out] buffer to store the return string + * @param buflen [in] maximum length of buf + * + * @return 0 on success, -1 on failure. On failure, Julius will ignore this + * plugin. + * + * + * + * @brief プラグイン情報取得(必須) + * + * このプラグインに関する情報を返す.与えられた opcode によって動作する. + * - 0 の場合,このプラグインファイルの名称を与えられたバッファに格納する + * + * この関数は,Julius がこのプラグインを読み込んだ直後に呼ばれる. + * + * @param opcode [in] 要求動作コード (現在 0 のみ実装) + * @param buf [out] 値を格納するバッファ + * @param buflen [in] buf の最大長 + * + * @return エラー時 -1, 成功時 0 を返す.エラーとして -1 を返した場合, + * このプラグイン全体は読み込まれない. + * + * + */ +int +get_plugin_info(int opcode, char *buf, int buflen) +{ + switch(opcode) { + case 0: + /* plugin description string */ + strncpy(buf, PLUGIN_TITLE, buflen); + break; + } + + return 0; +} + +/************************************************************************/ +/************************************************************************/ +/* Feature-vector input plugin functions */ + +/** + * + * @brief Return option string to select this input at option. (required) + * + * This function should return option string which should be specified + * as an argument "-input" option, to be used on Julius. The returning + * string should not be the same with any existing value. + * + * This function will be called several times at option parsing at startup. + * + * @param buf [out] buffer to store the return string + * @param buflen [in] maximum length of buf + * + * + * @brief 入力選択用のオプション文字列を返す(必須) + * + * このプラグインを入力として選択する際に,"-input" オプションで指定す + * べき文字列を格納して返す.返す文字は,システムにすでにあるものや, + * 他のプラグインが使用しているものと同じでないこと. + * (もし同じだった場合システム側が優先される) + * + * この関数は,起動時のオプション解析時に何度か呼ばれる. + * + * @param buf [out] 値を格納して返すバッファ + * @param buflen [in] buf の最大長 + * + * + */ +void +fvin_get_optname(char *buf, int buflen) +{ + strncpy(buf, INPUT_OPT, buflen); +} + +/** + * + * @brief Return configuration parameters for this input (required) + * + * This function should return configuration parameters about the input. + * + * When opcode = 0, return the dimension (length) of input vector. + * + * When opcode = 1, return the frame interval (time between frames) in + * milliseconds. + * + * When opcode = 2, parameter type code can be returned. The code should + * the same format as used in HTK parameter file header. This is for + * checking the input parameter type against acousitc model, and + * you can disable the checking by returning "0xffff" to this opcode. + * + * @param opcode [in] requested operation code + * + * @return values required for the opcode as described. + * + * + * + * @brief 特徴量のパラメータを返す(必須) + * + * この入力プラグインがJuliusに渡す特徴量に関するパラメータを返す. + * 与えられた以下の opcode ごとに,値を返す. + * + * opcode = 0: ベクトルの次元数 + * opcode = 1: 1フレームあたりの時間幅(単位:ミリ秒) + * opcode = 2: パラメータの型 + * + * opcode = 2 のパラメータの型は,音響モデルの特徴量との型整合性 + * チェックに使われる.値は,HTK の特徴量ファイルのヘッダ形式で + * エンコードされた値を返す.型チェックを行わない場合は, + * 0xffff を返すこと. + * + * @param opcode [in] 要求動作コード (現在 0 のみ実装) + * + * @return opcode ごとに要求された値を返す. + * + */ +int +fvin_get_configuration(int opcode) +{ + switch(opcode) { + case 0: /* return number of elements in a vector */ + return(25); + case 1:/* return msec per frame */ + return(10); + case 2:/* return parameter type specification in HTK format */ + /* return 0xffff to disable checking */ + return(0xffff); + } +} + +/************************************************************************/ + +/** + * + * @brief Initialize input device (required) + * + * This will be called only once at start up of Julius. You can + * check if the input file exists or prepare a socket for connection. + * + * If this function returns FALSE, Julius will exit. + * + * JuliusLib: this function will be called at j_adin_init(). + * + * @return TRUE on success, FALSE on failure. + * + * + * @brief デバイスを初期化する(必須) + * + * この関数は起動時に一回だけ呼ばれる.ここでは入力ファイルの準備や + * ソケットの用意といった,入力のための準備を行うのに使う. + * + * FALSE を返した場合,Julius は終了する. + * + * JuliusLib: この関数は j_adin_init() で呼ばれる. + * + * @return 成功時 TRUE,失敗時 FALSE を返す. + * + */ +boolean +fvin_standby() +{ + + /* sever socket ready etc... */ + return TRUE; + +} + +/** + * + * @brief Open an input (required) + * + * This function should open a new input. You may open a feature + * vector file, or wait for connection at this function. + * + * If this function returns FALSE, Julius will exit recognition loop. + * + * JuliusLib: this will be called at j_open_stream(). + * + * @return TRUE on success, FALSE on failure. + * + * + * @brief 入力を開く(必須) + * + * 入力を新規に開く.ファイルのオープン,ネットワーククライアントからの + * 接続などはここで行う. + * + * FALSE を返したとき,Julius は認識ループを抜ける. + * + * JuliusLib: この関数は j_open_stream() 内で呼ばれる. + * + * @return 成功時 TRUE,失敗時 FALSE を返す. + * + */ +boolean +fvin_open() +{ + /* listen and accept socket, or open a file */ + return TRUE; +} + +/** + * + * @brief Read a vector from input (required) + * + * This will be called repeatedly at each frame, and the read vector + * will be processed immediately, and then this function is called again. + * + * Return value of ADIN_EOF tells end of stream to Julius, which + * causes Julius to finish current recognition and close stream. + * ADIN_SEGMENT requests Julius to segment the current input. The + * current recognition will be stopped at this point, recognition + * result will be output, and then Julius continues to the next input. + * The behavior of ADIN_SEGMENT is similar to ADIN_EOF except that + * ADIN_SEGMENT does not close/open input, but just stop and restart + * the recognition. At last, return value should be ADIN_ERROR on + * error, in which Julius exits itself immediately. + * + * @param vecbuf [out] store a vector obtained in this function + * @param veclen [in] vector length + * + * @return 0 on success, ADIN_EOF on end of stream, ADIN_SEGMENT to + * request segmentation to Julius, or ADIN_ERROR on error. + * + * + * @brief 入力からベクトルを読み込む(必須) + * + * この関数は入力からベクトルを1つだけ読み込む.この関数は + * フレームごとに呼ばれ,読み込まれたベクトルはこのあとすぐに認識処理され, + * また次のフレームのデータを読むためにこの関数が呼ばれる. + * + * 入力が終端まで達したとき,ADIN_EOF を返す.このとき,Julius は現在 + * の認識処理を終了させ,入力を閉じる. + * + * ADIN_ERROR はこの関数内で深刻なエラーが生じた場合に返す.これが返さ + * れた場合,Julius はその場で異常終了する. + * + * ADIN_SEGMENT を返すことで,Julius に現在の認識を現時点で区切ること + * を要求することができる.現在の認識処理はこの時点でいったん区切られ, + * そこまでの認識結果が確定・出力されたあと,次の認識処理が始まりこの + * 関数が呼ばれる.ADIN_SEGMENT は ADIN_EOF と動作が似ているが, + * ADIN_EOF が adin_close(), adin_open() を呼んで入力を終了させ + * るのに対して,ADIN_SEGMENT はこれらを呼ばずに入力を続行する. + * + * @param vecbuf [out] 得られたベクトルを格納するバッファ + * @param veclen [in] ベクトル長 + * + * @return 成功時 0 あるいは end of stream 時に ADIN_EOF, Julius に区 + * 切り要求を出すときには ADIN_SEGMENT, エラー時はADIN_ERROR を返す. + * + */ +int +fvin_read(float *vecbuf, int veclen) +{ + /* read one vector from the input */ + if (0/* error */) return ADIN_ERROR; + if (0/* input should be segmented here */) return ADIN_SEGMENT; + if (0/* EOF */) return ADIN_ERROR; + + return(0); /* success */ +} + +/** + * + * @brief Close the current input (required) + * + * This function will be called when the input has reached end of file + * (i.e. the last call of fvin_read() returns ADIN_EOF) + * + * You may close a file or disconnect network client here. + * + * If this function returns TRUE, Julius will go again to adin_open() + * to open another stream. If returns FALSE, Julius will exit + * the recognition loop. + * + * JuliusLib: This will be called at the end of j_recognize_stream(). + * + * @return TRUE on success, FALSE on failure. + * + * + * @brief 入力を閉じる(必須) + * + * 現在の入力を閉じる.この関数は,入力が終端(EOF)に達したとき(すな + * わち fvin_read() が ADIN_EOF を返したとき)に呼ばれる.通常,ここでは + * ファイルを閉じる,ネットワーク接続を切断するなどの処理を行う. + * + * 正常終了としてTRUEを返したとき,Julius は adin_open() に戻って + * 他のストリームを開こうとする. FALSE を返したときは,Julius は + * 認識ループを抜ける. + * + * JuliusLib: この関数は j_recognize_stream() の最後で呼ばれる. + * + * @return 成功時 TRUE,失敗時 FALSE を返す. + * + */ +boolean +fvin_close() +{ + /* file close, connection close, etc.. */ + return TRUE; +} + +/************************************************************************/ + +/** + * + * @brief A hook for Termination request (optional) + * + * This function will be called when Julius receives a Termination + * request to stop running. This can be used to synchronize input + * facility with Julius's running status. + * + * Termination will occur when Julius is running on module mode and + * received TERMINATE command from client, or j_request_terminate() + * is called inside application. On termination, Julius will stop + * recognition immediately (discard current input if in process), + * and wait until received RESUME command or call of j_request_resume(). + * + * This hook function will be called just after a Termination request. + * Please note that this will be called when Julius receives request, + * not on actual termination. + * + * @return TRUE on success, FALSE on failure. + * + * + * @brief 中断要求用フック(任意) + * + * この関数を定義すると,Julius は中断要求を受け取った際にこの関数を呼び出す. + * これを使って,Julius の中断・再開と同期した入力同期処理を実装することが + * できる.(例:入力送信元に対して送信中断要求を出すなど) + * + * 中断要求は,Julius がアプリケーションやクライアントより受け取る + * 認識中断の要求である.具体的には,Julius がモジュールモードで動作して + * いる時に TERMINATE コマンドをクライアントから受け取ったときや, + * JuliusLibを組み込んだアプリケーションが j_request_terminate() を + * 呼んだときに発生する. + * + * 中断要求を受け取ると,Julius は現在の認識処理を中断する. + * 認識途中であった場合,その入力を破棄して即時中断する. + * 処理の再開は,RESUME コマンドか j_request_resume() の呼び出しで行われる. + * + * この関数は中断要求を Julius が受け取った時点で呼ばれる. + * 実際に処理が中断した後で呼ばれるのではないことに注意されたい. + * + * @return 成功時 TRUE, エラー時 FALSE を返す. + * + * + */ +boolean +fvin_terminate() +{ + printf("terminate request\n"); + return TRUE; +} + +/** + * + * @brief A hook for Pause request (optional) + * + * This function will be called when Julius receives a Pause request + * to stop running. This can be used to synchronize input facility + * with Julius's running status. + * + * Pause will occur when Julius is running on module mode and + * received PAUSE command from client, or j_request_pause() + * is called inside application. On pausing, Julius will + * stop recognition and then wait until it receives RESUME command + * or j_request_resume() is called. When pausing occurs while recognition is + * running, Julius will process it to the end before stops. + * + * This hook function will be called just after a Pause request. + * Please note that this will be called when Julius receives request, + * not on actual pause. + * + * @return TRUE on success, FALSE on failure. + * + * + * @brief 停止要求用フック(任意) + * + * この関数を定義すると,Julius は停止要求を受け取った際にこの関数を呼び出す. + * これを使って,Julius の中断・再開と同期した入力同期処理を実装することが + * できる.(例:入力送信元に対して送信中断要求を出すなど) + * + * 停止要求は,Julius がアプリケーションやクライアントより受け取る, + * 認識の一時停止の要求である.具体的には,Julius がモジュールモードで動作して + * いる時に PAUSE コマンドをクライアントから受け取ったときや, + * JuliusLibを組み込んだアプリケーションが j_request_pause() を + * 呼んだときに発生する. + * + * 停止要求を受け取ると,Julius は現在の認識処理を中断する. + * 認識途中であった場合,その認識が終わるまで待ってから中断する. + * 処理の再開は,RESUME コマンドか j_request_resume() の呼び出しで行われる. + * + * 中断要求 (fvin_terminate) との違いは,認識途中に要求を受けたときの動作が + * 異なる.中断要求では強制中断するが,停止要求ではその認識が終わるまで + * 待ってから停止する. + * + * この関数は停止要求を Julius が受け取った時点で呼ばれる. + * 実際に処理が停止した後で呼ばれるのではないことに注意されたい. + * + * @return 成功時 TRUE, エラー時 FALSE を返す. + * + * + */ +boolean +fvin_pause() +{ + printf("pause request\n"); + return TRUE; +} + +/** + * + * @brief A hook for Resume request (optional) + * + * This function will be called when Julius received a resume request + * to recover from pause/termination status. + * + * Resume will occur when Julius has been stopped by receiving RESUME + * command from client on module mode, or j_request_resume() is called + * inside application. + * + * This hook function will be called just after a resume request. + * This can be used to make this A/D-in plugin cooperate with the + * pause/resume status, for example to tell audio client to restart + * audio streaming. + * + * This function is totally optional. + * + * @return TRUE on success, FALSE on failure. + * + * + * @brief 認識再開要求用フック(任意) + * + * この関数を定義すると,Julius は停止状態からの認識再開要求の際に + * この関数を呼び出す. + * + * 認識再開要求は,Julius がモジュールモードで動作して RESUME コマンドを + * クライアントから受け取ったときや,JuliusLibを組み込んだアプリケーション + * が j_request_resume() を呼んだときに発生する.この再開要求が発生 + * すると,Julius は停止していた認識を再開する. + * + * 注意:この関数は,実際に停止したときに呼ばれるのではなく,Julius が + * 要求を受け取った時点で,そのたびに呼ばれる.複数回呼ばれることや, + * すでに動作中である場合にさらにこのコマンドを受け取ったときにも呼ば + * れることがあることに注意されたい. + * + * @return 成功時 TRUE, エラー時 FALSE を返す. + * + * + */ +boolean +fvin_resume() +{ + printf("resume request\n"); + return TRUE; +} + +/* end of file */ Index: julius4/plugin/generic_callback.c diff -u /dev/null julius4/plugin/generic_callback.c:1.1 --- /dev/null Thu Sep 25 14:00:08 2008 +++ julius4/plugin/generic_callback.c Thu Sep 25 14:00:08 2008 @@ -0,0 +1,180 @@ +/** + * @file generic_callback.c + * + * + * @brief An example plugin using callback. + * + * + * + * @brief コールバックを使うプラグインのサンプル + * + * + * @author Akinobu Lee + * @date Wed Aug 13 23:50:27 2008 + * + * $Revision: 1.1 $ + * + */ + +/** + * Required for a file + * - get_plugin_info() + * + * Optional for a file + * - initialize() + * + */ +/** + * using plugin function: + * + * - engine_startup() + * + */ + + +// #include "plugin_defs.h" +#include + +#define PLUGIN_TITLE "An example plugin using callback" + +/** + * + * @brief Initialization at loading time (optional) + * + * If defined, this will be called just before this plugin is loaded to Julius. + * if this returns -1, the whole functions in this file will not be loaded. + * + * This function is OPTIONAL. + * + * + * @brief 読み込み時の初期化(任意) + * + * 起動時,Julius がこのプラグインを読み込む際に最初に呼ばれる. + * -1 を返すと,このプラグイン全体が読み込まれなくなる. + * 実行可能性のチェックに使える. + * + * + * + * + * @return 0 on success, -1 on failure. + * + */ +int +initialize() +{ + return 0; +} + +/** + * + * @brief Get information of this plugin (required) + * + * This function should return informations of this plugin file. + * The required info will be specified by opcode: + * - 0: return description string of this file into buf + * + * This will be called just after Julius find this file and after + * initialize(). + * + * @param opcode [in] requested operation code + * @param buf [out] buffer to store the return string + * @param buflen [in] maximum length of buf + * + * @return 0 on success, -1 on failure. On failure, Julius will ignore this + * plugin. + * + * + * + * @brief プラグイン情報取得(必須) + * + * このプラグインに関する情報を返す.与えられた opcode によって動作する. + * - 0 の場合,このプラグインファイルの名称を与えられたバッファに格納する + * + * この関数は,Julius がこのプラグインを読み込んだ直後に呼ばれる. + * + * @param opcode [in] 要求動作コード (現在 0 のみ実装) + * @param buf [out] 値を格納するバッファ + * @param buflen [in] buf の最大長 + * + * @return エラー時 -1, 成功時 0 を返す.エラーとして -1 を返した場合, + * このプラグイン全体は読み込まれない. + * + * + */ +int +get_plugin_info(int opcode, char *buf, int buflen) +{ + switch(opcode) { + case 0: + /* plugin description string */ + strncpy(buf, PLUGIN_TITLE, buflen); + break; + } + + return 0; +} + +/** + * + * A sample callback function to output RECREADY message. + * + * @param recog [in] engine instance + * @param dummy [in] callback argument (dummy) + * + * + * RECREADY を出力するコールバック用関数(サンプル) + * + * @param recog [in] エンジンインスタンス + * @param dummy [in] コールバック引数(ダミー) + * + * + */ +static void +status_recready(Recog *recog, void *dummy) +{ + printf("<<>>\n"); +} + +/** + * + * @brief plugin function that will be called after engine startup. + * + * When the function of this name is defined in a plugin, this will + * be called just after Julius finished all startup sequence and before + * input and recognition start. + * + * In this example, this function registers the local function + * status_recready() as a CALLBACK_EVENT_SPEECH_READY callback. + * This callback will be called on every time Julius is ready for + * recognition for the next incoming input. + * + * @param data [in] a data pointer, actually a pointer to an engine instance. + * + * @return 0 on success, -1 on error. On error, Julius will exit immediately. + * + * + * @brief 認識エンジン起動完了時に呼び出されるプラグイン関数 + * + * この名前の関数が定義された場合,その関数は,Julius が全ての初期化を + * 完了して起動プロセスを終えた直後,実際に音声入力を開いて認識が始ま + * る前に呼ばれます. + * + * ここでは,この関数を使って,上記の関数 status_recready() を + * CALLBACK_EVENT_SPEECH_READY コールバックとして登録しています. + * このコールバックは Julius が入力ストリームからの次の音声入力待ち + * 状態になったときに呼ばれます. + * + * @param data [in] データへのポインタ.実体はエンジンインスタンスへの + * ポインタが渡される. + * + * @return 成功時 0 ,エラー時 -1 を返す.エラーの場合 Julius は異常終了する. + * + * + */ +int +startup(void *data) +{ + Recog *recog = data; + callback_add(recog, CALLBACK_EVENT_SPEECH_READY, status_recready, NULL); + return 0; +} Index: julius4/plugin/plugin_defs.h diff -u /dev/null julius4/plugin/plugin_defs.h:1.1 --- /dev/null Thu Sep 25 14:00:08 2008 +++ julius4/plugin/plugin_defs.h Thu Sep 25 14:00:08 2008 @@ -0,0 +1,43 @@ +/** + * @file plugin_defs.h + * + * + * @brief Definitions for JPI Plugin + * + * + * + * @brief JPI プラグイン用定義 + * + * + * @author Akinobu Lee + * @date Sat Aug 9 23:46:32 2008 + * + * $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, Nagoya Institute of Technology + * All rights reserved + */ + +#ifndef __JULIUS_PLUGIN_DEFS__ +#define __JULIUS_PLUGIN_DEFS__ + +typedef unsigned char boolean; +typedef short SP16; + +#ifndef TRUE +#define TRUE 1 +#endif +#ifndef FALSE +#define FALSE 0 +#endif + +/// Return code of adin_read() +#define ADIN_EOF -1 +#define ADIN_ERROR -2 +#define ADIN_SEGMENT -3 + +#endif /* __JULIUS_PLUGIN_DEFS__ */ Index: julius4/plugin/result.c diff -u /dev/null julius4/plugin/result.c:1.1 --- /dev/null Thu Sep 25 14:00:08 2008 +++ julius4/plugin/result.c Thu Sep 25 14:00:08 2008 @@ -0,0 +1,164 @@ +/** + * @file result.c + * + * + * @brief Plugin to process recognition result + * + * + * + * @brief 認識結果を処理するプラグイン + * + * + * @author Akinobu Lee + * @date Fri Aug 22 15:17:59 2008 + * + * $Revision: 1.1 $ + * + */ + +/** + * Required for a file + * - get_plugin_info() + * + * Optional for a file + * - initialize() + * + */ +/** + * Result processing function + * + * - result_str() + * + */ + +/***************************************************************************/ + +#include +#include + +#define PLUGIN_TITLE "result process plugin for Julius" + +/** + * + * @brief Initialization at loading time (optional) + * + * If defined, this will be called just before this plugin is loaded to Julius. + * if this returns -1, the whole functions in this file will not be loaded. + * + * This function is OPTIONAL. + * + * + * @brief 読み込み時の初期化(任意) + * + * 起動時,Julius がこのプラグインを読み込む際に最初に呼ばれる. + * -1 を返すと,このプラグイン全体が読み込まれなくなる. + * 実行可能性のチェックに使える. + * + * + * + * + * @return 0 on success, -1 on failure. + * + */ +int +initialize() +{ + return 0; +} + +/** + * + * @brief Get information of this plugin (required) + * + * This function should return informations of this plugin file. + * The required info will be specified by opcode: + * - 0: return description string of this file into buf + * + * This will be called just after Julius find this file and after + * initialize(). + * + * @param opcode [in] requested operation code + * @param buf [out] buffer to store the return string + * @param buflen [in] maximum length of buf + * + * @return 0 on success, -1 on failure. On failure, Julius will ignore this + * plugin. + * + * + * + * @brief プラグイン情報取得(必須) + * + * このプラグインに関する情報を返す.与えられた opcode によって動作する. + * - 0 の場合,このプラグインファイルの名称を与えられたバッファに格納する + * + * この関数は,Julius がこのプラグインを読み込んだ直後に呼ばれる. + * + * @param opcode [in] 要求動作コード (現在 0 のみ実装) + * @param buf [out] 値を格納するバッファ + * @param buflen [in] buf の最大長 + * + * @return エラー時 -1, 成功時 0 を返す.エラーとして -1 を返した場合, + * このプラグイン全体は読み込まれない. + * + * + */ +int +get_plugin_info(int opcode, char *buf, int buflen) +{ + switch(opcode) { + case 0: + /* plugin description string */ + strncpy(buf, PLUGIN_TITLE, buflen); + break; + } + + return 0; +} + +/** + * + * @brief Process a recognition result (best string) + * + * This function will be called each time after recognition of an + * utterance is finished. The best recognition result for the + * utterance will be passed to this function, as a string in which + * words are separated by white space. When the recognition was failed + * or rejected, string will be NULL. + * + * On short-pause segmentation mode or GMM/Decoder-VAD mode, where + * an input utterance may be segmented into pieces, this funtion will be + * called for each segment. On multi decoding, the best hypothesis among + * all the recognition instance will be given. + * + * @param result_str [in] recognition result, words separated by whitespace, + * or NULL on failure + * + * + * + * @brief 認識結果の処理(最尤文字列) + * + * この関数は入力の認識が終わるたびに呼び出され, + * 入力に対する認識結果(最も確率の高い候補)の文字列が渡される. + * 与えられる文字列は,単語毎にスペースで区切られる. + * 認識が失敗した場合は, 文字列に NULL が渡される. + * + * ショートポーズセグメンテーションや GMM/Decoder ベースのVADを + * 行う場合,入力は小単位に分割される.この場合,この関数は + * その分割された小単位ごとに呼ばれる.また,複数モデル認識の場合, + * 全認識処理中で最もスコアの高い仮説が渡される. + * + * @param result_str [in] 認識結果(単語は空白で区切られている)NULLの + * 場合,認識失敗. + * + * + * + */ +void +result_best_str(char *result_str) +{ + if (result_str == NULL) { + printf("[failed]\n"); + } else { + printf(" <<%s>>\n", result_str); + } +} From sumomo @ users.sourceforge.jp Sun Sep 28 00:33:44 2008 From: sumomo @ users.sourceforge.jp (sumomo @ users.sourceforge.jp) Date: Sun, 28 Sep 2008 00:33:44 +0900 Subject: [Julius-cvs 262] CVS update: julius4 Message-ID: <1222529624.416044.23126.nullmailer@users.sourceforge.jp> Index: julius4/00readme-ja.txt diff -u julius4/00readme-ja.txt:1.4 julius4/00readme-ja.txt:1.5 --- julius4/00readme-ja.txt:1.4 Tue May 27 18:16:39 2008 +++ julius4/00readme-ja.txt Sun Sep 28 00:33:44 2008 @@ -4,7 +4,9 @@ Julius + (Rev 4.1 2008/09/xx) (Rev 4.0.2 2008/05/27) + (Rev 4.0 2007/12/19) (Rev 3.5.3 2006/12/29) (Rev 3.4.2 2004/04/30) (Rev 2.0 1999/02/20) @@ -30,36 +32,26 @@ http://julius.sourceforge.jp/ -Julius-4.0.2 +Julius-4.1 ============= -Julius-4.0.2 ????????s?????? -??_????Release-ja.txt ??????? - - -Julius-4.0 -============= - -Julius-4.0 ?????????????????????????????-????????????????????????Julius???????? -?????????????????????????????????? -??????????????????????????????????? -???タ???????????????????????????????? - -? ????????????????API??? -? Julius / Julian ???? -? ?????????????????????? -? ?????????????-? 4-gram ??????-gram???? -? ?????????????? -? confusion network ??-? ??????(VAD) ????GMM????????? -? ???????????????????????? - -Julius-3.x ???????????????????????m?????? -????l??????????D???ッ??????????????? -?????? (3.5.3) ???????????????? +4.0 ?? 4.0.2 ?????????????C??????????? +???????????????? "-fallback1pass" ? "-usepower" ? +?????Linux ??????? API ??????? OSS ?? ALSA ? +????????? + +4.0.2 ?? 4.1 ?????????????????MSD-HMM?????? +CVN ??? frequency warping for VTLN ?????????????? +???????????????? perl ????? "jclient-perl" ? +???????? + +??? 4.1 ???????????????????????????タ? +???????????タ??????????????? +?????? "plugin" ???????????????????????? +?????????????????????????????? +????????????R?????????????C?????????? +??????_????????Release-ja.txt ??????? ??????? =============== @@ -81,6 +73,8 @@ mkbinhmm/ ????HMM????? mkbinhmm mkgshmm/ GMS??????????? mkgshmm mkss/ ????????????c?? mkss + jclient-perl/ A simple perl version of module mode client + plugin/ ????????????????????? support/ ???????? @@ -93,16 +87,20 @@ ??????????????????????????????????? ????????C?????????????????????????? - ???????http://julius.sourceforge.jp/ + ???????http://julius.sourceforge.jp/ ????L???????????Julius???????????????? -??????????s???????メ???????????????? +??????????s???????メ???????????????? +??? Julius ? CVS ????????e????? +???????????? + + Julius Forum: http://julius.sourceforge.jp/forum/ ????? =========== -Julius/Julian ????????????????? +Julius ????????????????? ??p???p????????????????????? ???????????????"LICENSE.txt" ?????????????? Index: julius4/00readme.txt diff -u julius4/00readme.txt:1.4 julius4/00readme.txt:1.5 --- julius4/00readme.txt:1.4 Tue May 27 18:16:39 2008 +++ julius4/00readme.txt Sun Sep 28 00:33:44 2008 @@ -4,7 +4,9 @@ Julius + (Rev 4.1 2008/09/xx) (Rev 4.0.2 2008/05/27) + (Rev 4.0 2007/12/19) (Rev 3.5.3 2006/12/29) (Rev 3.4.2 2004/04/30) (Rev 2.0 1999/02/20) @@ -37,41 +39,25 @@ together with source codes. -What's new in Julius-4.0.2 +What's new in Julius-4.1 =========================== -Julius rev.4.0.2 is a bug fix release. -Please see Release.txt for detailed list of fixes. +From 4.0 to 4.0.2, many bugs are fixed and small improvements were +done. New options "-fallback1pass" and "-usepower" were added. The +default audio API is changed from "oss" to "alsa" on Linux. + +From 4.0.2 to 4.1, multi-stream AM, MSD-HMM, CVN, frequency warping +for VTLN are all supported. "jclient-perl", a perl version of module +mode client, is newly added. + +A great forward-steps have been made by implementing a plugin +capability. It enables run-time, easy extension of decoder. +The directory "plugin" contains several example source codes and +ready to compile and test them. The source codes also contain all +function specification documents. -What's new in Julius-4.0 -========================== - -The Julius rev.4.0 is a full major version up, a re-innovation of the -decoder as a flexible speech recognition engine. The internal -structures are re-organized and modularized thoroughly, which results -in the librarization of core engine, enhancement and unification of -language model, realization of multi-decoding with hot plugging -feature. The major features are listed below: - - - Engine core becomes separate C library with simple API - - Can handle various LM, thus Julius and Julian are integrated - - Multi-decoding with multiple models - - Support to add and remove models while running the decoder - - Support N-gram longer than 4 (N now unlimited) - - User-defined LM function - - Confusion network output - - GMM-based and decoder-based VAD - - New tools added, new functions added - - Memory efficiency is improved - -Julius-4.0 ensures the compatibility with Julius-3.x for its usage and -Jconf configuration, so that one can easily migrate to Julius-4. -The decoding performance of Julius-4.0 is still kept as the same as -the latest release (Julius-3.5.3) for now. - - -Contents of Julius-4.0 +Contents of Julius-4.1 ========================= (Documents with suffix "ja" are written in Japanese) @@ -94,6 +80,8 @@ mkgshmm/ Model conversion for Gaussian Mixture Selection mkss/ Estimate noise spectrum from mic input support/ some tools to compile julius/julian from source + jclient-perl/ A simple perl version of module mode client + plugin/ Several plugin source codes and documentation olddoc/ ChangeLogs before 3.2 @@ -104,7 +92,8 @@ http://julius.sourceforge.jp/en/ -Also it is worth taking a look at the Julius forum at: +For QA, discussion and development information, please see and join +the Julius web forum at: http://julius.sourceforge.jp/forum/ Index: julius4/Release-ja.txt diff -u julius4/Release-ja.txt:1.4 julius4/Release-ja.txt:1.5 --- julius4/Release-ja.txt:1.4 Tue May 27 18:16:39 2008 +++ julius4/Release-ja.txt Sun Sep 28 00:33:44 2008 @@ -1,3 +1,42 @@ +4.1 (2008.9.xx) +================ +?????????????? + - ??????????? + - ?????? + - ????????? + - ??????+ - ?????????+ - ????+ - JuliusLib ?????????????????????????? + - ??????????????????????????????R?????? + - ?????Linux, Windows ??? dlopen() ??? OS + +????? + - ?????????????????? + - MSD-HMM ??????HTS ????????????f??????? + - CVN ???? + - VTLN ? frequency warping ???????????? + - "-input alsa", "-input oss" ??? "-input esd" + - ???????????????? perl ? "jclient-perl" ??? + +?????? + - ??????ッ????????????? + - ?????????????????????????K????? + ??????????????? "-LM" ??????????????? + ??????K???????????????? "-AM" ????????+ ???????????? + - ???????????????????????C"-GLOBAL" ????? + ????????+ ???????????? "-nosectioncheck" ?????????????D + +?????F + - "-record" ???????????????t?????????? + - "-multigramout" ???????? + - jconf ???????????????????????? + - HMM ???????HMM?????? 256, ???????P? + - ??????????????????????? + + 4.0.2 (2008.5.27) ================== ???? Index: julius4/Release.txt diff -u julius4/Release.txt:1.4 julius4/Release.txt:1.5 --- julius4/Release.txt:1.4 Tue May 27 18:16:39 2008 +++ julius4/Release.txt Sun Sep 28 00:33:44 2008 @@ -1,3 +1,42 @@ +4.1 (2008.9.xx) +================ +New plugin extension: + - supported types: + - A/D-in plugin + - feature vector input plugin + - audio input monitor / postprocess plugin + - feature vector monitor / postprocess plugin + - result plugin + - can add arbitrary JuliusLib callback via plugin + - sample codes is included, with full documentation of function spec. + - run on Linux, Windows and other unix variants with dlopen() capability + +Newly supported features: + - multi-stream feature input + - MSD-HMM (compatible with "HTS" toolkit) + - CVN + - frequency warping for VTLN (no estimation yet) + - "-input alsa", "-input oss" and "-input esd" + - perl version of jcontrol client "jclient-perl" + +Modified: + - Restrict option orders when multiple instances defined (-AM, -LM, -SR): + - Option should be just after correspondence instance declaration. + (ex. LM options should be placed after "-LM" and before other + instance declaration.) + - Global option should be before any instance declaration, or + just after "-GLOBAL" option. + This new restriction can be removed by "-nosectioncheck" option. + +Fixed bugs: + - "-record" fails to record the first silence part! + - Not working "-multigramout" + - environment variable expansion sometimes fail within jconf file. + - limits extended: + maximum HMM name length = 256 char, Number of HMM states unlimited. + - Module mode error message on grammar command. + + 4.0.2 (2008.5.27) ================== New features: Index: julius4/Sample.jconf diff -u julius4/Sample.jconf:1.4 julius4/Sample.jconf:1.5 --- julius4/Sample.jconf:1.4 Tue Jun 17 10:20:50 2008 +++ julius4/Sample.jconf Sun Sep 28 00:33:44 2008 @@ -111,6 +111,13 @@ #-realtime # force real-time processing #-norealtime # force non real-time processing +#### +#### Plug-in +#### +#### See plugin/00readme.txt for detail +#### +#-plugindir ./plugin:/usr/local/share/julius/plugins + ###################################################################### #### INSTANCE DEFINITION FOR MULTI DECODING @@ -165,6 +172,14 @@ ## configuration. # -AM_GMM +## When using instance declarations, global options should be placed +## at top before any instance declaration, or after this option below. +## This option is only a switcher and can be used anywhere anytime. +# -GLOBAL + +## This option disables strict section check and back to 4.0 +# -nosectioncheck + ###################################################################### #### LANGUAGE MODEL (-LM) ###################################################################### From sumomo @ users.sourceforge.jp Tue Sep 30 12:58:17 2008 From: sumomo @ users.sourceforge.jp (sumomo @ users.sourceforge.jp) Date: Tue, 30 Sep 2008 12:58:17 +0900 Subject: [Julius-cvs 263] CVS update: julius4/libjulius/include/julius Message-ID: <1222747097.607453.13962.nullmailer@users.sourceforge.jp> Index: julius4/libjulius/include/julius/wchmm.h diff -u julius4/libjulius/include/julius/wchmm.h:1.3 julius4/libjulius/include/julius/wchmm.h:1.4 --- julius4/libjulius/include/julius/wchmm.h:1.3 Wed Feb 13 17:43:43 2008 +++ julius4/libjulius/include/julius/wchmm.h Tue Sep 30 12:58:17 2008 @@ -28,7 +28,7 @@ * @author Akinobu Lee * @date Sun Sep 18 21:31:32 2005 * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * */ /* @@ -261,6 +261,7 @@ BMALLOC_BASE *malloc_root; ///< Pointer for block memory allocation #ifdef PASS1_IWCD APATNODE *lcdset_category_root; ///< Index of lexicon-dependent category-aware pseudo phone set when used on Julian + BMALLOC_BASE *lcdset_mroot; #endif /* PASS1_IWCD */ HMMWork *hmmwrk; ///< Work area for HMM computation in wchmm From sumomo @ users.sourceforge.jp Tue Sep 30 12:58:17 2008 From: sumomo @ users.sourceforge.jp (sumomo @ users.sourceforge.jp) Date: Tue, 30 Sep 2008 12:58:17 +0900 Subject: [Julius-cvs 264] CVS update: julius4/libjulius/src Message-ID: <1222747097.835634.13972.nullmailer@users.sourceforge.jp> Index: julius4/libjulius/src/outprob_style.c diff -u julius4/libjulius/src/outprob_style.c:1.3 julius4/libjulius/src/outprob_style.c:1.4 --- julius4/libjulius/src/outprob_style.c:1.3 Wed Feb 13 17:48:13 2008 +++ julius4/libjulius/src/outprob_style.c Tue Sep 30 12:58:17 2008 @@ -68,7 +68,7 @@ * @author Akinobu Lee * @date Mon Aug 22 17:14:26 2005 * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * */ /* @@ -232,7 +232,7 @@ } } if (! ltmp->is_pseudo) { - if (regist_cdset(&(wchmm->lcdset_category_root), ltmp->body.defined, wchmm->lccbuf2)) { + if (regist_cdset(&(wchmm->lcdset_category_root), ltmp->body.defined, wchmm->lccbuf2, &(wchmm->lcdset_mroot))) { cnt_p++; } } @@ -316,7 +316,7 @@ void lcdset_remove_with_category_all(WCHMM_INFO *wchmm) { - free_cdset(&(wchmm->lcdset_category_root)); + free_cdset(&(wchmm->lcdset_category_root), &(wchmm->lcdset_mroot)); } #endif /* PASS1_IWCD */ Index: julius4/libjulius/src/wchmm.c diff -u julius4/libjulius/src/wchmm.c:1.4 julius4/libjulius/src/wchmm.c:1.5 --- julius4/libjulius/src/wchmm.c:1.4 Wed Feb 13 17:47:26 2008 +++ julius4/libjulius/src/wchmm.c Tue Sep 30 12:58:17 2008 @@ -31,7 +31,7 @@ * @author Akinobu Lee * @date Mon Sep 19 23:39:15 2005 * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * */ /* @@ -79,6 +79,7 @@ w->malloc_root = NULL; #ifdef PASS1_IWCD w->lcdset_category_root = NULL; + w->lcdset_mroot = NULL; #endif /* PASS1_IWCD */ w->wrk.out_from_len = 0; /* reset user function entry point */ From sumomo @ users.sourceforge.jp Tue Sep 30 12:58:18 2008 From: sumomo @ users.sourceforge.jp (sumomo @ users.sourceforge.jp) Date: Tue, 30 Sep 2008 12:58:18 +0900 Subject: [Julius-cvs 265] CVS update: julius4/libsent Message-ID: <1222747098.015991.13979.nullmailer@users.sourceforge.jp> Index: julius4/libsent/Makefile.in diff -u julius4/libsent/Makefile.in:1.5 julius4/libsent/Makefile.in:1.6 --- julius4/libsent/Makefile.in:1.5 Mon Jul 7 14:50:11 2008 +++ julius4/libsent/Makefile.in Tue Sep 30 12:58:17 2008 @@ -3,7 +3,7 @@ # Copyright (c) 2005-2007 Julius project team, Nagoya Institute of Technology # All rights reserved # -# $Id: Makefile.in,v 1.5 2008/07/07 05:50:11 sumomo Exp $ +# $Id: Makefile.in,v 1.6 2008/09/30 03:58:17 sumomo Exp $ # SHELL=/bin/sh @@ -79,6 +79,8 @@ src/hmminfo/chkhmmlist.o \ src/hmminfo/write_binhmm.o \ src/hmminfo/read_binhmm.o \ +src/hmminfo/write_binhmmlist.o \ +src/hmminfo/read_binhmmlist.o \ src/net/rdwt.o \ src/net/server-client.o \ src/ngram/init_ngram.o \ From sumomo @ users.sourceforge.jp Tue Sep 30 12:58:18 2008 From: sumomo @ users.sourceforge.jp (sumomo @ users.sourceforge.jp) Date: Tue, 30 Sep 2008 12:58:18 +0900 Subject: [Julius-cvs 266] CVS update: julius4/libsent/include/sent Message-ID: <1222747098.178853.13988.nullmailer@users.sourceforge.jp> Index: julius4/libsent/include/sent/htk_hmm.h diff -u julius4/libsent/include/sent/htk_hmm.h:1.4 julius4/libsent/include/sent/htk_hmm.h:1.5 --- julius4/libsent/include/sent/htk_hmm.h:1.4 Mon Jul 7 14:50:11 2008 +++ julius4/libsent/include/sent/htk_hmm.h Tue Sep 30 12:58:18 2008 @@ -16,7 +16,7 @@ * @author Akinobu LEE * @date Thu Feb 10 19:36:47 2005 * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * */ /* @@ -402,6 +402,7 @@ BMALLOC_BASE *mroot; ///< Pointer for block memory allocation BMALLOC_BASE *lroot; ///< Pointer for block memory allocation for logical HMM + BMALLOC_BASE *cdset_root; ///< Pointer for block memory allocation for logical HMM int *tmp_mixnum; ///< Work area for state reading @@ -464,6 +465,9 @@ void def_regtree_macro(char *name, FILE *fp, HTK_HMM_INFO *hmm); /* rdhmmdef_hmmlist.c */ boolean rdhmmlist(FILE *fp, HTK_HMM_INFO *hmminfo); +boolean save_hmmlist_bin(FILE *fp, HTK_HMM_INFO *hmminfo); +boolean load_hmmlist_bin(FILE *fp, HTK_HMM_INFO *hmminfo); + /* put_htkdata_info.c */ void put_htk_trans(FILE *fp, HTK_HMM_Trans *t); void put_htk_var(FILE *fp, HTK_HMM_Var *v); @@ -502,10 +506,10 @@ char *rightcenter_name(char *hmmname, char *buf); /* CD_SET related */ -boolean regist_cdset(APATNODE **root, HTK_HMM_Data *d, char *cdname); +boolean regist_cdset(APATNODE **root, HTK_HMM_Data *d, char *cdname, BMALLOC_BASE **mroot); boolean make_cdset(HTK_HMM_INFO *hmminfo); void put_all_cdinfo(HTK_HMM_INFO *hmminfo); -void free_cdset(APATNODE **root); +void free_cdset(APATNODE **root, BMALLOC_BASE **mroot); CD_Set *cdset_lookup(HTK_HMM_INFO *hmminfo, char *cdstr); CD_Set *lcdset_lookup_by_hmmname(HTK_HMM_INFO *hmminfo, char *hmmname); CD_Set *rcdset_lookup_by_hmmname(HTK_HMM_INFO *hmminfo, char *hmmname); Index: julius4/libsent/include/sent/ptree.h diff -u julius4/libsent/include/sent/ptree.h:1.2 julius4/libsent/include/sent/ptree.h:1.3 --- julius4/libsent/include/sent/ptree.h:1.2 Tue Dec 18 17:45:50 2007 +++ julius4/libsent/include/sent/ptree.h Tue Sep 30 12:58:18 2008 @@ -17,7 +17,7 @@ * @author Akinobu LEE * @date Fri Feb 11 17:27:24 2005 * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * */ /* @@ -64,7 +64,7 @@ struct _patnode *right1; ///< Link to right node (bit=1) } PATNODE; -int testbit(char *str, int bitplace); +int testbit(char *str, int slen, int bitplace); int testbit_max(char *str, int bitplace, int maxbitplace); int where_the_bit_differ(char *str1, char *str2); PATNODE *make_ptree(char **words, int *data, int wordsnum, int bitplace); @@ -75,10 +75,11 @@ void free_ptree(PATNODE *rootnode); void *aptree_search_data(char *str, APATNODE *rootnode); -APATNODE *aptree_make_root_node(void *data); -void aptree_add_entry(char *str, void *data, char *matchstr, APATNODE **rootnode); +APATNODE *aptree_make_root_node(void *data, BMALLOC_BASE **mroot); +void aptree_add_entry(char *str, void *data, char *matchstr, APATNODE **rootnode, BMALLOC_BASE **mroot); void aptree_remove_entry(char *str, APATNODE **rootnode); void aptree_traverse_and_do(APATNODE *node, void (*callback)(void *)); -void free_aptree(APATNODE *rootnode); +boolean aptree_write(FILE *fp, APATNODE *root, boolean (*save_data_func)(void *, FILE *fp)); +boolean aptree_read(FILE *fp, APATNODE **root, BMALLOC_BASE **mroot, void *data, boolean (*load_data_func)(void **, void *, FILE *fp)); #endif /* __PATRICIA_TREE_H__ */ From sumomo @ users.sourceforge.jp Tue Sep 30 12:58:18 2008 From: sumomo @ users.sourceforge.jp (sumomo @ users.sourceforge.jp) Date: Tue, 30 Sep 2008 12:58:18 +0900 Subject: [Julius-cvs 267] CVS update: julius4/libsent/src/hmminfo Message-ID: <1222747098.447903.14023.nullmailer@users.sourceforge.jp> Index: julius4/libsent/src/hmminfo/cdset.c diff -u julius4/libsent/src/hmminfo/cdset.c:1.3 julius4/libsent/src/hmminfo/cdset.c:1.4 --- julius4/libsent/src/hmminfo/cdset.c:1.3 Wed Feb 13 17:40:07 2008 +++ julius4/libsent/src/hmminfo/cdset.c Tue Sep 30 12:58:18 2008 @@ -60,7 +60,7 @@ * @author Akinobu LEE * @date Tue Feb 15 17:58:54 2005 * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * */ /* @@ -204,7 +204,7 @@ * @return TRUE if newly registered, FALSE if the specified physical %HMM already exists in the pseudo phone. */ boolean -regist_cdset(APATNODE **root, HTK_HMM_Data *d, char *cdname) +regist_cdset(APATNODE **root, HTK_HMM_Data *d, char *cdname, BMALLOC_BASE **mroot) { boolean need_new; CD_State_Set *tmp; @@ -273,9 +273,9 @@ lset->tr = d->tr; /* add to search index tree */ if (*root == NULL) { - *root = aptree_make_root_node(lset); + *root = aptree_make_root_node(lset, mroot); } else { - aptree_add_entry(lset->name, lset, lmatch->name, root); + aptree_add_entry(lset->name, lset, lmatch->name, root, mroot); } changed = TRUE; @@ -309,39 +309,6 @@ } /** - * Remove an pseudo phone set entry from index tree - * - * @param hmminfo - * @param cdname - * - * @return - */ -boolean -remove_cdset(HTK_HMM_INFO *hmminfo, char *cdname) -{ - CD_Set *lmatch; - - if (hmminfo->cdset_info.cdtree == NULL) return TRUE; - - lmatch = aptree_search_data(cdname, hmminfo->cdset_info.cdtree); - if (lmatch != NULL && strmatch(lmatch->name, cdname)) { - jlog("Stat: cdset: [%s] found, removed from cdset\n", lmatch->name); - /* found */ - /* - for(j=1;jstate_num-1;j++) { - free(lmatch->stateset[j].s); - } - free(lmatch->stateset); - */ - aptree_remove_entry(cdname, &(hmminfo->cdset_info.cdtree)); - } else { - return FALSE; - } - return TRUE; -} - - -/** * Construct the whole pseudo %HMM information, and also add them to the logical Triphone tree. * * @param hmminfo [i/o] %HMM definition data. The generated data will also @@ -361,19 +328,19 @@ for 1st pass (word end) */ for(lg = hmminfo->lgstart; lg; lg = lg->next) { if (lg->is_pseudo) continue; - regist_cdset(&(hmminfo->cdset_info.cdtree), lg->body.defined, leftcenter_name(lg->name, buf)); + regist_cdset(&(hmminfo->cdset_info.cdtree), lg->body.defined, leftcenter_name(lg->name, buf), &(hmminfo->cdset_root)); } /* right-context set: "a+o" for /b-a+o/, /t-a+o/, ... for 2nd pass (word beginning) */ for(lg = hmminfo->lgstart; lg; lg = lg->next) { if (lg->is_pseudo) continue; - regist_cdset(&(hmminfo->cdset_info.cdtree), lg->body.defined, rightcenter_name(lg->name, buf)); + regist_cdset(&(hmminfo->cdset_info.cdtree), lg->body.defined, rightcenter_name(lg->name, buf), &(hmminfo->cdset_root)); } /* both-context set: "a" for all triphone with same base phone "a" for 1st pass (1 phoneme word, with no previous word hypo.) */ for(lg = hmminfo->lgstart; lg; lg = lg->next) { if (lg->is_pseudo) continue; - regist_cdset(&(hmminfo->cdset_info.cdtree), lg->body.defined, center_name(lg->name, buf)); + regist_cdset(&(hmminfo->cdset_info.cdtree), lg->body.defined, center_name(lg->name, buf), &(hmminfo->cdset_root)); } /* now that cdset is completely built */ @@ -409,11 +376,11 @@ * @param root [i/o] pointer to hold the root index pointer */ void -free_cdset(APATNODE **root) +free_cdset(APATNODE **root, BMALLOC_BASE **mroot) { if (*root != NULL) { aptree_traverse_and_do(*root, callback_free_lcdset_content); - free_aptree(*root); + mybfree2(mroot); *root = NULL; } } Index: julius4/libsent/src/hmminfo/chkhmmlist.c diff -u julius4/libsent/src/hmminfo/chkhmmlist.c:1.3 julius4/libsent/src/hmminfo/chkhmmlist.c:1.4 --- julius4/libsent/src/hmminfo/chkhmmlist.c:1.3 Wed Feb 13 17:40:07 2008 +++ julius4/libsent/src/hmminfo/chkhmmlist.c Tue Sep 30 12:58:18 2008 @@ -26,7 +26,7 @@ * @author Akinobu LEE * @date Tue Feb 15 19:17:51 2005 * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * */ /* @@ -66,8 +66,8 @@ new->endflag = FALSE; new->name = (char *)mybmalloc2(strlen(p)+1, &(hmminfo->mroot)); strcpy(new->name, p); - if (root == NULL) root = aptree_make_root_node(new); - else aptree_add_entry(new->name, new, match->name, &root); + if (root == NULL) root = aptree_make_root_node(new, &(hmminfo->mroot)); + else aptree_add_entry(new->name, new, match->name, &root, &(hmminfo->mroot)); n++; } hmminfo->basephone.num = n; @@ -223,8 +223,8 @@ } new = (char *)mybmalloc2(strlen(lostname)+1, &(hmminfo->mroot)); strcpy(new, lostname); - if (error_root == NULL) error_root = aptree_make_root_node(new); - else aptree_add_entry(new, new, match, &error_root); + if (error_root == NULL) error_root = aptree_make_root_node(new, &(hmminfo->mroot)); + else aptree_add_entry(new, new, match, &error_root, &(hmminfo->mroot)); error_num++; } Index: julius4/libsent/src/hmminfo/hmm_lookup.c diff -u julius4/libsent/src/hmminfo/hmm_lookup.c:1.3 julius4/libsent/src/hmminfo/hmm_lookup.c:1.4 --- julius4/libsent/src/hmminfo/hmm_lookup.c:1.3 Wed Feb 13 17:40:07 2008 +++ julius4/libsent/src/hmminfo/hmm_lookup.c Tue Sep 30 12:58:18 2008 @@ -34,7 +34,7 @@ * @author Akinobu LEE * @date Tue Feb 15 22:34:30 2005 * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * */ /* @@ -143,9 +143,9 @@ new->next = hmminfo->lgstart; hmminfo->lgstart = new; if (hmminfo->logical_root == NULL) { - hmminfo->logical_root = aptree_make_root_node(new); + hmminfo->logical_root = aptree_make_root_node(new, &(hmminfo->lroot)); } else { - aptree_add_entry(new->name, new, match->name, &(hmminfo->logical_root)); + aptree_add_entry(new->name, new, match->name, &(hmminfo->logical_root), &(hmminfo->lroot)); } } @@ -192,9 +192,9 @@ new->next = hmminfo->lgstart; hmminfo->lgstart = new; if (hmminfo->logical_root == NULL) { - hmminfo->logical_root = aptree_make_root_node(new); + hmminfo->logical_root = aptree_make_root_node(new, &(hmminfo->lroot)); } else { - aptree_add_entry(new->name, new, match->name, &(hmminfo->logical_root)); + aptree_add_entry(new->name, new, match->name, &(hmminfo->logical_root), &(hmminfo->lroot)); } hmminfo->totalpseudonum++; } Index: julius4/libsent/src/hmminfo/init_phmm.c diff -u julius4/libsent/src/hmminfo/init_phmm.c:1.3 julius4/libsent/src/hmminfo/init_phmm.c:1.4 --- julius4/libsent/src/hmminfo/init_phmm.c:1.3 Mon Jul 7 14:50:11 2008 +++ julius4/libsent/src/hmminfo/init_phmm.c Tue Sep 30 12:58:18 2008 @@ -12,7 +12,7 @@ * @author Akinobu LEE * @date Tue Feb 15 23:05:33 2005 * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * */ /* @@ -39,6 +39,7 @@ new->mroot = NULL; new->lroot = NULL; + new->cdset_root = NULL; new->tmp_mixnum = NULL; new->opt.stream_info.num = 0; @@ -96,20 +97,8 @@ hmminfo_free(HTK_HMM_INFO *hmm) { /* cdset does not use bmalloc, so free them separately */ - free_cdset(&(hmm->cdset_info.cdtree)); + free_cdset(&(hmm->cdset_info.cdtree), &(hmm->cdset_root)); - /* free lookup indexes */ - free_aptree(hmm->tr_root); - free_aptree(hmm->sw_root); - free_aptree(hmm->vr_root); - free_aptree(hmm->pdf_root); - free_aptree(hmm->dn_root); - free_aptree(hmm->st_root); - free_aptree(hmm->physical_root); - free_aptree(hmm->logical_root); - free_aptree(hmm->codebook_root); - free_aptree(hmm->basephone.root); - /* free all memory that has been allocated by bmalloc2() */ if (hmm->mroot != NULL) mybfree2(&(hmm->mroot)); if (hmm->lroot != NULL) mybfree2(&(hmm->lroot)); @@ -135,6 +124,7 @@ { FILE *fp; boolean ok_p; + boolean binary; ok_p = FALSE; @@ -180,15 +170,41 @@ jlog("Error: init_phmm: failed to open %s\n",namemapfile); return FALSE; } - if (rdhmmlist(fp, hmminfo) == FALSE) { - jlog("Error: init_phmm: HMMList \"%s\" read error\n",namemapfile); - return FALSE; + /* detect binary / ascii by the first 4 bytes */ + { + int x; + if (myfread(&x, sizeof(int), 1, fp) < 1) { + jlog("Error: init_phmm: failed to read %s\n", namemapfile); + return FALSE; + } + if (x == 0) { + binary = TRUE; + } else { + binary = FALSE; + myfrewind(fp); + } + } + if (binary) { + /* binary format */ + jlog("Stat: init_phmm: loading binary hmmlist\n"); + if (load_hmmlist_bin(fp, hmminfo) == FALSE) { + jlog("Error: init_phmm: HMMList \"%s\" read error\n",namemapfile); + return FALSE; + } + } else { + /* ascii format */ + jlog("Stat: init_phmm: loading ascii hmmlist\n"); + if (rdhmmlist(fp, hmminfo) == FALSE) { + jlog("Error: init_phmm: HMMList \"%s\" read error\n",namemapfile); + return FALSE; + } } if (fclose_readfile(fp) < 0) { jlog("Error: init_phmm: failed to close %s\n", namemapfile); return FALSE; } jlog("Stat: init_phmm: logical names: %5d in HMMList\n", hmminfo->totallogicalnum); + } else { /* add all names of physical HMMs as logical names */ hmm_add_physical_to_logical(hmminfo); Index: julius4/libsent/src/hmminfo/rdhmmdef_data.c diff -u julius4/libsent/src/hmminfo/rdhmmdef_data.c:1.2 julius4/libsent/src/hmminfo/rdhmmdef_data.c:1.3 --- julius4/libsent/src/hmminfo/rdhmmdef_data.c:1.2 Tue Dec 18 17:45:51 2007 +++ julius4/libsent/src/hmminfo/rdhmmdef_data.c Tue Sep 30 12:58:18 2008 @@ -12,7 +12,7 @@ * @author Akinobu LEE * @date Wed Feb 16 01:12:19 2005 * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * */ /* @@ -68,7 +68,7 @@ } else { /* add index to search index tree */ if (hmm->physical_root == NULL) { - hmm->physical_root = aptree_make_root_node(new); + hmm->physical_root = aptree_make_root_node(new, &(hmm->mroot)); } else { match = aptree_search_data(new->name, hmm->physical_root); if (match != NULL && strmatch(match->name, new->name)) { @@ -76,7 +76,7 @@ jlog("Error: rdhmmdef_data: HMM \"%s\" is defined more than twice\n", new->name); rderr(NULL); } else { - aptree_add_entry(new->name, new, match->name, &(hmm->physical_root)); + aptree_add_entry(new->name, new, match->name, &(hmm->physical_root), &(hmm->mroot)); } } } Index: julius4/libsent/src/hmminfo/rdhmmdef_dens.c diff -u julius4/libsent/src/hmminfo/rdhmmdef_dens.c:1.2 julius4/libsent/src/hmminfo/rdhmmdef_dens.c:1.3 --- julius4/libsent/src/hmminfo/rdhmmdef_dens.c:1.2 Tue Dec 18 17:45:51 2007 +++ julius4/libsent/src/hmminfo/rdhmmdef_dens.c Tue Sep 30 12:58:18 2008 @@ -12,7 +12,7 @@ * @author Akinobu LEE * @date Wed Feb 16 01:43:43 2005 * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * */ /* @@ -22,7 +22,7 @@ * All rights reserved */ -/* $Id: rdhmmdef_dens.c,v 1.2 2007/12/18 08:45:51 sumomo Exp $ */ +/* $Id: rdhmmdef_dens.c,v 1.3 2008/09/30 03:58:18 sumomo Exp $ */ #include #include @@ -88,14 +88,14 @@ if (new->name != NULL) { /* add index to search index tree */ if (hmm->dn_root == NULL) { - hmm->dn_root = aptree_make_root_node(new); + hmm->dn_root = aptree_make_root_node(new, &(hmm->mroot)); } else { match = aptree_search_data(new->name, hmm->dn_root); if (match != NULL && strmatch(match->name, new->name)) { jlog("Error: rdhmmdef_dens: ~m \"%s\" is already defined\n", new->name); rderr(NULL); } else { - aptree_add_entry(new->name, new, match->name, &(hmm->dn_root)); + aptree_add_entry(new->name, new, match->name, &(hmm->dn_root), &(hmm->mroot)); } } } Index: julius4/libsent/src/hmminfo/rdhmmdef_mpdf.c diff -u julius4/libsent/src/hmminfo/rdhmmdef_mpdf.c:1.1 julius4/libsent/src/hmminfo/rdhmmdef_mpdf.c:1.2 --- julius4/libsent/src/hmminfo/rdhmmdef_mpdf.c:1.1 Mon Jul 7 14:50:11 2008 +++ julius4/libsent/src/hmminfo/rdhmmdef_mpdf.c Tue Sep 30 12:58:18 2008 @@ -12,7 +12,7 @@ * @author Akinobu LEE * @date Wed Feb 16 01:43:43 2005 * - * $Revision: 1.1 $ + * $Revision: 1.2 $ * */ /* @@ -68,14 +68,14 @@ if (new->name != NULL) { /* add index to search index tree */ if (hmm->pdf_root == NULL) { - hmm->pdf_root = aptree_make_root_node(new); + hmm->pdf_root = aptree_make_root_node(new, &(hmm->mroot)); } else { match = aptree_search_data(new->name, hmm->pdf_root); if (match != NULL && strmatch(match->name, new->name)) { jlog("Error: rdhmmdef_dens: ~m \"%s\" is already defined\n", new->name); rderr(NULL); } else { - aptree_add_entry(new->name, new, match->name, &(hmm->pdf_root)); + aptree_add_entry(new->name, new, match->name, &(hmm->pdf_root), &(hmm->mroot)); } } } Index: julius4/libsent/src/hmminfo/rdhmmdef_state.c diff -u julius4/libsent/src/hmminfo/rdhmmdef_state.c:1.3 julius4/libsent/src/hmminfo/rdhmmdef_state.c:1.4 --- julius4/libsent/src/hmminfo/rdhmmdef_state.c:1.3 Mon Jul 7 14:50:11 2008 +++ julius4/libsent/src/hmminfo/rdhmmdef_state.c Tue Sep 30 12:58:18 2008 @@ -12,7 +12,7 @@ * @author Akinobu LEE * @date Wed Feb 16 03:07:44 2005 * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * */ /* @@ -70,14 +70,14 @@ if (new->name != NULL) { /* add index to search index tree */ if (hmm->st_root == NULL) { - hmm->st_root = aptree_make_root_node(new); + hmm->st_root = aptree_make_root_node(new, &(hmm->mroot)); } else { match = aptree_search_data(new->name, hmm->st_root); if (match != NULL && strmatch(match->name, new->name)) { jlog("Error: rdhmmdef_state: ~s \"%s\" is already defined\n", new->name); rderr(NULL); } else { - aptree_add_entry(new->name, new, match->name, &(hmm->st_root)); + aptree_add_entry(new->name, new, match->name, &(hmm->st_root), &(hmm->mroot)); } } } Index: julius4/libsent/src/hmminfo/rdhmmdef_streamweight.c diff -u julius4/libsent/src/hmminfo/rdhmmdef_streamweight.c:1.1 julius4/libsent/src/hmminfo/rdhmmdef_streamweight.c:1.2 --- julius4/libsent/src/hmminfo/rdhmmdef_streamweight.c:1.1 Mon Jul 7 14:50:11 2008 +++ julius4/libsent/src/hmminfo/rdhmmdef_streamweight.c Tue Sep 30 12:58:18 2008 @@ -65,14 +65,14 @@ if (new->name != NULL) { /* add index to search index tree */ if (hmm->sw_root == NULL) { - hmm->sw_root = aptree_make_root_node(new); + hmm->sw_root = aptree_make_root_node(new, &(hmm->mroot)); } else { match = aptree_search_data(new->name, hmm->sw_root); if (match != NULL && strmatch(match->name, new->name)) { jlog("Error: rdhmmdef_streamweight: ~w \"%s\" is already defined\n", new->name); rderr(NULL); } else { - aptree_add_entry(new->name, new, match->name, &(hmm->sw_root)); + aptree_add_entry(new->name, new, match->name, &(hmm->sw_root), &(hmm->mroot)); } } } Index: julius4/libsent/src/hmminfo/rdhmmdef_tiedmix.c diff -u julius4/libsent/src/hmminfo/rdhmmdef_tiedmix.c:1.3 julius4/libsent/src/hmminfo/rdhmmdef_tiedmix.c:1.4 --- julius4/libsent/src/hmminfo/rdhmmdef_tiedmix.c:1.3 Mon Jul 7 14:50:11 2008 +++ julius4/libsent/src/hmminfo/rdhmmdef_tiedmix.c Tue Sep 30 12:58:18 2008 @@ -12,7 +12,7 @@ * @author Akinobu LEE * @date Wed Feb 16 03:25:11 2005 * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * */ /* @@ -60,14 +60,14 @@ { GCODEBOOK *match; if (hmm->codebook_root == NULL) { - hmm->codebook_root = aptree_make_root_node(new); + hmm->codebook_root = aptree_make_root_node(new, &(hmm->mroot)); } else { match = aptree_search_data(new->name, hmm->codebook_root); if (match != NULL && strmatch(match->name, new->name)) { jlog("Error: rdhmmdef_tiedmix: ~s \"%s\" is already defined\n", new->name); rderr(NULL); } else { - aptree_add_entry(new->name, new, match->name, &(hmm->codebook_root)); + aptree_add_entry(new->name, new, match->name, &(hmm->codebook_root), &(hmm->mroot)); } } } Index: julius4/libsent/src/hmminfo/rdhmmdef_trans.c diff -u julius4/libsent/src/hmminfo/rdhmmdef_trans.c:1.2 julius4/libsent/src/hmminfo/rdhmmdef_trans.c:1.3 --- julius4/libsent/src/hmminfo/rdhmmdef_trans.c:1.2 Tue Dec 18 17:45:51 2007 +++ julius4/libsent/src/hmminfo/rdhmmdef_trans.c Tue Sep 30 12:58:18 2008 @@ -17,7 +17,7 @@ * @author Akinobu LEE * @date Wed Feb 16 03:50:55 2005 * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * */ /* @@ -69,14 +69,14 @@ if (new->name != NULL) { /* add index to search index tree */ if (hmm->tr_root == NULL) { - hmm->tr_root = aptree_make_root_node(new); + hmm->tr_root = aptree_make_root_node(new, &(hmm->mroot)); } else { match = aptree_search_data(new->name, hmm->tr_root); if (match != NULL && strmatch(match->name,new->name)) { jlog("Error: rdhmmdef_trans: ~t \"%s\" is already defined\n", new->name); rderr(NULL); } else { - aptree_add_entry(new->name, new, match->name, &(hmm->tr_root)); + aptree_add_entry(new->name, new, match->name, &(hmm->tr_root), &(hmm->mroot)); } } } Index: julius4/libsent/src/hmminfo/rdhmmdef_var.c diff -u julius4/libsent/src/hmminfo/rdhmmdef_var.c:1.2 julius4/libsent/src/hmminfo/rdhmmdef_var.c:1.3 --- julius4/libsent/src/hmminfo/rdhmmdef_var.c:1.2 Tue Dec 18 17:45:51 2007 +++ julius4/libsent/src/hmminfo/rdhmmdef_var.c Tue Sep 30 12:58:18 2008 @@ -12,7 +12,7 @@ * @author Akinobu LEE * @date Wed Feb 16 04:01:38 2005 * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * */ /* @@ -67,14 +67,14 @@ if (new->name != NULL) { /* add index to search index tree */ if (hmm->vr_root == NULL) { - hmm->vr_root = aptree_make_root_node(new); + hmm->vr_root = aptree_make_root_node(new, &(hmm->mroot)); } else { match = aptree_search_data(new->name, hmm->vr_root); if (match != NULL && strmatch(match->name, new->name)) { jlog("Error: rdhmmdef_var: ~v \"%s\" is already defined\n", new->name); rderr(NULL); } else { - aptree_add_entry(new->name, new, match->name, &(hmm->vr_root)); + aptree_add_entry(new->name, new, match->name, &(hmm->vr_root), &(hmm->mroot)); } } } Index: julius4/libsent/src/hmminfo/rdhmmlist.c diff -u julius4/libsent/src/hmminfo/rdhmmlist.c:1.2 julius4/libsent/src/hmminfo/rdhmmlist.c:1.3 --- julius4/libsent/src/hmminfo/rdhmmlist.c:1.2 Tue Dec 18 17:45:51 2007 +++ julius4/libsent/src/hmminfo/rdhmmlist.c Tue Sep 30 12:58:18 2008 @@ -41,7 +41,7 @@ * @author Akinobu LEE * @date Wed Feb 16 04:04:23 2005 * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * */ /* @@ -121,14 +121,14 @@ hmminfo->lgstart = new; /* add index to search index tree */ if (hmminfo->logical_root == NULL) { - hmminfo->logical_root = aptree_make_root_node(new); + hmminfo->logical_root = aptree_make_root_node(new, &(hmminfo->lroot)); } else { match = aptree_search_data(new->name, hmminfo->logical_root); if (match != NULL && strmatch(match->name, new->name)) { jlog("Error: rdhmmlist: line %d: logical HMM \"%s\" duplicated\n", n, new->name); ok_flag = FALSE; } else { - aptree_add_entry(new->name, new, match->name, &(hmminfo->logical_root)); + aptree_add_entry(new->name, new, match->name, &(hmminfo->logical_root), &(hmminfo->lroot)); } } @@ -136,5 +136,6 @@ hmminfo->totallogicalnum = n; free(buf); + return(ok_flag); } Index: julius4/libsent/src/hmminfo/read_binhmmlist.c diff -u /dev/null julius4/libsent/src/hmminfo/read_binhmmlist.c:1.1 --- /dev/null Tue Sep 30 12:58:18 2008 +++ julius4/libsent/src/hmminfo/read_binhmmlist.c Tue Sep 30 12:58:18 2008 @@ -0,0 +1,108 @@ +/** + * @file read_rdhmmlist.c + * + * + * @brief HMMListファイルを読み込む(バイナリ版) + * + * HMMList ファイルは,辞書上の音素表記(トライフォン表記)から + * 実際に定義されている %HMM へのマッピングを行なうファイルです. + * + * HMMListファイルでは,登場しうる音素について,対応する + * HMM 定義の名前を記述します.一行に1つづつ,第1カラムに音素名, + * スペースで区切って第2カラムに定義されている実際の %HMM 名を指定します. + * 第1カラムと第2カラムが全く同じ場合,すなわちその音素名のモデルが直接 + * %HMM として定義されている場合は,第2カラムは省略することができます. + * + * トライフォン使用時は,HMMListファイルで登場しうる全てのトライフォンに + * ついて記述する必要がある点に注意して下さい.もし与えられた認識辞書 + * 上で登場しうるトライフォンがHMMListに記述されていない場合, + * エラーとなります. + * + * + * + * @brief Read in HMMList file from binary format + * + * HMMList file specifies how the phones as described in word dictionary, + * or their context-dependent form, should be mapped to actual defined %HMM. + * + * In HMMList file, the possible phone names and their corresponding %HMM + * name should be specified one per line. The phone name should be put on + * the first column, and its corresponding %HMM name in the HTK %HMM definition + * file should be defined on the second column. If the two strings are + * the same, which occurs when a %HMM of the phone name is directly defined, + * the second column can be omitted. + * + * When using a triphone model, ALL the possible triphones that can appear + * on the given word dictionary should be specified in the HMMList file. + * If some possible triphone are not specified in the HMMList, Julius + * produces error. + * + * + * @author Akinobu LEE + * @date Wed Feb 16 04:04:23 2005 + * + * $Revision: 1.1 $ + * + */ +/* + * Copyright (c) 1991-2007 Kawahara Lab., Kyoto University + * Copyright (c) 2000-2005 Shikano Lab., Nara Institute of Science and Technology + * Copyright (c) 2005-2007 Julius project team, Nagoya Institute of Technology + * All rights reserved + */ + +#include +#include +#include + +static boolean +load_hmmlist_callback(void **data_p, void *data, FILE *fp) +{ + HTK_HMM_INFO *hmminfo = data; + HMM_Logical *new; + int len; + char buf[MAX_HMMNAME_LEN]; + HTK_HMM_Data *d; + + new = (HMM_Logical *)mybmalloc2(sizeof(HMM_Logical), &(hmminfo->lroot)); + if (myfread(&(new->is_pseudo), sizeof(boolean), 1, fp) < 1) return FALSE; + if (myfread(&len, sizeof(int), 1, fp) < 1) return FALSE; + new->name = (char *)mybmalloc2(len, &(hmminfo->lroot)); + if (myfread(new->name, len, 1, fp) < 1) return FALSE; + if (myfread(&len, sizeof(int), 1, fp) < 1) return FALSE; + if (myfread(buf, len, 1, fp) < 1) return FALSE; + if (new->is_pseudo) { + jlog("Error: sorry, pseudo logical phone saving not implemented yet\n"); + return FALSE; + } else { + d = htk_hmmdata_lookup_physical(hmminfo, buf); + if (d == NULL) { + jlog("Error: load_hmmlist_callback: no name \"%s\" in hmmdefs!\n", buf); + return FALSE; + } + new->body.defined = d; + } + new->next = hmminfo->lgstart; + hmminfo->lgstart = new; + + *data_p = new; + + return TRUE; +} + +boolean +load_hmmlist_bin(FILE *fp, HTK_HMM_INFO *hmminfo) +{ + HMM_Logical *l; + int n; + + if (aptree_read(fp, &(hmminfo->logical_root), &(hmminfo->lroot), hmminfo, load_hmmlist_callback) == FALSE) { + jlog("Error: load_hmmlist_bin: failed to read hmmlist from binary file\n"); + return FALSE; + } + n = 0; + for(l=hmminfo->lgstart;l;l=l->next) n++; + hmminfo->totallogicalnum = n; + + return TRUE; +} Index: julius4/libsent/src/hmminfo/write_binhmmlist.c diff -u /dev/null julius4/libsent/src/hmminfo/write_binhmmlist.c:1.1 --- /dev/null Tue Sep 30 12:58:18 2008 +++ julius4/libsent/src/hmminfo/write_binhmmlist.c Tue Sep 30 12:58:18 2008 @@ -0,0 +1,67 @@ +/** + * @file write_hmmlist.c + * + * + * @brief HMMListファイルをバイナリ形式で出力する + * + * + * + * @brief Write HMMList data to binary file + * + * + * + * @author Akinobu LEE + * @date Wed Feb 16 04:04:23 2005 + * + * $Revision: 1.1 $ + * + */ +/* + * Copyright (c) 1991-2007 Kawahara Lab., Kyoto University + * Copyright (c) 2000-2005 Shikano Lab., Nara Institute of Science and Technology + * Copyright (c) 2005-2007 Julius project team, Nagoya Institute of Technology + * All rights reserved + */ + +#include +#include +#include + +static boolean +save_hmmlist_callback(void *data, FILE *fp) +{ + HMM_Logical *l = data; + char *s; + int len; + + if (myfwrite(&(l->is_pseudo), sizeof(boolean), 1, fp) < 1) return FALSE; + len = strlen(l->name) + 1; + if (myfwrite(&len, sizeof(int), 1, fp) < 1) return FALSE; + if (myfwrite(l->name, len, 1, fp) < 1) return FALSE; + if (l->is_pseudo) { + s = l->body.pseudo->name; + } else { + s = l->body.defined->name; + } + len = strlen(s) + 1; + if (myfwrite(&len, sizeof(int), 1, fp) < 1) return FALSE; + if (myfwrite(s, len, 1, fp) < 1) return FALSE; + + return TRUE; +} + +boolean +save_hmmlist_bin(FILE *fp, HTK_HMM_INFO *hmminfo) +{ + /* set mark */ + int x = 0; + if (myfwrite(&x, sizeof(int), 1, fp) < 1) { + jlog("Error: save_hmmlist_bin: failed to write hmmlist to binary file\n"); + return FALSE; + } + if (aptree_write(fp, hmminfo->logical_root, save_hmmlist_callback) == FALSE) { + jlog("Error: save_hmmlist_bin: failed to write hmmlist to binary file\n"); + return FALSE; + } + return TRUE; +} From sumomo @ users.sourceforge.jp Tue Sep 30 12:58:18 2008 From: sumomo @ users.sourceforge.jp (sumomo @ users.sourceforge.jp) Date: Tue, 30 Sep 2008 12:58:18 +0900 Subject: [Julius-cvs 268] CVS update: julius4/libsent/src/util Message-ID: <1222747098.603790.14032.nullmailer@users.sourceforge.jp> Index: julius4/libsent/src/util/aptree.c diff -u julius4/libsent/src/util/aptree.c:1.2 julius4/libsent/src/util/aptree.c:1.3 --- julius4/libsent/src/util/aptree.c:1.2 Tue Dec 18 17:45:54 2007 +++ julius4/libsent/src/util/aptree.c Tue Sep 30 12:58:18 2008 @@ -12,7 +12,7 @@ * @author Akinobu LEE * @date Thu Feb 17 15:21:53 2005 * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * */ /* @@ -32,11 +32,11 @@ * @return pointer to the new node. */ static APATNODE * -new_node() +new_node(BMALLOC_BASE **mroot) { APATNODE *tmp; - tmp = (APATNODE *)mymalloc(sizeof(APATNODE)); + tmp = (APATNODE *)mybmalloc2(sizeof(APATNODE), mroot); tmp->left0 = NULL; tmp->right1 = NULL; @@ -53,6 +53,21 @@ static void * aptree_search_data_r(APATNODE *node, char *str, int maxbitplace) { +#if 1 + /* non-recursive */ + APATNODE *n; + APATNODE *branch = NULL; + n = node; + while(n->left0 != NULL || n->right1 != NULL) { + branch = n; + if (testbit_max(str, n->value.thres_bit, maxbitplace) != 0) { + n = n->right1; + } else { + n = n->left0; + } + } + return(n->value.data); +#else if (node->left0 == NULL && node->right1 == NULL) { return(node->value.data); } else { @@ -62,6 +77,7 @@ return(aptree_search_data_r(node->left0, str, maxbitplace)); } } +#endif } /** @@ -94,11 +110,11 @@ * @return the newly allocated root node. */ APATNODE * -aptree_make_root_node(void *data) +aptree_make_root_node(void *data, BMALLOC_BASE **mroot) { APATNODE *nnew; /* make new leaf node for newstr */ - nnew = new_node(); + nnew = new_node(mroot); nnew->value.data = data; return(nnew); } @@ -112,20 +128,54 @@ * @param parentlink [i/o] the parent node to which this node will be added */ static void -aptree_add_entry_at(char *str, int bitloc, void *data, APATNODE **parentlink) +aptree_add_entry_at(char *str, int slen, int bitloc, void *data, APATNODE **parentlink, BMALLOC_BASE **mroot) { +#if 1 + /* non-recursive */ + APATNODE **p; + APATNODE *newleaf, *newbranch, *node; + + p = parentlink; + node = *p; + while(node->value.thres_bit <= bitloc && + (node->left0 != NULL || node->right1 != NULL)) { + if (testbit(str, slen, node->value.thres_bit) != 0) { + p = &(node->right1); + } else { + p = &(node->left0); + } + node = *p; + } + + /* insert between [parent] and [node] */ + newleaf = new_node(mroot); + newleaf->value.data = data; + newbranch = new_node(mroot); + newbranch->value.thres_bit = bitloc; + *p = newbranch; + if (testbit(str, slen, bitloc) ==0) { + newbranch->left0 = newleaf; + newbranch->right1 = node; + } else { + newbranch->left0 = node; + newbranch->right1 = newleaf; + } + +#else + APATNODE *node; + APATNODE *newleaf, *newbranch; + node = *parentlink; if (node->value.thres_bit > bitloc || (node->left0 == NULL && node->right1 == NULL)) { - APATNODE *newleaf, *newbranch; /* insert between [parent] and [node] */ - newleaf = new_node(); + newleaf = new_node(mroot); newleaf->value.data = data; - newbranch = new_node(); + newbranch = new_node(mroot); newbranch->value.thres_bit = bitloc; *parentlink = newbranch; - if (testbit(str, bitloc) ==0) { + if (testbit(str, slen, bitloc) ==0) { newbranch->left0 = newleaf; newbranch->right1 = node; } else { @@ -134,12 +184,13 @@ } return; } else { - if (testbit(str, node->value.thres_bit) != 0) { - aptree_add_entry_at(str, bitloc, data, &(node->right1)); + if (testbit(str, slen, node->value.thres_bit) != 0) { + aptree_add_entry_at(str, slen, bitloc, data, &(node->right1), mroot); } else { - aptree_add_entry_at(str, bitloc, data, &(node->left0)); + aptree_add_entry_at(str, slen, bitloc, data, &(node->left0), mroot); } } +#endif } /** @@ -152,15 +203,15 @@ * @param rootnode [i/o] pointer to root index node */ void -aptree_add_entry(char *str, void *data, char *matchstr, APATNODE **rootnode) +aptree_add_entry(char *str, void *data, char *matchstr, APATNODE **rootnode, BMALLOC_BASE **mroot) { int bitloc; bitloc = where_the_bit_differ(str, matchstr); if (*rootnode == NULL) { - *rootnode = aptree_make_root_node(data); + *rootnode = aptree_make_root_node(data, mroot); } else { - aptree_add_entry_at(str, bitloc, data, rootnode); + aptree_add_entry_at(str, strlen(str), bitloc, data, rootnode, mroot); } } @@ -184,14 +235,14 @@ /* make sure the data of your removal request already exists before call this */ /* execute removal */ if (up == NULL) { - free(now); + //free(now); *root = NULL; return; } b = (up->right1 == now) ? up->left0 : up->right1; if (up2 == NULL) { - free(now); - free(up); + //free(now); + //free(up); *root = b; return; } @@ -200,8 +251,8 @@ } else { up2->right1 = b; } - free(now); - free(up); + //free(now); + //free(up); return; } else { /* traverse */ @@ -254,16 +305,219 @@ } } -/** - * Free all the sub nodes from specified node. - * - * @param node [in] current node. - */ -void -free_aptree(APATNODE *node) +/*************************************************************/ + +static void +aptree_count(APATNODE *node, int *count_branch, int *count_data, int *maxbit) +{ + if (node->left0 == NULL && node->right1 == NULL) { + (*count_data)++; + } else { + if (node->value.thres_bit > *maxbit) { + *maxbit = node->value.thres_bit; + } + (*count_branch)++; + if (node->left0 != NULL) { + aptree_count(node->left0, count_branch, count_data, maxbit); + } + if (node->right1 != NULL) { + aptree_count(node->right1, count_branch, count_data, maxbit); + } + } +} + +static int +aptree_build_index(APATNODE *node, int *num, int *data_id, int *left, int *right, int *data) +{ + int id; + + id = *num; + (*num)++; + if (node->left0 == NULL && node->right1 == NULL) { + left[id] = -1; + right[id] = -1; + data[id] = *data_id; + /* node->value.data を保存 */ + (*data_id)++; + } else { + data[id] = node->value.thres_bit; + if (node->left0 != NULL) { + left[id] = aptree_build_index(node->left0, num, data_id, left, right, data); + } else { + left[id] = -1; + } + if (node->right1 != NULL) { + right[id] = aptree_build_index(node->right1, num, data_id, left, right, data); + } else { + right[id] = -1; + } + } + return id; +} + +static void +aptree_write_leaf(FILE *fp, APATNODE *node, boolean (*callback)(void *, FILE *fp), boolean *error_p) +{ + if (node->left0 == NULL && node->right1 == NULL) { + if ((*callback)(node->value.data, fp) == FALSE) { + *error_p = TRUE; + } + } else { + if (node->left0 != NULL) { + aptree_write_leaf(fp, node->left0, callback, error_p); + } + if (node->right1 != NULL) { + aptree_write_leaf(fp, node->right1, callback, error_p); + } + } +} + + +boolean +aptree_write(FILE *fp, APATNODE *root, boolean (*save_data_func)(void *, FILE *fp)) +{ + int count_node, count_branch, count_data, maxbit; + int *left, *right, *value; + int num, did; + boolean err; + + if (root == NULL) return TRUE; + + /* count statistics */ + count_branch = count_data = 0; + maxbit = 0; + aptree_count(root, &count_branch, &count_data, &maxbit); + count_node = count_branch + count_data; + jlog("Stat: aptree_write: %d nodes (%d branch + %d data), maxbit=%d\n", count_node, count_branch, count_data, maxbit); + /* allocate */ + left = (int *)mymalloc(sizeof(int) * count_node); + right = (int *)mymalloc(sizeof(int) * count_node); + value = (int *)mymalloc(sizeof(int) * count_node); + /* make index */ + did = num = 0; + aptree_build_index(root, &num, &did, left, right, value); +#if 0 + { + int i; + for(i=0;ileft0 != NULL) free_aptree(node->left0); - if (node->right1 != NULL) free_aptree(node->right1); - free(node); + int count_node, count_branch, count_data, maxbit; + int *left, *right, *value; + int num, did; + boolean err; + APATNODE *nodelist; + APATNODE *node; + int i; + + if (*root != NULL) { + jlog("Error: aptree_read: root node != NULL!\n"); + return FALSE; + } + + /* read header */ + if (myfread(&count_node, sizeof(int), 1, fp) < 1) { + jlog("Error: aptree_read: fail to read header\n"); + return FALSE; + } + if (myfread(&count_data, sizeof(int), 1, fp) < 1) { + jlog("Error: aptree_read: fail to read header\n"); + return FALSE; + } + jlog("Stat: aptree_read: %d nodes (%d branch + %d data)\n", + count_node, count_node - count_data, count_data); + /* prepare buffer */ + left = (int *)mymalloc(sizeof(int) * count_node); + right = (int *)mymalloc(sizeof(int) * count_node); + value = (int *)mymalloc(sizeof(int) * count_node); + /* read data */ + if (myfread(left, sizeof(int), count_node, fp) < count_node) { + jlog("Error: aptree_read: fail to read %d bytes\n", sizeof(int) * count_node); + return FALSE; + } + if (myfread(right, sizeof(int), count_node, fp) < count_node) { + jlog("Error: aptree_read: fail to read %d bytes\n", sizeof(int) * count_node); + return FALSE; + } + if (myfread(value, sizeof(int), count_node, fp) < count_node) { + jlog("Error: aptree_read: fail to read %d bytes\n", sizeof(int) * count_node); + return FALSE; + } + /* allocate nodes */ + nodelist = (APATNODE *)mybmalloc2(sizeof(APATNODE) * count_node, mroot); + for(i=0;ileft0 = NULL; + } else { + node->left0 = &(nodelist[left[i]]); + } + if (right[i] == -1) { + node->right1 = NULL; + } else { + node->right1 = &(nodelist[right[i]]); + } + if (left[i] == -1 && right[i] == -1) { + /* load leaf data node */ + if ((*load_data_func)(&(node->value.data), data, fp) == FALSE) { + jlog("Error: aptree_read: failed to load leaf data entity\n"); + return FALSE; + } + } else { + /* set thres bit */ + node->value.thres_bit = value[i]; + } + } + /* set root node */ + *root = &(nodelist[0]); + + free(value); + free(right); + free(left); + + return TRUE; } Index: julius4/libsent/src/util/ptree.c diff -u julius4/libsent/src/util/ptree.c:1.2 julius4/libsent/src/util/ptree.c:1.3 --- julius4/libsent/src/util/ptree.c:1.2 Tue Dec 18 17:45:54 2007 +++ julius4/libsent/src/util/ptree.c Tue Sep 30 12:58:18 2008 @@ -12,7 +12,7 @@ * @author Akinobu LEE * @date Thu Feb 17 15:34:39 2005 * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * */ /* @@ -37,11 +37,11 @@ * @return the content of tested bit in @a tmp_str, either 0 or 1. */ int -testbit(char *str, int bitplace) +testbit(char *str, int slen, int bitplace) { int maskptr; - if ((maskptr = bitplace >> 3) > strlen(str)) return 0; + if ((maskptr = bitplace >> 3) > slen) return 0; return(str[maskptr] & mbit[bitplace & 7]); } @@ -74,11 +74,14 @@ { int p = 0; int bitloc; + int slen1, slen2; /* step: char, bit */ while(str1[p] == str2[p]) p++; bitloc = p * 8; - while(testbit(str1, bitloc) == testbit(str2, bitloc)) bitloc++; + slen1 = strlen(str1); + slen2 = strlen(str2); + while(testbit(str1, slen1, bitloc) == testbit(str2, slen2, bitloc)) bitloc++; return(bitloc); } @@ -138,7 +141,7 @@ newnum = 0; for (i=0;i=newnum; j--) { - if (testbit(words[j], bitplace) != 0) { + if (testbit(words[j], strlen(words[j]), bitplace) != 0) { p = words[i]; words[i] = words[j]; words[j] = p; tmp = data[i]; data[i] = data[j]; data[j] = tmp; break; @@ -267,7 +270,7 @@ * @param parentlink [i/o] the parent node to which this node will be added */ static void -ptree_add_entry_at(char *str, int bitloc, int data, PATNODE **parentlink) +ptree_add_entry_at(char *str, int slen, int bitloc, int data, PATNODE **parentlink) { PATNODE *node; node = *parentlink; @@ -280,7 +283,7 @@ newbranch = new_node(); newbranch->value.thres_bit = bitloc; *parentlink = newbranch; - if (testbit(str, bitloc) ==0) { + if (testbit(str, slen, bitloc) ==0) { newbranch->left0 = newleaf; newbranch->right1 = node; } else { @@ -289,10 +292,10 @@ } return; } else { - if (testbit(str, node->value.thres_bit) != 0) { - ptree_add_entry_at(str, bitloc, data, &(node->right1)); + if (testbit(str, slen, node->value.thres_bit) != 0) { + ptree_add_entry_at(str, slen, bitloc, data, &(node->right1)); } else { - ptree_add_entry_at(str, bitloc, data, &(node->left0)); + ptree_add_entry_at(str, slen, bitloc, data, &(node->left0)); } } } @@ -315,7 +318,7 @@ if (*rootnode == NULL) { *rootnode = ptree_make_root_node(data); } else { - ptree_add_entry_at(str, bitloc, data, rootnode); + ptree_add_entry_at(str, strlen(str), bitloc, data, rootnode); } } From sumomo @ users.sourceforge.jp Tue Sep 30 12:58:18 2008 From: sumomo @ users.sourceforge.jp (sumomo @ users.sourceforge.jp) Date: Tue, 30 Sep 2008 12:58:18 +0900 Subject: [Julius-cvs 269] CVS update: julius4/libsent/src/voca Message-ID: <1222747098.862785.14050.nullmailer@users.sourceforge.jp> Index: julius4/libsent/src/voca/voca_load_htkdict.c diff -u julius4/libsent/src/voca/voca_load_htkdict.c:1.4 julius4/libsent/src/voca/voca_load_htkdict.c:1.5 --- julius4/libsent/src/voca/voca_load_htkdict.c:1.4 Tue Aug 5 18:50:54 2008 +++ julius4/libsent/src/voca/voca_load_htkdict.c Tue Sep 30 12:58:18 2008 @@ -19,7 +19,7 @@ * @author Akinobu LEE * @date Fri Feb 18 19:43:06 2005 * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * */ /* @@ -143,11 +143,11 @@ buf = (char *)mymalloc(strlen(name) + 1); strcpy(buf, name); if (winfo->errph_root == NULL) { - winfo->errph_root = aptree_make_root_node(buf); + winfo->errph_root = aptree_make_root_node(buf, &(winfo->mroot)); } else { match = aptree_search_data(buf, winfo->errph_root); if (match == NULL || !strmatch(match, buf)) { - aptree_add_entry(buf, buf, match, &(winfo->errph_root)); + aptree_add_entry(buf, buf, match, &(winfo->errph_root), &(winfo->mroot)); } } } Index: julius4/libsent/src/voca/voca_load_wordlist.c diff -u julius4/libsent/src/voca/voca_load_wordlist.c:1.3 julius4/libsent/src/voca/voca_load_wordlist.c:1.4 --- julius4/libsent/src/voca/voca_load_wordlist.c:1.3 Tue Dec 18 17:45:54 2007 +++ julius4/libsent/src/voca/voca_load_wordlist.c Tue Sep 30 12:58:18 2008 @@ -13,7 +13,7 @@ * @author Akinobu LEE * @date Sun Jul 22 13:29:32 2007 * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * */ /* @@ -61,11 +61,11 @@ buf = (char *)mymalloc(strlen(name) + 1); strcpy(buf, name); if (winfo->errph_root == NULL) { - winfo->errph_root = aptree_make_root_node(buf); + winfo->errph_root = aptree_make_root_node(buf, &(winfo->mroot)); } else { match = aptree_search_data(buf, winfo->errph_root); if (match == NULL || !strmatch(match, buf)) { - aptree_add_entry(buf, buf, match, &(winfo->errph_root)); + aptree_add_entry(buf, buf, match, &(winfo->errph_root), &(winfo->mroot)); } } } From sumomo @ users.sourceforge.jp Tue Sep 30 12:58:19 2008 From: sumomo @ users.sourceforge.jp (sumomo @ users.sourceforge.jp) Date: Tue, 30 Sep 2008 12:58:19 +0900 Subject: [Julius-cvs 270] CVS update: julius4/mkbinhmm Message-ID: <1222747099.077028.14061.nullmailer@users.sourceforge.jp> Index: julius4/mkbinhmm/Makefile.in diff -u julius4/mkbinhmm/Makefile.in:1.3 julius4/mkbinhmm/Makefile.in:1.4 --- julius4/mkbinhmm/Makefile.in:1.3 Thu Sep 25 13:49:05 2008 +++ julius4/mkbinhmm/Makefile.in Tue Sep 30 12:58:18 2008 @@ -3,7 +3,7 @@ # Copyright (c) 2005-2007 Julius project team, Nagoya Institute of Technology # All rights reserved # -# $Id: Makefile.in,v 1.3 2008/09/25 04:49:05 sumomo Exp $ +# $Id: Makefile.in,v 1.4 2008/09/30 03:58:18 sumomo Exp $ # SHELL=/bin/sh .SUFFIXES: @@ -21,35 +21,39 @@ exec_prefix=@exec_prefix@ INSTALL=@INSTALL@ -OBJ=mkbinhmm.o -TARGET=mkbinhmm +all: mkbinhmm mkbinhmmlist -all: $(TARGET) +mkbinhmm: mkbinhmm.o $(LIBSENT)/libsent.a + $(CC) $(CFLAGS) $(CPPFLAGS) -o $@ mkbinhmm.o $(LDFLAGS) -$(TARGET): $(OBJ) $(LIBSENT)/libsent.a - $(CC) $(CFLAGS) $(CPPFLAGS) -o $@ $(OBJ) $(LDFLAGS) +mkbinhmmlist: mkbinhmmlist.o $(LIBSENT)/libsent.a + $(CC) $(CFLAGS) $(CPPFLAGS) -o $@ mkbinhmmlist.o $(LDFLAGS) install: install.bin install.man -install.bin: $(TARGET) +install.bin: mkbinhmm mkbinhmmlist ${INSTALL} -d @bindir@ - @INSTALL_PROGRAM@ $(TARGET) @bindir@ + @INSTALL_PROGRAM@ mkbinhmm mkbinhmmlist @bindir@ install.man: ${INSTALL} -d @mandir@/man1 - @INSTALL_DATA@ $(TARGET).man @mandir@/man1/$(TARGET).1 + @INSTALL_DATA@ mkbinhmm.man @mandir@/man1/mkbinhmm.1 + @INSTALL_DATA@ mkbinhmmlist.man @mandir@/man1/mkbinhmmlist.1 install.man.ja: ${INSTALL} -d @mandir@/man1 - @INSTALL_DATA@ $(TARGET).man.ja @mandir@/man1/$(TARGET).1 + @INSTALL_DATA@ mkbinhmm.man.ja @mandir@/man1/mkbinhmm.1 + @INSTALL_DATA@ mkbinhmmlist.man.ja @mandir@/man1/mkbinhmmlist.1 clean: - $(RM) $(OBJ) + $(RM) mkbinhmm.o mkbinhmmlist.o $(RM) *~ core - $(RM) $(TARGET) $(TARGET).exe + $(RM) mkbinhmm mkbinhmm.exe + $(RM) mkbinhmmlist mkbinhmmlist.exe distclean: - $(RM) $(OBJ) + $(RM) mkbinhmm.o mkbinhmmlist.o $(RM) *~ core - $(RM) $(TARGET) $(TARGET).exe + $(RM) mkbinhmm mkbinhmm.exe + $(RM) mkbinhmmlist mkbinhmmlist.exe $(RM) Makefile Index: julius4/mkbinhmm/mkbinhmm.c diff -u julius4/mkbinhmm/mkbinhmm.c:1.3 julius4/mkbinhmm/mkbinhmm.c:1.4 --- julius4/mkbinhmm/mkbinhmm.c:1.3 Mon Jul 7 14:50:12 2008 +++ julius4/mkbinhmm/mkbinhmm.c Tue Sep 30 12:58:18 2008 @@ -7,7 +7,7 @@ /* mkbinhmm --- read in ascii hmmdefs file and write in binary format */ -/* $Id: mkbinhmm.c,v 1.3 2008/07/07 05:50:12 sumomo Exp $ */ +/* $Id: mkbinhmm.c,v 1.4 2008/09/30 03:58:18 sumomo Exp $ */ #include #include @@ -21,7 +21,7 @@ usage(char *s) { printf("mkbinhmm: convert HMM definition file to binary format for Julius\n"); - printf("usage: %s [-C HTKConfig] hmmdefs binhmm\n", s); + printf("usage: %s [-htkconf HTKConfig] hmmdefs binhmm\n", s); printf("\nLibrary configuration: "); confout_version(stdout); confout_am(stdout); Index: julius4/mkbinhmm/mkbinhmmlist.c diff -u /dev/null julius4/mkbinhmm/mkbinhmmlist.c:1.1 --- /dev/null Tue Sep 30 12:58:19 2008 +++ julius4/mkbinhmm/mkbinhmmlist.c Tue Sep 30 12:58:18 2008 @@ -0,0 +1,97 @@ +/* + * Copyright (c) 2003-2007 Kawahara Lab., Kyoto University + * Copyright (c) 2003-2005 Shikano Lab., Nara Institute of Science and Technology + * Copyright (c) 2005-2007 Julius project team, Nagoya Institute of Technology + * All rights reserved + */ + +/* mkbinhmmlist --- read in ascii hmmlist file and write in binary format */ + +/* $Id: mkbinhmmlist.c,v 1.1 2008/09/30 03:58:18 sumomo Exp $ */ + +#include +#include + + +HTK_HMM_INFO *hmminfo; +Value para, para_htk; + + +static void +usage(char *s) +{ + printf("mkbinhmmlist: convert HMMList file to binary format for Julius\n"); + printf("usage: %s hmmdefs hmmlist binhmmlist\n", s); + printf("\nLibrary configuration: "); + confout_version(stdout); + confout_am(stdout); + printf("\n"); +} + + +int +main(int argc, char *argv[]) +{ + FILE *fp; + char *hmmdefs_file; + char *hmmlist_file; + char *outfile; + int i; + + hmmdefs_file = hmmlist_file = outfile = NULL; + for(i=1;i