\doxysection{cont\+\_\+fileseg.\+c}
\label{cont__fileseg_8c_source}\index{src/sphinx\_adtools/cont\_fileseg.c@{src/sphinx\_adtools/cont\_fileseg.c}}

\begin{DoxyCode}{0}
\DoxyCodeLine{00001\ \textcolor{comment}{/*\ -\/*-\/\ c-\/basic-\/offset:\ 4;\ indent-\/tabs-\/mode:\ nil\ -\/*-\/\ */}}
\DoxyCodeLine{00002\ \textcolor{comment}{/*\ ====================================================================}}
\DoxyCodeLine{00003\ \textcolor{comment}{\ *\ Copyright\ (c)\ 1999-\/2001\ Carnegie\ Mellon\ University.\ \ All\ rights}}
\DoxyCodeLine{00004\ \textcolor{comment}{\ *\ reserved.}}
\DoxyCodeLine{00005\ \textcolor{comment}{\ *}}
\DoxyCodeLine{00006\ \textcolor{comment}{\ *\ Redistribution\ and\ use\ in\ source\ and\ binary\ forms,\ with\ or\ without}}
\DoxyCodeLine{00007\ \textcolor{comment}{\ *\ modification,\ are\ permitted\ provided\ that\ the\ following\ conditions}}
\DoxyCodeLine{00008\ \textcolor{comment}{\ *\ are\ met:}}
\DoxyCodeLine{00009\ \textcolor{comment}{\ *}}
\DoxyCodeLine{00010\ \textcolor{comment}{\ *\ 1.\ Redistributions\ of\ source\ code\ must\ retain\ the\ above\ copyright}}
\DoxyCodeLine{00011\ \textcolor{comment}{\ *\ \ \ \ notice,\ this\ list\ of\ conditions\ and\ the\ following\ disclaimer.\ }}
\DoxyCodeLine{00012\ \textcolor{comment}{\ *}}
\DoxyCodeLine{00013\ \textcolor{comment}{\ *\ 2.\ Redistributions\ in\ binary\ form\ must\ reproduce\ the\ above\ copyright}}
\DoxyCodeLine{00014\ \textcolor{comment}{\ *\ \ \ \ notice,\ this\ list\ of\ conditions\ and\ the\ following\ disclaimer\ in}}
\DoxyCodeLine{00015\ \textcolor{comment}{\ *\ \ \ \ the\ documentation\ and/or\ other\ materials\ provided\ with\ the}}
\DoxyCodeLine{00016\ \textcolor{comment}{\ *\ \ \ \ distribution.}}
\DoxyCodeLine{00017\ \textcolor{comment}{\ *}}
\DoxyCodeLine{00018\ \textcolor{comment}{\ *\ This\ work\ was\ supported\ in\ part\ by\ funding\ from\ the\ Defense\ Advanced\ }}
\DoxyCodeLine{00019\ \textcolor{comment}{\ *\ Research\ Projects\ Agency\ and\ the\ National\ Science\ Foundation\ of\ the\ }}
\DoxyCodeLine{00020\ \textcolor{comment}{\ *\ United\ States\ of\ America,\ and\ the\ CMU\ Sphinx\ Speech\ Consortium.}}
\DoxyCodeLine{00021\ \textcolor{comment}{\ *}}
\DoxyCodeLine{00022\ \textcolor{comment}{\ *\ THIS\ SOFTWARE\ IS\ PROVIDED\ BY\ CARNEGIE\ MELLON\ UNIVERSITY\ \`{}\`{}AS\ IS''\ AND\ }}
\DoxyCodeLine{00023\ \textcolor{comment}{\ *\ ANY\ EXPRESSED\ OR\ IMPLIED\ WARRANTIES,\ INCLUDING,\ BUT\ NOT\ LIMITED\ TO,\ }}
\DoxyCodeLine{00024\ \textcolor{comment}{\ *\ THE\ IMPLIED\ WARRANTIES\ OF\ MERCHANTABILITY\ AND\ FITNESS\ FOR\ A\ PARTICULAR}}
\DoxyCodeLine{00025\ \textcolor{comment}{\ *\ PURPOSE\ ARE\ DISCLAIMED.\ \ IN\ NO\ EVENT\ SHALL\ CARNEGIE\ MELLON\ UNIVERSITY}}
\DoxyCodeLine{00026\ \textcolor{comment}{\ *\ NOR\ ITS\ EMPLOYEES\ BE\ LIABLE\ FOR\ ANY\ DIRECT,\ INDIRECT,\ INCIDENTAL,}}
\DoxyCodeLine{00027\ \textcolor{comment}{\ *\ SPECIAL,\ EXEMPLARY,\ OR\ CONSEQUENTIAL\ DAMAGES\ (INCLUDING,\ BUT\ NOT\ }}
\DoxyCodeLine{00028\ \textcolor{comment}{\ *\ LIMITED\ TO,\ PROCUREMENT\ OF\ SUBSTITUTE\ GOODS\ OR\ SERVICES;\ LOSS\ OF\ USE,\ }}
\DoxyCodeLine{00029\ \textcolor{comment}{\ *\ DATA,\ OR\ PROFITS;\ OR\ BUSINESS\ INTERRUPTION)\ HOWEVER\ CAUSED\ AND\ ON\ ANY\ }}
\DoxyCodeLine{00030\ \textcolor{comment}{\ *\ THEORY\ OF\ LIABILITY,\ WHETHER\ IN\ CONTRACT,\ STRICT\ LIABILITY,\ OR\ TORT\ }}
\DoxyCodeLine{00031\ \textcolor{comment}{\ *\ (INCLUDING\ NEGLIGENCE\ OR\ OTHERWISE)\ ARISING\ IN\ ANY\ WAY\ OUT\ OF\ THE\ USE\ }}
\DoxyCodeLine{00032\ \textcolor{comment}{\ *\ OF\ THIS\ SOFTWARE,\ EVEN\ IF\ ADVISED\ OF\ THE\ POSSIBILITY\ OF\ SUCH\ DAMAGE.}}
\DoxyCodeLine{00033\ \textcolor{comment}{\ *}}
\DoxyCodeLine{00034\ \textcolor{comment}{\ *\ ====================================================================}}
\DoxyCodeLine{00035\ \textcolor{comment}{\ *}}
\DoxyCodeLine{00036\ \textcolor{comment}{\ */}}
\DoxyCodeLine{00037\ \textcolor{comment}{/*}}
\DoxyCodeLine{00038\ \textcolor{comment}{\ *\ cont\_fileseg.c\ -\/-\/\ Read\ input\ file,\ filter\ silence\ regions,\ and\ segment\ into\ utterances.}}
\DoxyCodeLine{00039\ \textcolor{comment}{\ *\ }}
\DoxyCodeLine{00040\ \textcolor{comment}{\ *\ HISTORY}}
\DoxyCodeLine{00041\ \textcolor{comment}{\ *\ }}
\DoxyCodeLine{00042\ \textcolor{comment}{\ *\ \$Log:\ cont\_fileseg.c,v\ \$}}
\DoxyCodeLine{00043\ \textcolor{comment}{\ *\ Revision\ 1.1.1.1\ \ 2006/05/23\ 18:45:02\ \ dhuggins}}
\DoxyCodeLine{00044\ \textcolor{comment}{\ *\ re-\/importation}}
\DoxyCodeLine{00045\ \textcolor{comment}{\ *}}
\DoxyCodeLine{00046\ \textcolor{comment}{\ *\ Revision\ 1.13\ \ 2005/06/30\ 00:28:46\ \ rkm}}
\DoxyCodeLine{00047\ \textcolor{comment}{\ *\ Kept\ within-\/utterance\ silences\ in\ rawmode}}
\DoxyCodeLine{00048\ \textcolor{comment}{\ *}}
\DoxyCodeLine{00049\ \textcolor{comment}{\ *\ }}
\DoxyCodeLine{00050\ \textcolor{comment}{\ *\ 28-\/Jun-\/2005\ \ M\ K\ Ravishankar\ (rkm@cs.cmu.edu)\ at\ Carnegie\ Mellon\ University}}
\DoxyCodeLine{00051\ \textcolor{comment}{\ *\ \ \ \ \ \ \ \ \ \ \ \ \ \ Modified\ to\ use\ new\ state\ variables\ in\ cont\_ad\_t.}}
\DoxyCodeLine{00052\ \textcolor{comment}{\ *\ }}
\DoxyCodeLine{00053\ \textcolor{comment}{\ *\ Revision\ 1.12\ \ 2005/05/31\ 15:54:38\ \ rkm}}
\DoxyCodeLine{00054\ \textcolor{comment}{\ *\ ***\ empty\ log\ message\ ***}}
\DoxyCodeLine{00055\ \textcolor{comment}{\ *}}
\DoxyCodeLine{00056\ \textcolor{comment}{\ *\ Revision\ 1.11\ \ 2005/05/24\ 20:56:58\ \ rkm}}
\DoxyCodeLine{00057\ \textcolor{comment}{\ *\ Added\ min/max-\/noise\ parameters\ to\ cont\_fileseg}}
\DoxyCodeLine{00058\ \textcolor{comment}{\ *}}
\DoxyCodeLine{00059\ \textcolor{comment}{\ *\ Revision\ 1.10\ \ 2005/05/13\ 23:28:43\ \ egouvea}}
\DoxyCodeLine{00060\ \textcolor{comment}{\ *\ Changed\ null\ device\ to\ system\ dependent\ one:\ NUL\ for\ windows,\ /dev/null\ for\ everything\ else}}
\DoxyCodeLine{00061\ \textcolor{comment}{\ *\ }}
\DoxyCodeLine{00062\ \textcolor{comment}{\ *\ \$Log:\ cont\_fileseg.c,v\ \$}}
\DoxyCodeLine{00063\ \textcolor{comment}{\ *\ Revision\ 1.1.1.1\ \ 2006/05/23\ 18:45:02\ \ dhuggins}}
\DoxyCodeLine{00064\ \textcolor{comment}{\ *\ re-\/importation}}
\DoxyCodeLine{00065\ \textcolor{comment}{\ *}}
\DoxyCodeLine{00066\ \textcolor{comment}{\ *\ Revision\ 1.13\ \ 2005/06/30\ 00:28:46\ \ rkm}}
\DoxyCodeLine{00067\ \textcolor{comment}{\ *\ Kept\ within-\/utterance\ silences\ in\ rawmode}}
\DoxyCodeLine{00068\ \textcolor{comment}{\ *}}
\DoxyCodeLine{00069\ \textcolor{comment}{\ *\ Revision\ 1.12\ \ 2005/05/31\ 15:54:38\ \ rkm}}
\DoxyCodeLine{00070\ \textcolor{comment}{\ *\ ***\ empty\ log\ message\ ***}}
\DoxyCodeLine{00071\ \textcolor{comment}{\ *}}
\DoxyCodeLine{00072\ \textcolor{comment}{\ *\ Revision\ 1.11\ \ 2005/05/24\ 20:56:58\ \ rkm}}
\DoxyCodeLine{00073\ \textcolor{comment}{\ *\ Added\ min/max-\/noise\ parameters\ to\ cont\_fileseg}}
\DoxyCodeLine{00074\ \textcolor{comment}{\ *}}
\DoxyCodeLine{00075\ \textcolor{comment}{\ *\ Revision\ 1.9\ \ 2005/02/13\ 01:29:48\ \ rkm}}
\DoxyCodeLine{00076\ \textcolor{comment}{\ *\ Fixed\ cont\_ad\_read\ to\ never\ cross\ sil/speech\ boundary,\ and\ rawmode}}
\DoxyCodeLine{00077\ \textcolor{comment}{\ *}}
\DoxyCodeLine{00078\ \textcolor{comment}{\ *\ Revision\ 1.8\ \ 2005/02/01\ 22:21:13\ \ rkm}}
\DoxyCodeLine{00079\ \textcolor{comment}{\ *\ Added\ raw\ data\ logging,\ and\ raw\ data\ pass-\/through\ mode\ to\ cont\_ad}}
\DoxyCodeLine{00080\ \textcolor{comment}{\ *}}
\DoxyCodeLine{00081\ \textcolor{comment}{\ *\ Revision\ 1.7\ \ 2004/07/16\ 00:57:11\ \ egouvea}}
\DoxyCodeLine{00082\ \textcolor{comment}{\ *\ Added\ Ravi's\ implementation\ of\ FSG\ support.}}
\DoxyCodeLine{00083\ \textcolor{comment}{\ *}}
\DoxyCodeLine{00084\ \textcolor{comment}{\ *\ Revision\ 1.3\ \ 2004/06/25\ 14:58:05\ \ rkm}}
\DoxyCodeLine{00085\ \textcolor{comment}{\ *\ ***\ empty\ log\ message\ ***}}
\DoxyCodeLine{00086\ \textcolor{comment}{\ *}}
\DoxyCodeLine{00087\ \textcolor{comment}{\ *\ Revision\ 1.2\ \ 2004/06/23\ 20:32:08\ \ rkm}}
\DoxyCodeLine{00088\ \textcolor{comment}{\ *\ Exposed\ several\ cont\_ad\ config\ parameters}}
\DoxyCodeLine{00089\ \textcolor{comment}{\ *}}
\DoxyCodeLine{00090\ \textcolor{comment}{\ *\ }}
\DoxyCodeLine{00091\ \textcolor{comment}{\ *\ 27-\/Jun-\/96\ \ \ \ M\ K\ Ravishankar\ (rkm@cs.cmu.edu)\ at\ Carnegie\ Mellon\ University}}
\DoxyCodeLine{00092\ \textcolor{comment}{\ *\ \ \ \ \ \ \ \ \ \ \ \ \ \ Created.}}
\DoxyCodeLine{00093\ \textcolor{comment}{\ */}}
\DoxyCodeLine{00094\ }
\DoxyCodeLine{00095\ \textcolor{preprocessor}{\#include\ <stdio.h>}}
\DoxyCodeLine{00096\ \textcolor{preprocessor}{\#include\ <stdlib.h>}}
\DoxyCodeLine{00097\ \textcolor{preprocessor}{\#include\ <string.h>}}
\DoxyCodeLine{00098\ \textcolor{preprocessor}{\#include\ <assert.h>}}
\DoxyCodeLine{00099\ \textcolor{preprocessor}{\#include\ <math.h>}}
\DoxyCodeLine{00100\ }
\DoxyCodeLine{00101\ \textcolor{preprocessor}{\#include\ <sphinxbase/prim\_type.h>}}
\DoxyCodeLine{00102\ \textcolor{preprocessor}{\#include\ <sphinxbase/ad.h>}}
\DoxyCodeLine{00103\ \textcolor{preprocessor}{\#include\ <sphinxbase/cont\_ad.h>}}
\DoxyCodeLine{00104\ \textcolor{preprocessor}{\#include\ <sphinxbase/err.h>}}
\DoxyCodeLine{00105\ }
\DoxyCodeLine{00106\ \textcolor{keyword}{static}\ FILE\ *infp;\ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{comment}{/*\ File\ being\ segmented\ */}}
\DoxyCodeLine{00107\ \textcolor{keyword}{static}\ int32\ swap;}
\DoxyCodeLine{00108\ }
\DoxyCodeLine{00109\ \textcolor{comment}{/*\ Max\ size\ read\ by\ file\_ad\_read\ function\ on\ each\ invocation,\ for\ debugging\ */}}
\DoxyCodeLine{00110\ \textcolor{keyword}{static}\ int32\ max\_ad\_read\_size;}
\DoxyCodeLine{00111\ }
\DoxyCodeLine{00112\ \textcolor{preprocessor}{\#if\ defined(WIN32)\ \&\&\ !defined(GNUWINCE)}}
\DoxyCodeLine{00113\ \textcolor{preprocessor}{\#define\ NULL\_DEVICE\ "{}NUL"{}}}
\DoxyCodeLine{00114\ \textcolor{preprocessor}{\#else}}
\DoxyCodeLine{00115\ \textcolor{preprocessor}{\#define\ NULL\_DEVICE\ "{}/dev/null"{}}}
\DoxyCodeLine{00116\ \textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{00117\ }
\DoxyCodeLine{00118\ }
\DoxyCodeLine{00119\ \textcolor{comment}{/*}}
\DoxyCodeLine{00120\ \textcolor{comment}{\ *\ Need\ to\ provide\ cont\_ad\_init\ with\ a\ read\ function\ to\ read\ the\ input\ file.}}
\DoxyCodeLine{00121\ \textcolor{comment}{\ *\ This\ is\ it.\ \ The\ ad\_rec\_t\ *r\ argument\ is\ ignored\ since\ there\ is\ no\ A/D}}
\DoxyCodeLine{00122\ \textcolor{comment}{\ *\ device\ involved.}}
\DoxyCodeLine{00123\ \textcolor{comment}{\ */}}
\DoxyCodeLine{00124\ \textcolor{keyword}{static}\ int32}
\DoxyCodeLine{00125\ file\_ad\_read(ad\_rec\_t\ *\ r,\ int16\ *\ buf,\ int32\ max)}
\DoxyCodeLine{00126\ \{}
\DoxyCodeLine{00127\ \ \ \ \ int32\ i,\ k;}
\DoxyCodeLine{00128\ }
\DoxyCodeLine{00129\ \ \ \ \ \textcolor{keywordflow}{if}\ (max\ >\ max\_ad\_read\_size)}
\DoxyCodeLine{00130\ \ \ \ \ \ \ \ \ max\ =\ max\_ad\_read\_size;}
\DoxyCodeLine{00131\ }
\DoxyCodeLine{00132\ \ \ \ \ k\ =\ fread(buf,\ \textcolor{keyword}{sizeof}(int16),\ max,\ infp);}
\DoxyCodeLine{00133\ \ \ \ \ \textcolor{keywordflow}{if}\ (swap)\ \{}
\DoxyCodeLine{00134\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{for}\ (i\ =\ 0;\ i\ <\ k;\ i++)\ \{}
\DoxyCodeLine{00135\ \ \ \ \ \ \ \ \ \ \ \ \ buf[i]\ =\ ((buf[i]\ >>\ 8)\ \&\ 0x00ff)\ |\ ((buf[i]\ <<\ 8)\ \&\ 0xff00);}
\DoxyCodeLine{00136\ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00137\ \ \ \ \ \}}
\DoxyCodeLine{00138\ }
\DoxyCodeLine{00139\ \ \ \ \ \textcolor{keywordflow}{return}\ ((k\ >\ 0)\ ?\ k\ :\ -\/1);}
\DoxyCodeLine{00140\ \}}
\DoxyCodeLine{00141\ }
\DoxyCodeLine{00142\ }
\DoxyCodeLine{00143\ \textcolor{keyword}{static}\ \textcolor{keywordtype}{void}}
\DoxyCodeLine{00144\ usagemsg(\textcolor{keywordtype}{char}\ *pgm)}
\DoxyCodeLine{00145\ \{}
\DoxyCodeLine{00146\ \ \ \ \ E\_INFO(\textcolor{stringliteral}{"{}Usage:\ \%s\ \(\backslash\)\(\backslash\)\(\backslash\)n"{}},\ pgm);}
\DoxyCodeLine{00147\ \ \ \ \ E\_INFOCONT(\textcolor{stringliteral}{"{}\(\backslash\)t[-\/?\ |\ -\/h]\ \(\backslash\)\(\backslash\)\(\backslash\)n"{}});}
\DoxyCodeLine{00148\ \ \ \ \ E\_INFOCONT(\textcolor{stringliteral}{"{}\(\backslash\)t[-\/d\ |\ -\/debug]\ \(\backslash\)\(\backslash\)\(\backslash\)n"{}});}
\DoxyCodeLine{00149\ \ \ \ \ E\_INFOCONT(\textcolor{stringliteral}{"{}\(\backslash\)t[-\/sps\ <sampling-\/rate>\ (16000)]\ \(\backslash\)\(\backslash\)\(\backslash\)n"{}});}
\DoxyCodeLine{00150\ \ \ \ \ E\_INFOCONT(\textcolor{stringliteral}{"{}\(\backslash\)t[-\/b\ |\ -\/byteswap]\ \(\backslash\)\(\backslash\)\(\backslash\)n"{}});}
\DoxyCodeLine{00151\ \ \ \ \ E\_INFOCONT}
\DoxyCodeLine{00152\ \ \ \ \ \ \ \ \ (\textcolor{stringliteral}{"{}\(\backslash\)t[\{-\/s\ |\ -\/silsep\}\ <length-\/silence-\/separator(sec)\ (0.5)]>\ \(\backslash\)\(\backslash\)\(\backslash\)n"{}});}
\DoxyCodeLine{00153\ \ \ \ \ E\_INFOCONT(\textcolor{stringliteral}{"{}\(\backslash\)t[-\/w\ |\ -\/writeseg]\ \(\backslash\)\(\backslash\)\(\backslash\)n"{}});}
\DoxyCodeLine{00154\ \ \ \ \ E\_INFOCONT(\textcolor{stringliteral}{"{}\(\backslash\)t[-\/min-\/noise\ <min-\/noise>]\ \(\backslash\)\(\backslash\)\(\backslash\)n"{}});}
\DoxyCodeLine{00155\ \ \ \ \ E\_INFOCONT(\textcolor{stringliteral}{"{}\(\backslash\)t[-\/max-\/noise\ <max-\/noise>]\ \(\backslash\)\(\backslash\)\(\backslash\)n"{}});}
\DoxyCodeLine{00156\ \ \ \ \ E\_INFOCONT(\textcolor{stringliteral}{"{}\(\backslash\)t[-\/delta-\/sil\ <delta-\/sil>]\ \(\backslash\)\(\backslash\)\(\backslash\)n"{}});}
\DoxyCodeLine{00157\ \ \ \ \ E\_INFOCONT(\textcolor{stringliteral}{"{}\(\backslash\)t[-\/delta-\/speech\ <delta-\/speech>]\ \(\backslash\)\(\backslash\)\(\backslash\)n"{}});}
\DoxyCodeLine{00158\ \ \ \ \ E\_INFOCONT(\textcolor{stringliteral}{"{}\(\backslash\)t[-\/sil-\/onset\ <sil-\/onset>]\ \(\backslash\)\(\backslash\)\(\backslash\)n"{}});}
\DoxyCodeLine{00159\ \ \ \ \ E\_INFOCONT(\textcolor{stringliteral}{"{}\(\backslash\)t[-\/speech-\/onset\ <speech-\/onset>]\ \(\backslash\)\(\backslash\)\(\backslash\)n"{}});}
\DoxyCodeLine{00160\ \ \ \ \ E\_INFOCONT(\textcolor{stringliteral}{"{}\(\backslash\)t[-\/adapt-\/rate\ <adapt-\/rate>]\ \(\backslash\)\(\backslash\)\(\backslash\)n"{}});}
\DoxyCodeLine{00161\ \ \ \ \ E\_INFOCONT(\textcolor{stringliteral}{"{}\(\backslash\)t[-\/max-\/adreadsize\ <ad\_read\_blksize>]\ \(\backslash\)\(\backslash\)\(\backslash\)n"{}});}
\DoxyCodeLine{00162\ \ \ \ \ E\_INFOCONT(\textcolor{stringliteral}{"{}\(\backslash\)t[-\/c\ <copy-\/input-\/file>]\ \(\backslash\)\(\backslash\)\(\backslash\)n"{}});}
\DoxyCodeLine{00163\ \ \ \ \ E\_INFOCONT(\textcolor{stringliteral}{"{}\(\backslash\)t[-\/r\ |\ -\/rawmode]\ \(\backslash\)\(\backslash\)\(\backslash\)n"{}});}
\DoxyCodeLine{00164\ \ \ \ \ E\_INFOCONT(\textcolor{stringliteral}{"{}\(\backslash\)t-\/i\ <input-\/file>\(\backslash\)n"{}});}
\DoxyCodeLine{00165\ }
\DoxyCodeLine{00166\ \ \ \ \ exit(0);}
\DoxyCodeLine{00167\ \}}
\DoxyCodeLine{00168\ }
\DoxyCodeLine{00169\ \textcolor{comment}{/*}}
\DoxyCodeLine{00170\ \textcolor{comment}{\ *\ Read\ specified\ input\ file,\ segment\ it\ into\ utterances\ wherever\ a\ silence\ segment\ of}}
\DoxyCodeLine{00171\ \textcolor{comment}{\ *\ a\ given\ minimum\ duration\ is\ encountered.\ \ Filter\ out\ long\ silences.}}
\DoxyCodeLine{00172\ \textcolor{comment}{\ *\ Utterances\ are\ written\ to\ files\ named\ 00000000.raw,\ 00000001.raw,\ 00000002.raw,\ etc.}}
\DoxyCodeLine{00173\ \textcolor{comment}{\ */}}
\DoxyCodeLine{00174\ \textcolor{keywordtype}{int}}
\DoxyCodeLine{00175\ main(int32\ argc,\ \textcolor{keywordtype}{char}\ **argv)}
\DoxyCodeLine{00176\ \{}
\DoxyCodeLine{00177\ \ \ \ \ cont\_ad\_t\ *cont;}
\DoxyCodeLine{00178\ \ \ \ \ int32\ uttid,\ uttlen,\ starttime,\ siltime,\ sps,\ debug,\ writeseg,\ rawmode;}
\DoxyCodeLine{00179\ \ \ \ \ int16\ buf[4096];}
\DoxyCodeLine{00180\ \ \ \ \ \textcolor{keywordtype}{char}\ *infile,\ *copyfile,\ segfile[1024];}
\DoxyCodeLine{00181\ \ \ \ \ FILE\ *fp;}
\DoxyCodeLine{00182\ \ \ \ \ \textcolor{keywordtype}{float}\ endsil;}
\DoxyCodeLine{00183\ \ \ \ \ ad\_rec\_t\ ad;}
\DoxyCodeLine{00184\ \ \ \ \ int32\ i,\ k;}
\DoxyCodeLine{00185\ \ \ \ \ int32\ winsize,\ leader,\ trailer;}
\DoxyCodeLine{00186\ \ \ \ \ int32\ orig\_min\_noise,\ orig\_max\_noise;}
\DoxyCodeLine{00187\ \ \ \ \ int32\ orig\_delta\_sil,\ orig\_delta\_speech;}
\DoxyCodeLine{00188\ \ \ \ \ int32\ orig\_speech\_onset,\ orig\_sil\_onset;}
\DoxyCodeLine{00189\ \ \ \ \ int32\ min\_noise,\ max\_noise;}
\DoxyCodeLine{00190\ \ \ \ \ int32\ delta\_sil,\ delta\_speech;}
\DoxyCodeLine{00191\ \ \ \ \ int32\ sil\_onset,\ speech\_onset;}
\DoxyCodeLine{00192\ \ \ \ \ float32\ orig\_adapt\_rate;}
\DoxyCodeLine{00193\ \ \ \ \ float32\ adapt\_rate;}
\DoxyCodeLine{00194\ \ \ \ \ int32\ total\_speech\_samples;}
\DoxyCodeLine{00195\ \ \ \ \ float32\ total\_speech\_sec;}
\DoxyCodeLine{00196\ \ \ \ \ FILE\ *rawfp;}
\DoxyCodeLine{00197\ }
\DoxyCodeLine{00198\ \ \ \ \ \textcolor{comment}{/*\ Set\ argument\ defaults\ */}}
\DoxyCodeLine{00199\ \ \ \ \ cont\ =\ NULL;}
\DoxyCodeLine{00200\ \ \ \ \ sps\ =\ 16000;}
\DoxyCodeLine{00201\ \ \ \ \ swap\ =\ 0;}
\DoxyCodeLine{00202\ \ \ \ \ endsil\ =\ 0.5;}
\DoxyCodeLine{00203\ \ \ \ \ writeseg\ =\ 0;}
\DoxyCodeLine{00204\ \ \ \ \ min\_noise\ =\ max\_noise\ =\ -\/1;}
\DoxyCodeLine{00205\ \ \ \ \ delta\_sil\ =\ delta\_speech\ =\ -\/1;}
\DoxyCodeLine{00206\ \ \ \ \ sil\_onset\ =\ speech\_onset\ =\ -\/1;}
\DoxyCodeLine{00207\ \ \ \ \ adapt\_rate\ =\ -\/1.0;}
\DoxyCodeLine{00208\ \ \ \ \ max\_ad\_read\_size\ =\ (int32)\ 0x7ffffff0;}
\DoxyCodeLine{00209\ \ \ \ \ debug\ =\ 0;}
\DoxyCodeLine{00210\ \ \ \ \ infile\ =\ NULL;}
\DoxyCodeLine{00211\ \ \ \ \ copyfile\ =\ NULL;}
\DoxyCodeLine{00212\ \ \ \ \ rawfp\ =\ NULL;}
\DoxyCodeLine{00213\ \ \ \ \ rawmode\ =\ 0;}
\DoxyCodeLine{00214\ }
\DoxyCodeLine{00215\ \ \ \ \ \textcolor{comment}{/*\ Parse\ arguments\ */}}
\DoxyCodeLine{00216\ \ \ \ \ \textcolor{keywordflow}{for}\ (i\ =\ 1;\ i\ <\ argc;\ i++)\ \{}
\DoxyCodeLine{00217\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ ((strcmp(argv[i],\ \textcolor{stringliteral}{"{}-\/help"{}})\ ==\ 0)}
\DoxyCodeLine{00218\ \ \ \ \ \ \ \ \ \ \ \ \ ||\ (strcmp(argv[i],\ \textcolor{stringliteral}{"{}-\/h"{}})\ ==\ 0)}
\DoxyCodeLine{00219\ \ \ \ \ \ \ \ \ \ \ \ \ ||\ (strcmp(argv[i],\ \textcolor{stringliteral}{"{}-\/?"{}})\ ==\ 0))\ \{}
\DoxyCodeLine{00220\ \ \ \ \ \ \ \ \ \ \ \ \ usagemsg(argv[0]);}
\DoxyCodeLine{00221\ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00222\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{else}\ \textcolor{keywordflow}{if}\ ((strcmp(argv[i],\ \textcolor{stringliteral}{"{}-\/debug"{}})\ ==\ 0)}
\DoxyCodeLine{00223\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ ||\ (strcmp(argv[i],\ \textcolor{stringliteral}{"{}-\/d"{}})\ ==\ 0))\ \{}
\DoxyCodeLine{00224\ \ \ \ \ \ \ \ \ \ \ \ \ debug\ =\ 1;}
\DoxyCodeLine{00225\ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00226\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{else}\ \textcolor{keywordflow}{if}\ (strcmp(argv[i],\ \textcolor{stringliteral}{"{}-\/sps"{}})\ ==\ 0)\ \{}
\DoxyCodeLine{00227\ \ \ \ \ \ \ \ \ \ \ \ \ i++;}
\DoxyCodeLine{00228\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ ((i\ ==\ argc)}
\DoxyCodeLine{00229\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ ||\ (sscanf(argv[i],\ \textcolor{stringliteral}{"{}\%d"{}},\ \&sps)\ !=\ 1)}
\DoxyCodeLine{00230\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ ||\ (sps\ <=\ 0))\ \{}
\DoxyCodeLine{00231\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ E\_ERROR(\textcolor{stringliteral}{"{}Invalid\ -\/sps\ argument\(\backslash\)n"{}});}
\DoxyCodeLine{00232\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ usagemsg(argv[0]);}
\DoxyCodeLine{00233\ \ \ \ \ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00234\ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00235\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{else}\ \textcolor{keywordflow}{if}\ ((strcmp(argv[i],\ \textcolor{stringliteral}{"{}-\/byteswap"{}})\ ==\ 0)}
\DoxyCodeLine{00236\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ ||\ (strcmp(argv[i],\ \textcolor{stringliteral}{"{}-\/b"{}})\ ==\ 0))\ \{}
\DoxyCodeLine{00237\ \ \ \ \ \ \ \ \ \ \ \ \ swap\ =\ 1;}
\DoxyCodeLine{00238\ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00239\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{else}\ \textcolor{keywordflow}{if}\ ((strcmp(argv[i],\ \textcolor{stringliteral}{"{}-\/silsep"{}})\ ==\ 0)}
\DoxyCodeLine{00240\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ ||\ (strcmp(argv[i],\ \textcolor{stringliteral}{"{}-\/s"{}})\ ==\ 0))\ \{}
\DoxyCodeLine{00241\ \ \ \ \ \ \ \ \ \ \ \ \ i++;}
\DoxyCodeLine{00242\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ ((i\ ==\ argc)}
\DoxyCodeLine{00243\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ ||\ (sscanf(argv[i],\ \textcolor{stringliteral}{"{}\%f"{}},\ \&endsil)\ !=\ 1)}
\DoxyCodeLine{00244\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ ||\ (endsil\ <=\ 0.0))\ \{}
\DoxyCodeLine{00245\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ E\_ERROR(\textcolor{stringliteral}{"{}Invalid\ -\/silsep\ argument\(\backslash\)n"{}});}
\DoxyCodeLine{00246\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ usagemsg(argv[0]);}
\DoxyCodeLine{00247\ \ \ \ \ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00248\ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00249\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{else}\ \textcolor{keywordflow}{if}\ ((strcmp(argv[i],\ \textcolor{stringliteral}{"{}-\/writeseg"{}})\ ==\ 0)}
\DoxyCodeLine{00250\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ ||\ (strcmp(argv[i],\ \textcolor{stringliteral}{"{}-\/w"{}})\ ==\ 0))\ \{}
\DoxyCodeLine{00251\ \ \ \ \ \ \ \ \ \ \ \ \ writeseg\ =\ 1;}
\DoxyCodeLine{00252\ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00253\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{else}\ \textcolor{keywordflow}{if}\ (strcmp(argv[i],\ \textcolor{stringliteral}{"{}-\/min-\/noise"{}})\ ==\ 0)\ \{}
\DoxyCodeLine{00254\ \ \ \ \ \ \ \ \ \ \ \ \ i++;}
\DoxyCodeLine{00255\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ ((i\ ==\ argc)\ ||}
\DoxyCodeLine{00256\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ (sscanf(argv[i],\ \textcolor{stringliteral}{"{}\%d"{}},\ \&min\_noise)\ !=\ 1)\ ||}
\DoxyCodeLine{00257\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ (min\_noise\ <\ 0))\ \{}
\DoxyCodeLine{00258\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ E\_ERROR(\textcolor{stringliteral}{"{}Invalid\ -\/min-\/noise\ argument\(\backslash\)n"{}});}
\DoxyCodeLine{00259\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ usagemsg(argv[0]);}
\DoxyCodeLine{00260\ \ \ \ \ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00261\ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00262\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{else}\ \textcolor{keywordflow}{if}\ (strcmp(argv[i],\ \textcolor{stringliteral}{"{}-\/max-\/noise"{}})\ ==\ 0)\ \{}
\DoxyCodeLine{00263\ \ \ \ \ \ \ \ \ \ \ \ \ i++;}
\DoxyCodeLine{00264\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ ((i\ ==\ argc)\ ||}
\DoxyCodeLine{00265\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ (sscanf(argv[i],\ \textcolor{stringliteral}{"{}\%d"{}},\ \&max\_noise)\ !=\ 1)\ ||}
\DoxyCodeLine{00266\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ (max\_noise\ <\ 0))\ \{}
\DoxyCodeLine{00267\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ E\_ERROR(\textcolor{stringliteral}{"{}Invalid\ -\/max-\/noise\ argument\(\backslash\)n"{}});}
\DoxyCodeLine{00268\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ usagemsg(argv[0]);}
\DoxyCodeLine{00269\ \ \ \ \ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00270\ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00271\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{else}\ \textcolor{keywordflow}{if}\ (strcmp(argv[i],\ \textcolor{stringliteral}{"{}-\/delta-\/sil"{}})\ ==\ 0)\ \{}
\DoxyCodeLine{00272\ \ \ \ \ \ \ \ \ \ \ \ \ i++;}
\DoxyCodeLine{00273\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ ((i\ ==\ argc)\ ||}
\DoxyCodeLine{00274\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ (sscanf(argv[i],\ \textcolor{stringliteral}{"{}\%d"{}},\ \&delta\_sil)\ !=\ 1)\ ||}
\DoxyCodeLine{00275\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ (delta\_sil\ <\ 0))\ \{}
\DoxyCodeLine{00276\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ E\_ERROR(\textcolor{stringliteral}{"{}Invalid\ -\/delta-\/sil\ argument\(\backslash\)n"{}});}
\DoxyCodeLine{00277\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ usagemsg(argv[0]);}
\DoxyCodeLine{00278\ \ \ \ \ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00279\ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00280\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{else}\ \textcolor{keywordflow}{if}\ (strcmp(argv[i],\ \textcolor{stringliteral}{"{}-\/delta-\/speech"{}})\ ==\ 0)\ \{}
\DoxyCodeLine{00281\ \ \ \ \ \ \ \ \ \ \ \ \ i++;}
\DoxyCodeLine{00282\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ ((i\ ==\ argc)\ ||}
\DoxyCodeLine{00283\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ (sscanf(argv[i],\ \textcolor{stringliteral}{"{}\%d"{}},\ \&delta\_speech)\ !=\ 1)\ ||}
\DoxyCodeLine{00284\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ (delta\_speech\ <\ 0))\ \{}
\DoxyCodeLine{00285\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ E\_ERROR(\textcolor{stringliteral}{"{}Invalid\ -\/delta-\/speech\ argument\(\backslash\)n"{}});}
\DoxyCodeLine{00286\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ usagemsg(argv[0]);}
\DoxyCodeLine{00287\ \ \ \ \ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00288\ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00289\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{else}\ \textcolor{keywordflow}{if}\ (strcmp(argv[i],\ \textcolor{stringliteral}{"{}-\/sil-\/onset"{}})\ ==\ 0)\ \{}
\DoxyCodeLine{00290\ \ \ \ \ \ \ \ \ \ \ \ \ i++;}
\DoxyCodeLine{00291\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ ((i\ ==\ argc)\ ||}
\DoxyCodeLine{00292\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ (sscanf(argv[i],\ \textcolor{stringliteral}{"{}\%d"{}},\ \&sil\_onset)\ !=\ 1)\ ||}
\DoxyCodeLine{00293\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ (sil\_onset\ <\ 1))\ \{}
\DoxyCodeLine{00294\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ E\_ERROR(\textcolor{stringliteral}{"{}Invalid\ -\/sil-\/onset\ argument\(\backslash\)n"{}});}
\DoxyCodeLine{00295\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ usagemsg(argv[0]);}
\DoxyCodeLine{00296\ \ \ \ \ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00297\ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00298\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{else}\ \textcolor{keywordflow}{if}\ (strcmp(argv[i],\ \textcolor{stringliteral}{"{}-\/speech-\/onset"{}})\ ==\ 0)\ \{}
\DoxyCodeLine{00299\ \ \ \ \ \ \ \ \ \ \ \ \ i++;}
\DoxyCodeLine{00300\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ ((i\ ==\ argc)\ ||}
\DoxyCodeLine{00301\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ (sscanf(argv[i],\ \textcolor{stringliteral}{"{}\%d"{}},\ \&speech\_onset)\ !=\ 1)\ ||}
\DoxyCodeLine{00302\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ (speech\_onset\ <\ 1))\ \{}
\DoxyCodeLine{00303\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ E\_ERROR(\textcolor{stringliteral}{"{}Invalid\ -\/speech-\/onset\ argument\(\backslash\)n"{}});}
\DoxyCodeLine{00304\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ usagemsg(argv[0]);}
\DoxyCodeLine{00305\ \ \ \ \ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00306\ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00307\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{else}\ \textcolor{keywordflow}{if}\ (strcmp(argv[i],\ \textcolor{stringliteral}{"{}-\/adapt-\/rate"{}})\ ==\ 0)\ \{}
\DoxyCodeLine{00308\ \ \ \ \ \ \ \ \ \ \ \ \ i++;}
\DoxyCodeLine{00309\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ ((i\ ==\ argc)\ ||}
\DoxyCodeLine{00310\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ (sscanf(argv[i],\ \textcolor{stringliteral}{"{}\%f"{}},\ \&adapt\_rate)\ !=\ 1)\ ||}
\DoxyCodeLine{00311\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ (adapt\_rate\ <\ 0.0)\ ||\ (adapt\_rate\ >\ 1.0))\ \{}
\DoxyCodeLine{00312\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ E\_ERROR(\textcolor{stringliteral}{"{}Invalid\ -\/adapt-\/rate\ argument\(\backslash\)n"{}});}
\DoxyCodeLine{00313\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ usagemsg(argv[0]);}
\DoxyCodeLine{00314\ \ \ \ \ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00315\ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00316\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{else}\ \textcolor{keywordflow}{if}\ (strcmp(argv[i],\ \textcolor{stringliteral}{"{}-\/max-\/adreadsize"{}})\ ==\ 0)\ \{}
\DoxyCodeLine{00317\ \ \ \ \ \ \ \ \ \ \ \ \ i++;}
\DoxyCodeLine{00318\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ ((i\ ==\ argc)\ ||}
\DoxyCodeLine{00319\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ (sscanf(argv[i],\ \textcolor{stringliteral}{"{}\%d"{}},\ \&max\_ad\_read\_size)\ !=\ 1)\ ||}
\DoxyCodeLine{00320\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ (max\_ad\_read\_size\ <\ 1))\ \{}
\DoxyCodeLine{00321\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ E\_ERROR(\textcolor{stringliteral}{"{}Invalid\ -\/max-\/adreadsize\ argument\(\backslash\)n"{}});}
\DoxyCodeLine{00322\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ usagemsg(argv[0]);}
\DoxyCodeLine{00323\ \ \ \ \ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00324\ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00325\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{else}\ \textcolor{keywordflow}{if}\ (strcmp(argv[i],\ \textcolor{stringliteral}{"{}-\/c"{}})\ ==\ 0)\ \{}
\DoxyCodeLine{00326\ \ \ \ \ \ \ \ \ \ \ \ \ i++;}
\DoxyCodeLine{00327\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (i\ ==\ argc)\ \{}
\DoxyCodeLine{00328\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ E\_ERROR(\textcolor{stringliteral}{"{}Invalid\ -\/c\ argument\(\backslash\)n"{}});}
\DoxyCodeLine{00329\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ usagemsg(argv[0]);}
\DoxyCodeLine{00330\ \ \ \ \ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00331\ \ \ \ \ \ \ \ \ \ \ \ \ copyfile\ =\ argv[i];}
\DoxyCodeLine{00332\ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00333\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{else}\ \textcolor{keywordflow}{if}\ ((strcmp(argv[i],\ \textcolor{stringliteral}{"{}-\/rawmode"{}})\ ==\ 0)}
\DoxyCodeLine{00334\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ ||\ (strcmp(argv[i],\ \textcolor{stringliteral}{"{}-\/r"{}})\ ==\ 0))\ \{}
\DoxyCodeLine{00335\ \ \ \ \ \ \ \ \ \ \ \ \ rawmode\ =\ 1;}
\DoxyCodeLine{00336\ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00337\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{else}\ \textcolor{keywordflow}{if}\ (strcmp(argv[i],\ \textcolor{stringliteral}{"{}-\/i"{}})\ ==\ 0)\ \{}
\DoxyCodeLine{00338\ \ \ \ \ \ \ \ \ \ \ \ \ i++;}
\DoxyCodeLine{00339\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (i\ ==\ argc)\ \{}
\DoxyCodeLine{00340\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ E\_ERROR(\textcolor{stringliteral}{"{}Invalid\ -\/i\ argument\(\backslash\)n"{}});}
\DoxyCodeLine{00341\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ usagemsg(argv[0]);}
\DoxyCodeLine{00342\ \ \ \ \ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00343\ \ \ \ \ \ \ \ \ \ \ \ \ infile\ =\ argv[i];}
\DoxyCodeLine{00344\ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00345\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{else}\ \{}
\DoxyCodeLine{00346\ \ \ \ \ \ \ \ \ \ \ \ \ usagemsg(argv[0]);}
\DoxyCodeLine{00347\ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00348\ \ \ \ \ \}}
\DoxyCodeLine{00349\ }
\DoxyCodeLine{00350\ \ \ \ \ \textcolor{keywordflow}{if}\ (infile\ ==\ NULL)\ \{}
\DoxyCodeLine{00351\ \ \ \ \ \ \ \ \ E\_ERROR(\textcolor{stringliteral}{"{}No\ input\ file\ specified\(\backslash\)n"{}});}
\DoxyCodeLine{00352\ \ \ \ \ \ \ \ \ usagemsg(argv[0]);}
\DoxyCodeLine{00353\ \ \ \ \ \}}
\DoxyCodeLine{00354\ }
\DoxyCodeLine{00355\ \ \ \ \ \textcolor{keywordflow}{if}\ ((infp\ =\ fopen(infile,\ \textcolor{stringliteral}{"{}rb"{}}))\ ==\ NULL)}
\DoxyCodeLine{00356\ \ \ \ \ \ \ \ \ E\_FATAL\_SYSTEM(\textcolor{stringliteral}{"{}Failed\ to\ open\ '\%s'\ for\ reading"{}},\ infile);}
\DoxyCodeLine{00357\ }
\DoxyCodeLine{00358\ \ \ \ \ \textcolor{comment}{/*}}
\DoxyCodeLine{00359\ \textcolor{comment}{\ \ \ \ \ *\ Associate\ continuous\ listening\ module\ with\ opened\ input\ file\ and\ read\ function.}}
\DoxyCodeLine{00360\ \textcolor{comment}{\ \ \ \ \ *\ No\ A/D\ device\ is\ involved,\ but\ need\ to\ fill\ in\ ad-\/>sps.}}
\DoxyCodeLine{00361\ \textcolor{comment}{\ \ \ \ \ *\ Calibrate\ input\ data\ using\ first\ few\ seconds\ of\ file,\ but\ then\ rewind\ it!!}}
\DoxyCodeLine{00362\ \textcolor{comment}{\ \ \ \ \ */}}
\DoxyCodeLine{00363\ \ \ \ \ ad.sps\ =\ sps;}
\DoxyCodeLine{00364\ \ \ \ \ ad.bps\ =\ \textcolor{keyword}{sizeof}(int16);}
\DoxyCodeLine{00365\ \ \ \ \ \textcolor{keywordflow}{if}\ (!rawmode)}
\DoxyCodeLine{00366\ \ \ \ \ \ \ \ \ cont\ =\ cont\_ad\_init(\&ad,\ file\_ad\_read);}
\DoxyCodeLine{00367\ \ \ \ \ \textcolor{keywordflow}{else}}
\DoxyCodeLine{00368\ \ \ \ \ \ \ \ \ cont\ =\ cont\_ad\_init\_rawmode(\&ad,\ file\_ad\_read);}
\DoxyCodeLine{00369\ }
\DoxyCodeLine{00370\ \ \ \ \ printf(\textcolor{stringliteral}{"{}Calibrating\ ..."{}});}
\DoxyCodeLine{00371\ \ \ \ \ fflush(stdout);}
\DoxyCodeLine{00372\ \ \ \ \ \textcolor{keywordflow}{if}\ (cont\_ad\_calib(cont)\ <\ 0)}
\DoxyCodeLine{00373\ \ \ \ \ \ \ \ \ printf(\textcolor{stringliteral}{"{}\ failed;\ file\ too\ short?\(\backslash\)n"{}});}
\DoxyCodeLine{00374\ \ \ \ \ \textcolor{keywordflow}{else}}
\DoxyCodeLine{00375\ \ \ \ \ \ \ \ \ printf(\textcolor{stringliteral}{"{}\ done\(\backslash\)n"{}});}
\DoxyCodeLine{00376\ \ \ \ \ rewind(infp);}
\DoxyCodeLine{00377\ }
\DoxyCodeLine{00378\ \ \ \ \ \textcolor{comment}{/*\ Convert\ desired\ min.\ inter-\/utterance\ silence\ duration\ to\ \#samples\ */}}
\DoxyCodeLine{00379\ \ \ \ \ siltime\ =\ (int32)\ (endsil\ *\ sps);}
\DoxyCodeLine{00380\ }
\DoxyCodeLine{00381\ \ \ \ \ \textcolor{comment}{/*\ Enable\ writing\ raw\ input\ to\ output\ by\ the\ cont\ module\ if\ specified\ */}}
\DoxyCodeLine{00382\ \ \ \ \ \textcolor{keywordflow}{if}\ (copyfile)\ \{}
\DoxyCodeLine{00383\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ ((rawfp\ =\ fopen(copyfile,\ \textcolor{stringliteral}{"{}wb"{}}))\ ==\ NULL)}
\DoxyCodeLine{00384\ \ \ \ \ \ \ \ \ \ \ \ \ E\_ERROR\_SYSTEM(\textcolor{stringliteral}{"{}Failed\ to\ open\ raw\ output\ file\ '\%s'\ for\ writing"{}});}
\DoxyCodeLine{00385\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{else}}
\DoxyCodeLine{00386\ \ \ \ \ \ \ \ \ \ \ \ \ cont\_ad\_set\_rawfp(cont,\ rawfp);}
\DoxyCodeLine{00387\ \ \ \ \ \}}
\DoxyCodeLine{00388\ }
\DoxyCodeLine{00389\ \ \ \ \ cont\_ad\_get\_params(cont,}
\DoxyCodeLine{00390\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \&orig\_delta\_sil,\ \&orig\_delta\_speech,}
\DoxyCodeLine{00391\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \&orig\_min\_noise,\ \&orig\_max\_noise,}
\DoxyCodeLine{00392\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \&winsize,}
\DoxyCodeLine{00393\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \&orig\_speech\_onset,\ \&orig\_sil\_onset,}
\DoxyCodeLine{00394\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \&leader,\ \&trailer,\ \&orig\_adapt\_rate);}
\DoxyCodeLine{00395\ }
\DoxyCodeLine{00396\ \ \ \ \ E\_INFO(\textcolor{stringliteral}{"{}Default\ parameters:\(\backslash\)n"{}});}
\DoxyCodeLine{00397\ \ \ \ \ E\_INFOCONT(\textcolor{stringliteral}{"{}\(\backslash\)tmin-\/noise\ =\ \%d,\ max-\/noise\ =\ \%d\(\backslash\)n"{}},}
\DoxyCodeLine{00398\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ orig\_min\_noise,\ orig\_max\_noise);}
\DoxyCodeLine{00399\ \ \ \ \ E\_INFOCONT(\textcolor{stringliteral}{"{}\(\backslash\)tdelta-\/sil\ =\ \%d,\ delta-\/speech\ =\ \%d\(\backslash\)n"{}},}
\DoxyCodeLine{00400\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ orig\_delta\_sil,\ orig\_delta\_speech);}
\DoxyCodeLine{00401\ \ \ \ \ E\_INFOCONT(\textcolor{stringliteral}{"{}\(\backslash\)tsil-\/onset\ =\ \%d,\ speech-\/onset\ =\ \%d\(\backslash\)n"{}},}
\DoxyCodeLine{00402\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ orig\_sil\_onset,\ orig\_speech\_onset);}
\DoxyCodeLine{00403\ \ \ \ \ E\_INFOCONT(\textcolor{stringliteral}{"{}\(\backslash\)tadapt\_rate\ =\ \%.3f\(\backslash\)n"{}},\ orig\_adapt\_rate);}
\DoxyCodeLine{00404\ }
\DoxyCodeLine{00405\ \ \ \ \ \textcolor{keywordflow}{if}\ (min\_noise\ <\ 0)}
\DoxyCodeLine{00406\ \ \ \ \ \ \ \ \ min\_noise\ =\ orig\_min\_noise;}
\DoxyCodeLine{00407\ \ \ \ \ \textcolor{keywordflow}{if}\ (max\_noise\ <\ 0)}
\DoxyCodeLine{00408\ \ \ \ \ \ \ \ \ max\_noise\ =\ orig\_max\_noise;}
\DoxyCodeLine{00409\ \ \ \ \ \textcolor{keywordflow}{if}\ (delta\_sil\ <\ 0)}
\DoxyCodeLine{00410\ \ \ \ \ \ \ \ \ delta\_sil\ =\ orig\_delta\_sil;}
\DoxyCodeLine{00411\ \ \ \ \ \textcolor{keywordflow}{if}\ (delta\_speech\ <\ 0)}
\DoxyCodeLine{00412\ \ \ \ \ \ \ \ \ delta\_speech\ =\ orig\_delta\_speech;}
\DoxyCodeLine{00413\ \ \ \ \ \textcolor{keywordflow}{if}\ (sil\_onset\ <\ 0)}
\DoxyCodeLine{00414\ \ \ \ \ \ \ \ \ sil\_onset\ =\ orig\_sil\_onset;}
\DoxyCodeLine{00415\ \ \ \ \ \textcolor{keywordflow}{if}\ (speech\_onset\ <\ 0)}
\DoxyCodeLine{00416\ \ \ \ \ \ \ \ \ speech\_onset\ =\ orig\_speech\_onset;}
\DoxyCodeLine{00417\ \ \ \ \ \textcolor{keywordflow}{if}\ (adapt\_rate\ <\ 0.0)}
\DoxyCodeLine{00418\ \ \ \ \ \ \ \ \ adapt\_rate\ =\ orig\_adapt\_rate;}
\DoxyCodeLine{00419\ }
\DoxyCodeLine{00420\ \ \ \ \ cont\_ad\_set\_params(cont,}
\DoxyCodeLine{00421\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ delta\_sil,\ delta\_speech,}
\DoxyCodeLine{00422\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ min\_noise,\ max\_noise,}
\DoxyCodeLine{00423\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ winsize,}
\DoxyCodeLine{00424\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ speech\_onset,\ sil\_onset,}
\DoxyCodeLine{00425\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ leader,\ trailer,\ adapt\_rate);}
\DoxyCodeLine{00426\ }
\DoxyCodeLine{00427\ \ \ \ \ E\_INFO(\textcolor{stringliteral}{"{}Current\ parameters:\(\backslash\)n"{}});}
\DoxyCodeLine{00428\ \ \ \ \ E\_INFOCONT(\textcolor{stringliteral}{"{}\(\backslash\)tmin-\/noise\ =\ \%d,\ max-\/noise\ =\ \%d\(\backslash\)n"{}},\ min\_noise,\ max\_noise);}
\DoxyCodeLine{00429\ \ \ \ \ E\_INFOCONT(\textcolor{stringliteral}{"{}\(\backslash\)tdelta-\/sil\ =\ \%d,\ delta-\/speech\ =\ \%d\(\backslash\)n"{}},\ delta\_sil,}
\DoxyCodeLine{00430\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ delta\_speech);}
\DoxyCodeLine{00431\ \ \ \ \ E\_INFOCONT(\textcolor{stringliteral}{"{}\(\backslash\)tsil-\/onset\ =\ \%d,\ speech-\/onset\ =\ \%d\(\backslash\)n"{}},\ sil\_onset,}
\DoxyCodeLine{00432\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ speech\_onset);}
\DoxyCodeLine{00433\ \ \ \ \ E\_INFOCONT(\textcolor{stringliteral}{"{}\(\backslash\)tadapt\_rate\ =\ \%.3f\(\backslash\)n"{}},\ adapt\_rate);}
\DoxyCodeLine{00434\ }
\DoxyCodeLine{00435\ \ \ \ \ E\_INFO(\textcolor{stringliteral}{"{}Sampling\ rate:\ \%d"{}},\ sps);}
\DoxyCodeLine{00436\ \ \ \ \ E\_INFOCONT(\textcolor{stringliteral}{"{};\ Byteswap:\ \%s"{}},\ swap\ ?\ \textcolor{stringliteral}{"{}Yes"{}}\ :\ \textcolor{stringliteral}{"{}No"{}});}
\DoxyCodeLine{00437\ \ \ \ \ E\_INFOCONT(\textcolor{stringliteral}{"{};\ Max\ ad-\/read\ size:\ \%d\(\backslash\)n"{}},\ max\_ad\_read\_size);}
\DoxyCodeLine{00438\ }
\DoxyCodeLine{00439\ \ \ \ \ \textcolor{keywordflow}{if}\ (debug)}
\DoxyCodeLine{00440\ \ \ \ \ \ \ \ \ cont\_ad\_set\_logfp(cont,\ stdout);}
\DoxyCodeLine{00441\ }
\DoxyCodeLine{00442\ \ \ \ \ total\_speech\_samples\ =\ 0;}
\DoxyCodeLine{00443\ \ \ \ \ total\_speech\_sec\ =\ 0.0;}
\DoxyCodeLine{00444\ }
\DoxyCodeLine{00445\ \ \ \ \ uttid\ =\ 0;}
\DoxyCodeLine{00446\ \ \ \ \ uttlen\ =\ 0;}
\DoxyCodeLine{00447\ \ \ \ \ starttime\ =\ 0;}
\DoxyCodeLine{00448\ \ \ \ \ fp\ =\ NULL;}
\DoxyCodeLine{00449\ }
\DoxyCodeLine{00450\ \ \ \ \ \textcolor{comment}{/*\ Process\ data\ */}}
\DoxyCodeLine{00451\ \ \ \ \ \textcolor{keywordflow}{for}\ (;;)\ \{}
\DoxyCodeLine{00452\ \ \ \ \ \ \ \ \ \textcolor{comment}{/*\ Get\ audio\ data\ from\ continuous\ listening\ module\ */}}
\DoxyCodeLine{00453\ \ \ \ \ \ \ \ \ k\ =\ cont\_ad\_read(cont,\ buf,\ 4096);}
\DoxyCodeLine{00454\ }
\DoxyCodeLine{00455\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (k\ <\ 0)\ \{\ \ \ \ \ \ \ \ \ \ \ \ \textcolor{comment}{/*\ End\ of\ input\ audio\ file;\ close\ any\ open\ output\ file\ and\ exit\ */}}
\DoxyCodeLine{00456\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (fp\ !=\ NULL)\ \{}
\DoxyCodeLine{00457\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ fclose(fp);}
\DoxyCodeLine{00458\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ fp\ =\ NULL;}
\DoxyCodeLine{00459\ }
\DoxyCodeLine{00460\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ printf}
\DoxyCodeLine{00461\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ (\textcolor{stringliteral}{"{}Utt\ \%08d,\ st=\ \%8.2fs,\ et=\ \%8.2fs,\ seg=\ \%7.2fs\ (\#samp=\ \%10d)\(\backslash\)n"{}},}
\DoxyCodeLine{00462\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ uttid,\ (\textcolor{keywordtype}{double})\ starttime\ /\ (\textcolor{keywordtype}{double})\ sps,}
\DoxyCodeLine{00463\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ (\textcolor{keywordtype}{double})\ (starttime\ +\ uttlen)\ /\ (\textcolor{keywordtype}{double})\ sps,}
\DoxyCodeLine{00464\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ (\textcolor{keywordtype}{double})\ uttlen\ /\ (\textcolor{keywordtype}{double})\ sps,\ uttlen);}
\DoxyCodeLine{00465\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ fflush(stdout);}
\DoxyCodeLine{00466\ }
\DoxyCodeLine{00467\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ total\_speech\_samples\ +=\ uttlen;}
\DoxyCodeLine{00468\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ total\_speech\_sec\ +=\ (double)\ uttlen\ /\ (\textcolor{keywordtype}{double})\ sps;}
\DoxyCodeLine{00469\ }
\DoxyCodeLine{00470\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ uttid++;}
\DoxyCodeLine{00471\ \ \ \ \ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00472\ }
\DoxyCodeLine{00473\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{break};}
\DoxyCodeLine{00474\ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00475\ }
\DoxyCodeLine{00476\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (cont-\/>state\ ==\ CONT\_AD\_STATE\_SIL)\ \{\ \textcolor{comment}{/*\ Silence\ data\ got\ */}}
\DoxyCodeLine{00477\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (fp\ !=\ NULL)\ \{\ \ \ \textcolor{comment}{/*\ Currently\ in\ an\ utterance\ */}}
\DoxyCodeLine{00478\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (cont-\/>seglen\ >\ siltime)\ \{\ \ \ \textcolor{comment}{/*\ Long\ enough\ silence\ detected;\ end\ the\ utterance\ */}}
\DoxyCodeLine{00479\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ fclose(fp);}
\DoxyCodeLine{00480\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ fp\ =\ NULL;}
\DoxyCodeLine{00481\ }
\DoxyCodeLine{00482\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ printf}
\DoxyCodeLine{00483\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ (\textcolor{stringliteral}{"{}Utt\ \%08d,\ st=\ \%8.2fs,\ et=\ \%8.2fs,\ seg=\ \%7.2fs\ (\#samp=\ \%10d)\(\backslash\)n"{}},}
\DoxyCodeLine{00484\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ uttid,\ (\textcolor{keywordtype}{double})\ starttime\ /\ (\textcolor{keywordtype}{double})\ sps,}
\DoxyCodeLine{00485\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ (\textcolor{keywordtype}{double})\ (starttime\ +\ uttlen)\ /\ (\textcolor{keywordtype}{double})\ sps,}
\DoxyCodeLine{00486\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ (\textcolor{keywordtype}{double})\ uttlen\ /\ (\textcolor{keywordtype}{double})\ sps,\ uttlen);}
\DoxyCodeLine{00487\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ fflush(stdout);}
\DoxyCodeLine{00488\ }
\DoxyCodeLine{00489\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ total\_speech\_samples\ +=\ uttlen;}
\DoxyCodeLine{00490\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ total\_speech\_sec\ +=\ (double)\ uttlen\ /\ (\textcolor{keywordtype}{double})\ sps;}
\DoxyCodeLine{00491\ }
\DoxyCodeLine{00492\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ uttid++;}
\DoxyCodeLine{00493\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00494\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{else}\ \{}
\DoxyCodeLine{00495\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{comment}{/*}}
\DoxyCodeLine{00496\ \textcolor{comment}{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ *\ Short\ silence\ within\ utt;\ write\ it\ to\ output.\ \ (Some\ extra\ trailing\ silence}}
\DoxyCodeLine{00497\ \textcolor{comment}{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ *\ is\ included\ in\ the\ utterance,\ as\ a\ result.\ \ Not\ to\ worry\ about\ it.)}}
\DoxyCodeLine{00498\ \textcolor{comment}{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ */}}
\DoxyCodeLine{00499\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (k\ >\ 0)\ \{}
\DoxyCodeLine{00500\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ fwrite(buf,\ \textcolor{keyword}{sizeof}(int16),\ k,\ fp);}
\DoxyCodeLine{00501\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ uttlen\ +=\ k;}
\DoxyCodeLine{00502\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00503\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00504\ \ \ \ \ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00505\ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00506\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{else}\ \{}
\DoxyCodeLine{00507\ \ \ \ \ \ \ \ \ \ \ \ \ assert(cont-\/>state\ ==\ CONT\_AD\_STATE\_SPEECH);}
\DoxyCodeLine{00508\ }
\DoxyCodeLine{00509\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (fp\ ==\ NULL)\ \{\ \ \ \textcolor{comment}{/*\ Not\ in\ an\ utt;\ open\ a\ new\ output\ file\ */}}
\DoxyCodeLine{00510\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (writeseg)}
\DoxyCodeLine{00511\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ sprintf(segfile,\ \textcolor{stringliteral}{"{}\%08d.raw"{}},\ uttid);}
\DoxyCodeLine{00512\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{else}}
\DoxyCodeLine{00513\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ strcpy(segfile,\ NULL\_DEVICE);}
\DoxyCodeLine{00514\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ ((fp\ =\ fopen(segfile,\ \textcolor{stringliteral}{"{}wb"{}}))\ ==\ NULL)}
\DoxyCodeLine{00515\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ E\_FATAL\_SYSTEM(\textcolor{stringliteral}{"{}Failed\ to\ open\ segmentation\ file\ '\%s'\ for\ writing"{}},\ segfile);}
\DoxyCodeLine{00516\ }
\DoxyCodeLine{00517\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ starttime\ =\ cont-\/>read\_ts\ -\/\ k;}
\DoxyCodeLine{00518\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ uttlen\ =\ 0;}
\DoxyCodeLine{00519\ \ \ \ \ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00520\ }
\DoxyCodeLine{00521\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{comment}{/*\ Write\ data\ obtained\ to\ output\ file\ */}}
\DoxyCodeLine{00522\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (k\ >\ 0)\ \{}
\DoxyCodeLine{00523\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ fwrite(buf,\ \textcolor{keyword}{sizeof}(int16),\ k,\ fp);}
\DoxyCodeLine{00524\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ uttlen\ +=\ k;}
\DoxyCodeLine{00525\ \ \ \ \ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00526\ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00527\ \ \ \ \ \}}
\DoxyCodeLine{00528\ }
\DoxyCodeLine{00529\ \ \ \ \ \textcolor{keywordflow}{if}\ (rawfp)}
\DoxyCodeLine{00530\ \ \ \ \ \ \ \ \ fclose(rawfp);}
\DoxyCodeLine{00531\ }
\DoxyCodeLine{00532\ \ \ \ \ E\_INFO(\textcolor{stringliteral}{"{}Total\ raw\ input\ speech\ =\ \%d\ frames,\ \%d\ samples,\ \%.2f\ sec\(\backslash\)n"{}},}
\DoxyCodeLine{00533\ \ \ \ \ \ \ \ \ \ \ \ cont-\/>tot\_frm,\ cont-\/>tot\_frm\ *\ cont-\/>spf,}
\DoxyCodeLine{00534\ \ \ \ \ \ \ \ \ \ \ \ (cont-\/>tot\_frm\ *\ cont-\/>spf)\ /\ (float32)\ cont-\/>sps);}
\DoxyCodeLine{00535\ \ \ \ \ E\_INFO(\textcolor{stringliteral}{"{}Total\ speech\ detected\ =\ \%d\ samples,\ \%.2f\ sec\(\backslash\)n"{}},}
\DoxyCodeLine{00536\ \ \ \ \ \ \ \ \ \ \ \ total\_speech\_samples,\ total\_speech\_sec);}
\DoxyCodeLine{00537\ }
\DoxyCodeLine{00538\ \ \ \ \ cont\_ad\_close(cont);}
\DoxyCodeLine{00539\ }
\DoxyCodeLine{00540\ \ \ \ \ \textcolor{keywordflow}{return}\ 0;}
\DoxyCodeLine{00541\ \}}

\end{DoxyCode}
