"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "speech_class/EST_TrackFile.cc" between
speech_tools-2.4-release.tar.gz and speech_tools-2.5.0-release.tar.gz

About: The speech_tools - Edinburgh Speech Tools Library (used by the Festival Speech Synthesis System).

EST_TrackFile.cc  (speech_tools-2.4-release):EST_TrackFile.cc  (speech_tools-2.5.0-release)
skipping to change at line 281 skipping to change at line 281
return format_ok; return format_ok;
} }
EST_read_status EST_TrackFile::load_xmg(const EST_String filename, EST_Track &tr , float ishift, float startt) EST_read_status EST_TrackFile::load_xmg(const EST_String filename, EST_Track &tr , float ishift, float startt)
{ {
(void)ishift; (void)ishift;
(void)startt; (void)startt;
EST_TokenStream ts; EST_TokenStream ts;
EST_StrList sl; EST_StrList sl;
int i, n, sr; int i, n;
EST_String t, k, v; EST_String t, k, v;
EST_Litem *p; EST_Litem *p;
if (((filename == "-") ? ts.open(cin) : ts.open(filename)) != 0) if (((filename == "-") ? ts.open(cin) : ts.open(filename)) != 0)
{ {
cerr << "Can't open track file " << filename << endl; cerr << "Can't open track file " << filename << endl;
return misc_read_error; return misc_read_error;
} }
// set up the character constant values for this stream // set up the character constant values for this stream
ts.set_SingleCharSymbols(";"); ts.set_SingleCharSymbols(";");
if (ts.peek().string() != "XAO1") if (ts.peek().string() != "XAO1")
return wrong_format; return wrong_format;
ts.get().string(); ts.get().string();
while ((!ts.eof()) && (ts.peek().string() != "\014")) while ((!ts.eof()) && (ts.peek().string() != "\014"))
{ {
k = ts.get().string(); k = ts.get().string();
v = ts.get().string(); v = ts.get().string();
#if 0
/* Tracks don't represent these explicitly */
if (k == "Freq") if (k == "Freq")
sr = v.Int() * 1000; sr = v.Int() * 1000;
else if (k == "YMin") else if (k == "YMin")
/* tr.amin = atof(v) */; /* tr.amin = atof(v) */;
else if (k == "YMax") else if (k == "YMax")
/*tr.amax = atof(v) */; /*tr.amax = atof(v) */;
#endif
} }
if (ts.eof()) if (ts.eof())
{ {
cerr << "Unexpected end of file in reading xmg header\n"; cerr << "Unexpected end of file in reading xmg header\n";
return misc_read_error; return misc_read_error;
} }
ts.get().string(); // read control L ts.get().string(); // read control L
ts.get_upto_eoln().string(); // read until end of header ts.get_upto_eoln().string(); // read until end of header
skipping to change at line 388 skipping to change at line 391
if (swap) swapfloat(&f); if (swap) swapfloat(&f);
return f; return f;
} }
EST_read_status EST_TrackFile::load_est_ts(EST_TokenStream &ts, EST_read_status EST_TrackFile::load_est_ts(EST_TokenStream &ts,
EST_Track &tr, float ishift, float startt ) EST_Track &tr, float ishift, float startt )
{ {
(void)ishift; (void)ishift;
(void)startt; (void)startt;
int i, j; int i, j;
int num_frames, num_channels, num_aux_channels; int num_frames, num_channels;
EST_Features hinfo; EST_Features hinfo;
EST_EstFileType t; EST_EstFileType t;
EST_String v; EST_String v;
bool ascii; bool ascii;
bool breaks; bool breaks;
bool eq_space; bool eq_space;
EST_read_status r; EST_read_status r;
int swap; int swap;
if ((r = read_est_header(ts, hinfo, ascii, t)) != format_ok) if ((r = read_est_header(ts, hinfo, ascii, t)) != format_ok)
skipping to change at line 412 skipping to change at line 415
breaks = hinfo.present("BreaksPresent") ? true : false; breaks = hinfo.present("BreaksPresent") ? true : false;
eq_space = false; eq_space = false;
if ((hinfo.present("EqualSpace")) && if ((hinfo.present("EqualSpace")) &&
((hinfo.S("EqualSpace") == "true") || ((hinfo.S("EqualSpace") == "true") ||
(hinfo.S("EqualSpace") == "1"))) (hinfo.S("EqualSpace") == "1")))
eq_space = true; eq_space = true;
num_frames = hinfo.I("NumFrames"); num_frames = hinfo.I("NumFrames");
num_channels = hinfo.I("NumChannels"); num_channels = hinfo.I("NumChannels");
num_aux_channels = hinfo.I("NumAuxChannels", 0);
tr.resize(num_frames, num_channels); tr.resize(num_frames, num_channels);
hinfo.remove("NumFrames"); hinfo.remove("NumFrames");
hinfo.remove("EqualSpace"); hinfo.remove("EqualSpace");
hinfo.remove("NumChannels"); hinfo.remove("NumChannels");
hinfo.remove("BreaksPresent"); hinfo.remove("BreaksPresent");
hinfo.remove("DataType"); hinfo.remove("DataType");
if (hinfo.present("NumAuxChannels"))
hinfo.remove("NumAuxChannels");
EST_String strn, cname; EST_String strn, cname;
EST_Features::Entries p, c; EST_Features::Entries p, c;
EST_StrList ch_map; EST_StrList ch_map;
for (p.begin(hinfo); p;) for (p.begin(hinfo); p;)
{ {
c = p++; c = p++;
if (c->k.contains("Aux_Channel_")) if (c->k.contains("Channel_"))
{
ch_map.append(c->v.String());
hinfo.remove(c->k);
}
else if (c->k.contains("Channel_"))
{ {
tr.set_channel_name(c->v.String(), tr.set_channel_name(c->v.String(),
c->k.after("Channel_").Int()); c->k.after("Channel_").Int());
hinfo.remove(c->k); hinfo.remove(c->k);
} }
} }
tr.resize_aux(ch_map); tr.resize_aux(ch_map);
// tr.create_map(); // tr.create_map();
skipping to change at line 768 skipping to change at line 763
fprintf(fp, "%s %s\n", (const char *)p->k, fprintf(fp, "%s %s\n", (const char *)p->k,
(const char *) p->v.String()); (const char *) p->v.String());
fprintf(fp, "EST_Header_End\n"); fprintf(fp, "EST_Header_End\n");
for (i = 0; i < tr.num_frames(); ++i) for (i = 0; i < tr.num_frames(); ++i)
{ {
fprintf(fp, "%f\t", tr.t(i)); fprintf(fp, "%f\t", tr.t(i));
fprintf(fp, "%s\t", (char *)(tr.val(i) ? "1 " : "0 ")); fprintf(fp, "%s\t", (char *)(tr.val(i) ? "1 " : "0 "));
for (j = 0; j < tr.num_channels(); ++j) for (j = 0; j < tr.num_channels(); ++j)
fprintf(fp, "%f ", tr.a_no_check(i, j)); fprintf(fp, "%g ", tr.a_no_check(i, j));
for (j = 0; j < tr.num_aux_channels(); ++j) for (j = 0; j < tr.num_aux_channels(); ++j)
fprintf(fp, "%s ", (const char *)tr.aux(i, j).string()); fprintf(fp, "%s ", (const char *)tr.aux(i, j).string());
fprintf(fp, "\n"); fprintf(fp, "\n");
} }
return write_ok; return write_ok;
} }
EST_write_status EST_TrackFile::save_est_ascii(const EST_String filename, EST_write_status EST_TrackFile::save_est_ascii(const EST_String filename,
EST_Track tr) EST_Track tr)
{ {
skipping to change at line 856 skipping to change at line 851
for (j = 0; j < tr.num_channels(); ++j) for (j = 0; j < tr.num_channels(); ++j)
if((int)fwrite(&tr.a_no_check(i, j),4,1,fp) != 1) if((int)fwrite(&tr.a_no_check(i, j),4,1,fp) != 1)
return misc_write_error; return misc_write_error;
} }
return write_ok; return write_ok;
} }
EST_write_status EST_TrackFile::save_ascii(const EST_String filename, EST_Track tr) EST_write_status EST_TrackFile::save_ascii(const EST_String filename, EST_Track tr)
{ {
/* We want to print these "nice" but not lose precision for
various precisioned numbers. so we're going to use %g to do this */
char fbuf[100];
if (tr.equal_space() == TRUE) if (tr.equal_space() == TRUE)
tr.change_type(0.0, FALSE); tr.change_type(0.0, FALSE);
ostream *outf; ostream *outf;
if (filename == "-") if (filename == "-")
outf = &cout; outf = &cout;
else else
outf = new ofstream(filename); outf = new ofstream(filename);
if (!(*outf)) if (!(*outf))
return write_fail; return write_fail;
outf->precision(5); outf->precision(5);
outf->setf(ios::fixed, ios::floatfield); outf->setf(ios::fixed, ios::floatfield);
outf->width(8); outf->width(8);
for (int i = 0; i < tr.num_frames(); ++i) for (int i = 0; i < tr.num_frames(); ++i)
{ {
for (int j = 0; j < tr.num_channels(); ++j) for (int j = 0; j < tr.num_channels(); ++j)
*outf << tr.a(i, j) << " "; {
snprintf(fbuf,sizeof(fbuf),"%g",tr.a(i, j));
*outf << fbuf << " ";
}
*outf << endl; *outf << endl;
} }
if (outf != &cout) if (outf != &cout)
delete outf; delete outf;
return write_ok; return write_ok;
} }
EST_write_status EST_TrackFile::save_xgraph(const EST_String filename, EST_Track tr) EST_write_status EST_TrackFile::save_xgraph(const EST_String filename, EST_Track tr)
 End of changes. 10 change blocks. 
13 lines changed or deleted 14 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)