65 #define NEARLY_ZERO 0.00001 67 #define REASONABLE_FRAME_SIZE (20) 68 #define UNREASONABLE_FRAME_SIZE (80) 71 static const char *NIST_SIG =
"NIST_1A\n 1024\n";
72 static const char *NIST_END_SIG =
"end_head\n";
73 #define NIST_HDR_SIZE 1024 75 static int def_load_sample_rate = 500;
103 r_val =
get_track_esps(filename, &fields, &tt, &fsize, &num_points,
104 &num_values, &fixed);
107 cerr <<
"Error reading ESPS file " << filename << endl;
113 num_fields = num_values;
120 tr.
resize(num_points,num_fields);
123 for (i = 0; i < num_points; ++i)
126 tr.
a(i, j) = tt[i][j+first_channel];
141 for (i = 0; i < num_values; ++i)
144 for (i = 0; i < num_values; ++i)
164 ssize_t i, j, n_rows, n_cols=0;
168 if (((filename ==
"-") ? ts.
open(cin) : ts.
open(filename)) != 0)
170 cerr <<
"Can't open track file " << filename << endl;
179 "Error: Frame spacing must be specified (or apparent frame shift nearly zero)\n";
185 for (n_rows = 0; !ts.
eof(); ++n_rows)
191 for (n_cols = 0; !tt.
eof(); ++n_cols)
196 tr.
resize(n_rows, n_cols);
198 for (p = sl.
head(), i = 0; p != 0; ++i, p = p->
next())
202 for (j = 0; !tt.
eof(); ++j)
203 tr.
a(i, j) = tt.
get().Float(ok);
206 cerr <<
"Wrong number of points in row " << i << endl;
207 cerr <<
"Expected " << n_cols <<
" got " << j << endl;
233 if (((filename ==
"-") ? ts.
open(cin) : ts.
open(filename)) != 0)
235 cerr <<
"Can't open track file " << filename << endl;
243 for (n_rows = 0; !ts.
eof(); ++n_rows)
247 for (n_cols = 0; !tt.
eof(); ++n_cols)
253 tr.
resize(n_rows, n_cols);
255 for (p = sl.
head(), i = 0; p != 0; ++i, p = p->
next())
259 tr.
t(i) = tt.
get().Float(ok);
260 for (j = 0; !tt.
eof(); ++j)
261 tr.
a(i, j) = tt.
get().Float(ok);
264 cerr <<
"Wrong number of points in row " << i << endl;
265 cerr <<
"Expected " << n_cols <<
" got " << j << endl;
291 if (((filename ==
"-") ? ts.
open(cin) : ts.
open(filename)) != 0)
293 cerr <<
"Can't open track file " << filename << endl;
306 k = ts.
get().string();
307 v = ts.
get().string();
312 }
else if (k ==
"YMax") {
319 cerr <<
"Unexpected end of file in reading xmg header\n";
326 for (n = 0; !ts.
eof(); ++n)
332 for (p = sl.
head(), i = 0; p != 0; ++i, p = p->
next())
338 tr.
t(i) = ts.
get().Float(ok) / 1000.0;
339 tr.
a(i) = ts.
get().Float(ok);
357 EST_Track &tr,
float ishift,
float startt)
362 if (((filename ==
"-") ? ts.
open(cin) : ts.
open(filename)) != 0)
364 cerr <<
"Can't open track file " << filename << endl;
370 r = load_est_ts(ts, tr, ishift, startt);
374 cerr <<
"Not end of file, but expected it\n";
384 if (ts.
fread(&f,4,1) != 1)
386 cerr <<
"Could not get_float" << endl;
394 EST_Track &tr,
float ishift,
float startt)
399 ssize_t num_frames, num_channels;
414 breaks = hinfo.
present(
"BreaksPresent") ?
true :
false;
416 if ((hinfo.
present(
"EqualSpace")) &&
417 ((hinfo.
S(
"EqualSpace") ==
"true") ||
418 (hinfo.
S(
"EqualSpace") ==
"1")))
421 num_frames = hinfo.
I(
"NumFrames");
422 num_channels = hinfo.
I(
"NumChannels");
424 tr.
resize(num_frames, num_channels);
426 hinfo.
remove(
"NumFrames");
427 hinfo.
remove(
"EqualSpace");
428 hinfo.
remove(
"NumChannels");
429 hinfo.
remove(
"BreaksPresent");
431 if (hinfo.
present(
"NumAuxChannels"))
432 hinfo.
remove(
"NumAuxChannels");
439 for (p.
begin(hinfo); p;)
443 if (c->k.contains(
"Aux_Channel_"))
445 ch_map.
append(c->v.String());
448 else if (c->k.contains(
"Channel_"))
451 c->k.after(
"Channel_").Int());
462 if (!hinfo.
present(
"ByteOrder"))
470 const int BINARY_CHANNEL_BUFFER_SIZE=1024;
472 float frame_buffer[BINARY_CHANNEL_BUFFER_SIZE];
475 if( num_channels > BINARY_CHANNEL_BUFFER_SIZE )
476 frame =
new float[num_channels];
478 frame = frame_buffer;
482 for (i = 0; i < num_frames; ++i)
491 cerr <<
"unexpected end of file when looking for " << num_frames-i <<
" more frame(s)" << endl;
494 tr.
t(i) = ts.
get().Float(ok);
499 tr.
t(i) = get_float(ts,swap);
506 v = ts.
get().string();
514 if (get_float(ts,swap) == 0.0)
537 for (j = 0; j < num_channels; ++j){
538 tr.
a(i, j) = ts.
get().Float(ok);
544 if (ts.
fread( frame,
sizeof(
float), num_channels ) != num_channels)
546 cerr <<
"Could not read frame " << i <<
"/" << num_frames << endl;
550 for( j=0; j<num_channels; ++j ){
552 tr.
a(i,j) = frame[j];
555 for( j=0; j<num_channels; ++j )
556 tr.
a(i,j) = frame[j];
565 tr.
aux(i, j) = ts.
get().string();
571 cerr <<
"Warning: Aux Channel reading not yet implemented";
572 cerr <<
"for binary tracks\n";
578 if( frame != frame_buffer )
596 float ishift,
float startt)
608 "Error: Frame spacing must be specified (or apparent frame shift nearly zero)\n";
612 if (((filename ==
"-") ? ts.
open(cin) : ts.
open(filename)) != 0)
614 cerr <<
"Can't open track file " << filename << endl;
618 if (ts.
get().string() !=
"SNNS")
620 if (ts.
get().string() !=
"result")
626 ssize_t num_frames=0, num_channels=0;
633 if (t.
contains(
"teaching output included"))
640 if (k ==
"No. of output units")
641 num_channels = v.Int();
642 if (k ==
"No. of patterns")
643 num_frames = v.Int();
651 tr.
resize(num_frames, num_channels);
655 for (i = 0; (!ts.
eof()) && (i < num_frames);)
664 for (j = 0; j < num_channels; ++j)
671 for (j = 0; j < num_channels; ++j)
672 tr.
a(i, j) = ts.
get().Float(ok);
692 int extra_channels=0;
698 cerr <<
"Output to stdout not available for ESPS file types:";
699 cerr <<
"no output written\n";
709 shift = track_tosave.
shift();
713 float **a =
new float*[track_tosave.
num_frames()];
717 a[i] =
new float[track_tosave.
num_channels() + extra_channels];
720 a[i][0] = track_tosave.
t(i);
723 a[i][j + extra_channels] = track_tosave.
a(i,j);
726 char **f_names =
new char*[track_tosave.
num_channels() + extra_channels];
734 f_names[0] =
wstrdup(
"EST_TIME");
742 for (i=0; i < track_tosave.
num_frames(); i ++)
745 for (i=0; i < track_tosave.
num_channels()+extra_channels; i++)
746 delete [] f_names[i];
756 std::stringstream tmpstring;
757 std::string tmpstring2;
759 fprintf(fp,
"EST_File Track\n");
760 fprintf(fp,
"DataType ascii\n");
762 tmpstring2 = tmpstring.str();
763 fprintf(fp,
"NumFrames %s\n", tmpstring2.c_str());
768 fprintf(fp,
"BreaksPresent true\n");
770 fprintf(fp,
"Channel_%d %s\n", i, (
const char *)(tr.
channel_name(i)));
773 fprintf(fp,
"Aux_Channel_%d %s\n", i,
778 for (p.
begin(tr); p; ++p)
779 fprintf(fp,
"%s %s\n", (
const char *)p->k,
780 (
const char *) p->v.String());
782 fprintf(fp,
"EST_Header_End\n");
786 fprintf(fp,
"%f\t", tr.
t(i));
787 fprintf(fp,
"%s\t", (
char *)(tr.
val(i) ?
"1 " :
"0 "));
791 fprintf(fp,
"%s ", (
const char *)tr.
aux(i, j).
string());
805 else if ((fd = fopen(filename,
"wb")) ==
NULL)
808 r = save_est_ts(fd,tr);
822 else if ((fd = fopen(filename,
"wb")) ==
NULL)
825 r = save_est_binary_ts(fd,tr);
839 std::stringstream tmpstring;
840 std::string tmpstring2;
842 fprintf(fp,
"EST_File Track\n");
843 fprintf(fp,
"DataType binary\n");
847 tmpstring2 = tmpstring.str();
848 fprintf(fp,
"NumFrames %s\n", tmpstring2.c_str());
852 fprintf(fp,
"BreaksPresent true\n");
853 fprintf(fp,
"CommentChar ;\n\n");
856 fprintf(fp,
"EST_Header_End\n");
861 if((
int)fwrite(&tr.
t(i),4,1,
fp) != 1)
867 float bm = (tr.
val(i) ? 1 : 0);
868 if((
int)fwrite(&bm,4,1,fp) != 1)
890 outf =
new ofstream(filename);
896 outf->setf(ios::fixed, ios::floatfield);
902 *outf << tr.
a(i, j) <<
" ";
920 outf =
new ofstream(filename);
932 *outf << tr.
t(i) <<
"\t" << tr.
a(i, j) << endl;
946 int num_inputs, num_outputs, num_pats;
953 outf =
new ofstream(filename);
959 for (pi = inpat.
head(); pi ; pi = pi->
next())
960 num_pats += inpat(pi).num_frames();
962 *outf <<
"SNNS pattern definition file V3.2\n";
964 time_t thetime =
time(0);
965 char *date = ctime(&thetime);
970 num_inputs = inpat.
first().num_channels();
971 num_outputs = outpat.
first().num_channels();
973 *outf <<
"No. of patterns : " << num_pats << endl;
974 *outf <<
"No. of input units : "<< num_inputs << endl;
975 *outf <<
"No. of output units : "<< num_outputs << endl;
976 *outf << endl << endl;
978 for (pi = inpat.
head(), po = outpat.
head(); pi ;
981 if (inpat(pi).num_frames() != outpat(pi).num_frames())
983 cerr <<
"Error: Input pattern has " << inpat(pi).num_frames()
984 <<
" output pattern has " << outpat(pi).num_frames() << endl;
989 for (i = 0; i < inpat(pi).num_frames(); ++i)
992 *outf <<
"#Input pattern " << (i + 1) <<
":\n";
993 for (j = 0; j < inpat(pi).num_channels(); ++j)
994 *outf << inpat(pi).a(i, j) <<
" ";
996 *outf <<
"#Output pattern " << (i + 1) <<
":\n";
997 for (j = 0; j < outpat(po).num_channels(); ++j)
998 *outf << outpat(po).a(i, j) <<
" ";
1068 if (filename ==
"-")
1071 outf =
new ofstream(filename);
1077 outf->setf(ios::fixed, ios::floatfield);
1087 *outf <<
"XAO1\n\n";
1088 *outf <<
"LineType segments \n";
1089 *outf <<
"LineStyle solid \n";
1090 *outf <<
"LineWidth 0 \n";
1091 *outf <<
"Freq " << sr / 1000 << endl;
1092 *outf <<
"Format Binary \n";
1098 *outf << char(12) <<
"\n";
1105 *outf << tr.
ms_t(i) <<
"\t";
1107 *outf <<tr.
a(i, j) <<
" ";
1134 if (orig.
f_String(
"contour_type",
"none") ==
"ct_lpc")
1147 file_num_channels += 1;
1172 SWAPSHORT((
sizeof(
float) * file_num_channels)));
1178 if (filename ==
"-")
1180 else if ((outf = fopen(filename,
"wb")) ==
NULL)
1182 cerr <<
"save_htk: cannot open file \"" << filename <<
1183 "\" for writing." << endl;
1198 cerr <<
"No data to write as HTK_DISCRETE !" << endl;
1204 cerr <<
"Warning: multiple channel track being written" << endl;
1205 cerr <<
" as discrete will only save channel 0 !" << endl;
1211 fwrite((
unsigned char*) &tempshort, 1,
sizeof(
short), outf);
1222 fwrite((
unsigned char*) &(track.
t(i)), 1,
sizeof(
float), outf);
1228 fwrite((
unsigned char*) &(track.
a(i, j)), 1,
sizeof(
float), outf);
1246 static int htk_swapped_header(
htk_header *header)
1253 if (htk_sane_header(header))
1261 if (htk_sane_header(header))
1270 return save_htk_as(filename, tmp,
HTK_FBANK);
1275 return save_htk_as(filename, tmp,
HTK_FBANK);
1280 return save_htk_as(filename, tmp,
HTK_MFCC);
1290 return save_htk_as(filename, tmp,
HTK_USER);
1304 ssize_t i, j, k, nframes, new_order;
1311 if ((fp = fopen(filename,
"rb")) ==
NULL)
1313 cerr <<
"EST_Track load: couldn't open EST_Track input file" << endl;
1319 data_length =
EST_ftell(fp)/sample_width;
1321 nframes = data_length /new_order;
1324 cout <<
"d length: " << data_length <<
" nfr " << nframes << endl;
1326 tmp.
resize(nframes, new_order);
1330 file_data.
resize(data_length);
1334 if ((
int)fread(file_data.
memory(), sample_width, data_length,
fp) != data_length)
1343 for (i = k = 0; i < nframes; ++i)
1344 for (j = 0; j < new_order; ++j, ++k)
1370 return load_ema_internal(filename, tmp, ishift, startt,
FALSE);
1376 return load_ema_internal(filename, tmp, ishift, startt,
TRUE);
1386 int samps,sample_width,data_length,actual_bo;
1387 unsigned char *file_data;
1389 char *byte_order, *sample_coding;
1395 if (((filename ==
"-") ? ts.
open(cin) : ts.
open(filename)) != 0)
1397 cerr <<
"Can't open track file " << filename << endl;
1401 current_pos = ts.
tell();
1405 if (strncmp(header,NIST_SIG,
sizeof(NIST_SIG)) != 0)
1417 data_length = (samps - offset)*num_channels;
1418 file_data =
walloc(
unsigned char,sample_width * data_length);
1422 n = ts.
fread(file_data,sample_width,data_length);
1424 if ((n < 1) && (n != data_length))
1427 wfree(sample_coding);
1431 else if ((n < data_length) && (data_length/num_channels == n))
1433 fprintf(stderr,
"TRACK read: nist header is (probably) non-standard\n");
1434 fprintf(stderr,
"TRACK read: assuming different num_channel interpretation\n");
1437 else if (n < data_length)
1439 fprintf(stderr,
"TRACK read: short file %s\n",
1441 fprintf(stderr,
"WAVE read: at %d got %d instead of %d samples\n",
1442 offset,n,data_length);
1451 actual_sample_type,actual_bo);
1454 int num_samples = data_length/num_channels;
1455 tmp.
resize(num_samples, num_channels);
1459 cerr <<
"shift " << 1/(float)sample_rate << endl;
1462 for (i=0; i<num_samples; i++)
1464 for (j = 0; j < num_channels; ++j)
1465 tmp.
a(i, j) = data[k++];
1468 for (j = 0; j < num_channels; ++j)
1488 if (filename ==
"-")
1490 else if ((fd = fopen(filename,
"wb")) ==
NULL)
1497 memset(header,0,1024);
1498 strcat(header, NIST_SIG);
1499 sprintf(p,
"channel_count -i %d\n", tr.
num_channels());
1501 sprintf(p,
"sample_count -i %d\n", tr.
num_frames());
1503 int sr = (
int)(rint(1/(
float)tr.
shift()));
1504 sprintf(p,
"sample_rate -i %d\n", sr);
1507 sprintf(p,
"sample_coding -s%d %s\n", (
signed)strlen(t), t);
1510 strcat(header, NIST_END_SIG);
1512 strcat(header,
"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
1515 if (fwrite(&header, 1024, 1, fd) != 1)
1549 ssize_t i,j, order, new_frames, num_values, num_channels;
1557 int header_sz =
sizeof(header);
1562 bool fileIsCompressed=
false;
1564 unsigned short samp_type, base_samp_type;
1566 if ((fp = fopen(filename,
"rb")) ==
NULL){
1567 cerr <<
"EST_Track load: couldn't open EST_Track input file" << endl;
1572 if (fread(&header, header_sz, 1, fp) != 1){
1577 swap = htk_swapped_header(&header);
1585 base_samp_type = samp_type &
HTK_MASK;
1587 time_included = (samp_type &
HTK_EST_PS) != 0;
1589 switch(base_samp_type){
1591 cerr <<
"Can't read HTK WAVEFORM format file into track" << endl;
1602 EST_warning(
"reading HTK_IREFC and HTK_LPREC parameter types is unsupported" );
1608 pname =
"ct_cepstrum";
1615 pname =
"ct_cepstrum";
1628 cerr <<
"Can't read HTK DISCRETE format file into track" << endl;
1648 fileIsCompressed =
true;
1650 num_channels = num_values = header.
samp_size /
sizeof(
short int);
1654 compressA =
new float[num_values];
1655 compressB =
new float[num_values];
1658 compressA = compressA_Buffer;
1659 compressB = compressB_Buffer;
1662 if( (fread( compressA,
sizeof(
float), num_values, fp )) !=
static_cast<size_t>(num_values) ){
1663 if (compressA != compressA_Buffer)
delete[] compressA;
1664 if (compressB != compressB_Buffer)
delete[] compressB;
1669 if( (fread( compressB,
sizeof(
float), num_values, fp )) != static_cast<size_t>(num_values) ){
1670 if (compressA != compressA_Buffer)
delete[] compressA;
1671 if (compressB != compressB_Buffer)
delete[] compressB;
1683 new_frames = header.
num_samps - (2*(
sizeof(float)-
sizeof(
short int)));
1686 num_channels = num_values = header.
samp_size /
sizeof(float);
1691 if (compressA != compressA_Buffer)
delete[] compressA;
1692 if (compressB != compressB_Buffer)
delete[] compressB;
1702 tmp.
resize(new_frames, num_channels);
1705 EST_warning(
"setting htk file start to %f", startt );
1713 if( dataBeginPosition == -1 ){
1714 if (compressA != compressA_Buffer)
delete[] compressA;
1715 if (compressB != compressB_Buffer)
delete[] compressB;
1721 if (compressA != compressA_Buffer)
delete[] compressA;
1722 if (compressB != compressB_Buffer)
delete[] compressB;
1728 if ((file_length = ftell(fp)) == -1){
1729 if (compressA != compressA_Buffer)
delete[] compressA;
1730 if (compressB != compressB_Buffer)
delete[] compressB;
1736 if( fileIsCompressed ){
1737 expected_vals = (file_length-dataBeginPosition) /
sizeof(
short int);
1743 expected_vals = (file_length-dataBeginPosition) /
sizeof(
float);
1750 if( expected_vals != (num_values * new_frames) ){
1752 if (compressA != compressA_Buffer)
delete[] compressA;
1753 if (compressB != compressB_Buffer)
delete[] compressB;
1760 order = num_channels;
1774 cerr <<
"Couldn't position htk file at start of data" << endl;
1775 if (compressA != compressA_Buffer)
delete[] compressA;
1776 if (compressB != compressB_Buffer)
delete[] compressB;
1781 if( fileIsCompressed ){
1784 frame =
new short int[num_values];
1786 frame = frame_buffer;
1788 int first_channel = time_included?1:0;
1790 for( i=0; i<new_frames; i++ ){
1791 if( fread( frame,
sizeof(
short int), num_values, fp ) != (
size_t) num_values ){
1792 cerr <<
"Could not read data from htk track file" << endl;
1795 if( frame != frame_buffer )
1797 if( compressA != compressA_Buffer )
1798 delete [] compressA;
1799 if( compressB != compressB_Buffer )
1800 delete [] compressB;
1809 tmp.
t(i) = ((float)frame[0]+compressB[0])/compressA[0];
1811 for( j=0; j<num_channels; ++j ){
1813 tmp.
a(i,j) = ((float)frame[index]+compressB[index])/compressA[
index];
1819 if( frame != frame_buffer )
1821 if( compressA != compressA_Buffer )
1822 delete [] compressA;
1823 if( compressB != compressB_Buffer )
1824 delete [] compressB;
1830 frame =
new float[num_values];
1832 frame = frame_buffer;
1834 int first_channel = time_included?1:0;
1835 for( i=0; i<new_frames; i++ ){
1836 if( fread( frame,
sizeof(
float), num_values, fp ) != (
size_t) num_values ){
1837 cerr <<
"Could not read data from htk track file" << endl;
1839 if (frame != frame_buffer)
1847 tmp.
t(i) = frame[0];
1849 for( j=0; j<num_channels; ++j )
1850 tmp.
a(i, j) = frame[j+first_channel];
1855 if( frame != frame_buffer )
1863 for (i=0;i<order;i++)
1872 if ( (samp_type & HTK_ENERGY) && !(samp_type & HTK_NO_E) )
1876 if (samp_type & HTK_DELTA){
1877 for (j = 0; j < order; j++){
1883 if (samp_type & HTK_ENERGY)
1888 if (samp_type & HTK_AC){
1889 for(j=0;j<order;j++){
1894 if (samp_type & HTK_ENERGY)
1899 if (i != num_channels){
1900 cerr <<
"Something went horribly wrong - wanted " << num_values
1901 <<
" channels in track but got " << i << endl;
1905 tmp.
f_set(
"contour_type",pname);
2001 if (fz.
a(i, f) < 1.0)
2008 if (fz.
a(i, p) < 0.5)
2024 int ncoefs, nchannels;
2045 for (
ssize_t c = 0; c < ncoefs; c++)
2048 lpc.
t(i) = track.
t(i);
2065 tlist(p).save(tlist(p).name(), otype);
2076 for (p = files.
head(); p; p = p->
next())
2083 tlist(plp).set_name(files(p));
2096 startt = al.
fval(
"-startt" );
2099 ishift = al.
fval(
"ishift");
2101 ishift = al.
fval(
"-s");
2102 else if (al.
present(
"time_channel"))
2150 EST_String s(
"AvailablE track file formats:\n");
2167 "unknown track file type"}},
2170 "entropic sps file"}},
2173 "Edinburgh Speech Tools track file"}},
2176 "Edinburgh Speech Tools track file"}}
2186 "htk file (as FBANK)"}},
2189 "htk file (as MFCC)"}},
2192 "htk file (as MFCC_E)"}},
2195 "htk file (as USER)"}},
2198 "htk file (as DISCRETE)"}},
2201 "Macquarie University's Simple Signal File Format"}},
2204 "xmg file viewer"}},
2207 "xgraph display program format"}},
2216 "ascii decimal numbers"}},
2223 EST_TrackFile::TS_Info> track_ts_names[] =
2227 "unknown track file type"}},
2231 "Edinburgh Speech Tools track file"}},
2235 "Edinburgh Speech Tools track file"}},
2239 "Macquarie University's Simple Signal File Format"}},
2243 "unknown track file type"}}
2250 #if defined(INSTANTIATE_TEMPLATES) 2252 #include "../base_class/EST_TNamedEnum.cc" 2255 const char *, EST_TrackFile::Info>;
2258 const char *, EST_TrackFile::TS_Info>;
bool single_break() const
static EST_read_status load_xmg(LoadTrackFileArgs)
EST_TokenStream & get(EST_Token &t)
get next token in stream
char * wstrdup(const char *s)
enum EST_write_status put_track_esps(const char *filename, char **f_names, float **a, float fsize, float rate, int order, int num_points, short fixed)
int num_aux_channels() const
return number of auxiliary channels in track
#define walloc(TYPE, SIZE)
EST_read_status read_est_header(EST_TokenStream &ts, EST_Features &hinfo, bool &ascii, EST_EstFileType &t)
int contains(const char *s, ssize_t pos=-1) const
Does it contain this substring?
RMS power of section of signal.
static EST_write_status save_htk_user(SaveTrackFileArgs)
int track_to_htk_lpc(EST_Track &track, EST_Track &lpc)
int track_to_espsf0(EST_Track &track, EST_Track &f0_track)
static EST_TNamedEnumI< EST_TrackFileType, TS_Info > ts_map
EST_FilePos EST_ftell(FILE *fp)
static EST_write_status save_est_ascii(SaveTrackFileArgs)
enum EST_bo_t str_to_bo(const char *boname)
static EST_read_status load_NIST(LoadTrackFileArgs)
static EST_write_status save_est_binary_ts(SaveTrac_TokenStreamArgs)
enum EST_write_status save_raw_data(FILE *fp, const short *data, int offset, int num_samples, int num_channels, enum EST_sample_type_t sample_type, int bo)
int fread(void *buff, int size, int nitems) EST_WARN_UNUSED_RESULT
Reading binary data, (don't use peek() immediately beforehand)
#define HTK_UNITS_PER_SECOND
const char * sample_type_to_nist(enum EST_sample_type_t sample_type)
void set_value(ssize_t i)
set frame i to be a value
int espsf0_to_track(EST_Track &fz)
void set_channel_name(const EST_String &name, int channel)
set the name of the channel.
void set_break(ssize_t i)
set frame i to be a break
EST_String name() const
name of track - redundant use access to features
static EST_write_status save_est_ts(SaveTrac_TokenStreamArgs)
int num_channels() const
return number of channels in track
void set_SingleCharSymbols(const EST_String &sc)
set which characters are to be treated as single character symbols
void set_single_break(bool t)
static EST_read_status load_ascii(LoadTrackFileArgs)
static EST_write_status save_ssff_ts(SaveTrac_TokenStreamArgs)
const EST_String filename() const
The originating filename (if there is one)
EST_ChannelNameMap esps_channel_names
Definition of the names ESPS programs use for channels.
INLINE const T & a_no_check(ssize_t n) const
read-only const access operator: without bounds checking
EST_FilePos tell(void) const
tell, synonym for filepos
EST_String itoString(int n)
Make a EST_String object from an integer.
float fval(const EST_String &rkey, int m=1) const
static EST_read_status load_esps(LoadTrackFileArgs)
short * convert_raw_data(unsigned char *file_data, int data_length, enum EST_sample_type_t sample_type, int bo)
void resize(ssize_t num_frames, int num_channels, bool preserve=1)
float & a_no_check(ssize_t i, int c=0)
static EST_String options_short(void)
static EST_write_status save_htk_fbank(SaveTrackFileArgs)
int index(EST_TList< T > &l, T &val, bool(*eq)(const EST_UItem *, const EST_UItem *)=NULL)
static const float default_frame_shift
int open(const EST_String &filename)
open a EST_TokenStream for a file.
static EST_String cat(const EST_String s1, const EST_String s2=Empty, const EST_String s3=Empty, const EST_String s4=Empty, const EST_String s5=Empty, const EST_String s6=Empty, const EST_String s7=Empty, const EST_String s8=Empty, const EST_String s9=Empty)
int open_string(const EST_String &newbuffer)
open a EST_TokenStream for string rather than a file
const EST_String S(const EST_String &path) const
EST_read_status load_snns_res(const EST_String filename, EST_Track &tr, float ishift, float startt)
void swap_bytes_float(float *data, int length)
static EST_read_status load_ssff_ts(LoadTrack_TokenStreamArgs)
int track_break(ssize_t i) const
return true if frame i is a break
int channel_position(const char *name, int offset=0) const
void assign_map(EST_TrackMap::P map)
static EST_write_status save_esps(SaveTrackFileArgs)
EST_write_status save_snns_pat(const EST_String filename, EST_TrackList &inpat, EST_TrackList &outpat)
enum EST_read_status get_track_esps(const char *filename, char ***fields, float ***a, float *fsize, int *num_points, int *num_fields, short *fixed)
EST_read_status load(const EST_String name, float ishift=0.0, float startt=0.0)
bool equal_space() const
return true if track has equal (i.e. fixed) frame spacing */
void resize(ssize_t n, int set=1)
float & t(ssize_t i=0)
return time position of frame i
float & a(ssize_t i, int c=0)
EST_write_status save_ind_TrackList(EST_TrackList &tlist, EST_String &otype)
const char * name(ENUM tok, int n=0) const
void set_file_type(EST_TrackFileType t)
The file was written successfully.
void set_name(const EST_String &n)
set name of track - redundant use access to features
void change_type(float nshift, bool single_break)
REDO.
static EST_read_status load_ema_swapped(LoadTrackFileArgs)
void remove(const EST_String &name)
static EST_read_status load_htk(LoadTrackFileArgs)
void resize_aux(EST_StrList &map, bool preserve=1)
void swap_bytes_short(short *data, int length)
float time(const EST_Item &item)
The file exists but is not in the format specified.
int present(const EST_String &name) const
const T & first() const
return const reference to first item in list
static EST_TNamedEnumI< EST_TrackFileType, Info > map
int EST_fseek(FILE *fp, EST_FilePos offset, int whence)
ssize_t num_frames() const
return number of frames in track
EST_Token & peek(void)
peek at next token
const EST_String & string(void) const
static EST_write_status save_htk_mfcc_e(SaveTrackFileArgs)
The file was not written successfully.
const V & val(const K &rkey, bool m=0) const
return value according to key (const)
static EST_write_status save_NIST(SaveTrackFileArgs)
void append(const T &item)
add item onto end of list
#define REASONABLE_FRAME_SIZE
int read_track(EST_Track &tr, const EST_String &in_file, EST_Option &al)
const EST_String channel_name(int channel, const EST_ChannelNameMap &map, int strings_override=1) const
INFO & info(ENUM token) const
EST_Token get_upto(const EST_String &s)
get up to s in stream as a single token.
EST_read_status read_TrackList(EST_TrackList &tlist, EST_StrList &files, EST_Option &al)
static EST_read_status load_est(LoadTrackFileArgs)
char * nist_get_param_str(char *hdr, char *field, char *def_val)
static EST_write_status save_htk_discrete(SaveTrackFileArgs)
const EST_String & string() const
void begin(const Container &over)
Set the iterator ready to run over this container.
const char * str(void) const
Get a const-pointer to the actual memory.
enum EST_sample_type_t nist_to_sample_type(char *type)
EST_Val & aux(ssize_t i, int c)
static EST_write_status save_htk(SaveTrackFileArgs)
int present(const K &rkey) const
Returns true if key is present.
static EST_read_status load_xgraph(LoadTrackFileArgs)
static EST_write_status save_xmg(SaveTrackFileArgs)
EST_Token get_upto_eoln(void)
get up to s in end of line as a single token.
int val(ssize_t i) const
return true if frame i is a value
int nist_get_param_int(char *hdr, char *field, int def_val)
static EST_write_status save_ssff(SaveTrackFileArgs)
int I(const EST_String &path) const
static EST_write_status save_est_binary(SaveTrackFileArgs)
#define UNREASONABLE_FRAME_SIZE
static EST_write_status save_xgraph(SaveTrackFileArgs)
bool has_channel(const char *name) const
static EST_write_status save_ascii(SaveTrackFileArgs)
static EST_read_status load_ssff(LoadTrackFileArgs)
int seek(int position)
seek, reposition file pointer
EST_String f_String(const char *name, const EST_String &def) const
void set_equal_space(bool t)
float ms_t(ssize_t i) const
return time of frame i in milli-seconds.
void fill_time(float t, int start=1)
static EST_read_status load_est_ts(LoadTrack_TokenStreamArgs)
static EST_write_status save_htk_mfcc(SaveTrackFileArgs)
static EST_String options_supported(void)
void f_set(const EST_String name, int val)
static EST_read_status load_ema(LoadTrackFileArgs)
const EST_String aux_channel_name(int channel) const
Value to return for errors, never occurs in TrackMaps.
Utility EST_String Functions header file.