Edinburgh Speech Tools  2.1-release
tilt_synthesis_main.cc
Go to the documentation of this file.
1 /*************************************************************************/
2 /* */
3 /* Centre for Speech Technology Research */
4 /* University of Edinburgh, UK */
5 /* Copyright (c) 1996 */
6 /* All Rights Reserved. */
7 /* */
8 /* Permission is hereby granted, free of charge, to use and distribute */
9 /* this software and its documentation without restriction, including */
10 /* without limitation the rights to use, copy, modify, merge, publish, */
11 /* distribute, sublicense, and/or sell copies of this work, and to */
12 /* permit persons to whom this work is furnished to do so, subject to */
13 /* the following conditions: */
14 /* 1. The code must retain the above copyright notice, this list of */
15 /* conditions and the following disclaimer. */
16 /* 2. Any modifications must be clearly marked as such. */
17 /* 3. Original authors' names are not deleted. */
18 /* 4. The authors' names are not used to endorse or promote products */
19 /* derived from this software without specific prior written */
20 /* permission. */
21 /* */
22 /* THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK */
23 /* DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING */
24 /* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT */
25 /* SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE */
26 /* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES */
27 /* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN */
28 /* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, */
29 /* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF */
30 /* THIS SOFTWARE. */
31 /* */
32 /*************************************************************************/
33 /* Author : Paul Taylor */
34 /* Date : February 1996 */
35 /*-----------------------------------------------------------------------*/
36 /* Event RFC Synthesis */
37 /* */
38 /*=======================================================================*/
39 
40 #include "EST_cmd_line.h"
41 #include "EST_tilt.h"
42 #include "EST_Track.h"
44 #include "EST_string_aux.h"
45 
46 using namespace std;
47 
48 void extract_channels(EST_Wave &single, const EST_Wave &multi, EST_IList &ch_list);
49 
50 
51 int main (int argc, char *argv[])
52 {
53  EST_Track fz, nfz;
54  EST_Relation ev;
55  EST_Option al, op;
56  EST_String out_file("-"), ev_format, pstring;
57  EST_StrList files, event_list;
58  EST_Item *e;
59 
60  float shift;
61  const float default_frame_shift = 0.01; // i.e 10ms intervals
62 
64  (argc, argv,
65  EST_String("[input label file] -o [output file] [options]") +
66  "Summary: generate F0 file from tilt or RFC label file\n"
67  "use \"-\" to make input and output files stdin/out\n"
68  "-h Options help\n\n"+
69  "-noconn Synthesize events only - no connections in output\n"
70  "-o <ofile> Output F0 file\n"
71  "-otype <string> File type for output label file\n"
72  "-event_names <string> List of labels to be classed as events. \n"
73  " Lists are specified as quoted strings with spaces \n"
74  " separating each item, e.g.: \"a b c d\"\n\n"
75  "-s <float> Frame spacing of generated contour in seconds\n",
76  files, al);
77 
78  out_file = al.present("-o") ? al.val("-o") : (EST_String)"-";
79  init_lib_ops(al, op);
80 
81  ev.load(files.first());
82 
83  // temporary fix until status of start and end is finalised
84  float prev_end = 0.0;
85 
86  for (e = ev.head(); e; e = e->next())
87  {
88  e->set("start", prev_end);
89  prev_end = e->F("end");
90  }
91 
92  pstring = al.present("-event_names") ? al.val("-event_names"):
93  EST_String("a b ab pos");
94  StringtoStrList(pstring, event_list);
95 
96  convert_to_broad(ev, event_list, "int_event");
97  shift = al.present("-s") ? al.fval("-s") : default_frame_shift;
98 
99  if (ev.f("intonation_style") == "tilt")
100  tilt_synthesis(fz, ev, shift, al.present("-noconn"));
101  else
102  {
103 // validate_rfc_stream(ev);
104  fill_rfc_types(ev);
105 // cout << ev;
106  rfc_synthesis(fz, ev, shift, al.present("-noconn"));
107  }
108 
109  fz.set_channel_name("F0", 0);
110 
111  fz.save(out_file, al.val("-otype"));
112  return 0;
113 }
114 
115 
116 
117 
119 {
120  // general options
121  a_list.override_val("sample_rate", al.val("-f", 0));
122 }
123 
A class for storing digital waveforms. The waveform is stored as an array of 16 bit shorts...
Definition: EST_Wave.h:64
EST_Item * head() const
Definition: EST_Relation.h:121
int override_val(const EST_String rkey, const EST_String rval)
add to end of list or overwrite. If rval is empty, do nothing
Definition: EST_Option.cc:54
void set_channel_name(const EST_String &name, int channel)
set the name of the channel.
Definition: EST_Track.cc:168
void set(const EST_String &name, ssize_t ival)
Definition: EST_Item.h:185
float fval(const EST_String &rkey, int m=1) const
Definition: EST_Option.cc:104
void rfc_synthesis(EST_Track &f0, EST_Relation &ev_list, float f_shift, int no_conn)
Generate an F0 contour given a list RFC events.
void convert_to_broad(EST_Relation &seg, EST_StrList &pos_list, EST_String broad_name="", int polarity=1)
float F(const EST_String &name) const
Definition: EST_Item.h:135
void StringtoStrList(EST_String s, EST_StrList &l, EST_String sep)
Convert a EST_String to a EST_StrList by separating tokens in s delimited by the separator sep...
int init_lib_ops(EST_Option &al, EST_Option &options)
Definition: cmd_line.cc:69
EST_write_status save(const EST_String name, const EST_String EST_filetype="")
Definition: EST_Track.cc:1233
void override_lib_ops(EST_Option &a_list, EST_Option &al)
void tilt_synthesis(EST_Track &track, EST_Relation &ev_list, float f_shift, int no_conn)
Generate an F0 contour given a list Tilt events.
const T & first() const
return const reference to first item in list
Definition: EST_TList.h:152
const V & val(const K &rkey, bool m=0) const
return value according to key (const)
Definition: EST_TKVL.cc:145
void fill_rfc_types(EST_Relation &ev)
Definition: tilt_utils.cc:237
EST_Item * next() const
Definition: EST_Item.h:348
EST_Features f
Definition: EST_Relation.h:101
int main(int argc, char *argv[])
int present(const K &rkey) const
Returns true if key is present.
Definition: EST_TKVL.cc:222
EST_read_status load(const EST_String &filename, const EST_String &type="esps")
EST_String
void extract_channels(EST_Wave &single, const EST_Wave &multi, EST_IList &ch_list)
Definition: EST_wave_aux.cc:84
int parse_command_line(int argc, char *argv[], const EST_String &usage, EST_StrList &files, EST_Option &al, int make_stdio=1)
Definition: cmd_line.cc:101
Utility EST_String Functions header file.