Edinburgh Speech Tools  2.1-release
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
tilt_synthesis_main.cc
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"
43 #include "ling_class/EST_relation_aux.h"
44 #include "EST_string_aux.h"
45 
46 
47 void extract_channels(EST_Wave &single, const EST_Wave &multi, EST_IList &ch_list);
48 
49 
50 int main (int argc, char *argv[])
51 {
52  EST_Track fz, nfz;
53  EST_Relation ev;
54  EST_Option al, op;
55  EST_String out_file("-"), ev_format, pstring;
56  EST_StrList files, event_list;
57  EST_Item *e;
58 
59  float shift;
60  const float default_frame_shift = 0.01; // i.e 10ms intervals
61 
62  parse_command_line
63  (argc, argv,
64  EST_String("[input label file] -o [output file] [options]") +
65  "Summary: generate F0 file from tilt or RFC label file\n"
66  "use \"-\" to make input and output files stdin/out\n"
67  "-h Options help\n\n"+
68  "-noconn Synthesize events only - no connections in output\n"
69  "-o <ofile> Output F0 file\n"
70  "-otype <string> File type for output label file\n"
71  "-event_names <string> List of labels to be classed as events. \n"
72  " Lists are specified as quoted strings with spaces \n"
73  " separating each item, e.g.: \"a b c d\"\n\n"
74  "-s <float> Frame spacing of generated contour in seconds\n",
75  files, al);
76 
77  out_file = al.present("-o") ? al.val("-o") : (EST_String)"-";
78  init_lib_ops(al, op);
79 
80  ev.load(files.first());
81 
82  // temporary fix until status of start and end is finalised
83  float prev_end = 0.0;
84 
85  for (e = ev.head(); e; e = e->next())
86  {
87  e->set("start", prev_end);
88  prev_end = e->F("end");
89  }
90 
91  pstring = al.present("-event_names") ? al.val("-event_names"):
92  EST_String("a b ab pos");
93  StringtoStrList(pstring, event_list);
94 
95  convert_to_broad(ev, event_list, "int_event");
96  shift = al.present("-s") ? al.fval("-s") : default_frame_shift;
97 
98  if (ev.f("intonation_style") == "tilt")
99  tilt_synthesis(fz, ev, shift, al.present("-noconn"));
100  else
101  {
102 // validate_rfc_stream(ev);
103  fill_rfc_types(ev);
104 // cout << ev;
105  rfc_synthesis(fz, ev, shift, al.present("-noconn"));
106  }
107 
108  fz.set_channel_name("F0", 0);
109 
110  fz.save(out_file, al.val("-otype"));
111  return 0;
112 }
113 
114 
115 
116 
117 void override_lib_ops(EST_Option &a_list, EST_Option &al)
118 {
119  // general options
120  a_list.override_val("sample_rate", al.val("-f", 0));
121 }
122 
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:122
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:48
void set_channel_name(const EST_String &name, int channel)
set the name of the channel.
Definition: EST_Track.cc:166
float fval(const EST_String &rkey, int m=1) const
Definition: EST_Option.cc:98
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 set(const EST_String &name, int ival)
Definition: EST_Item.h:180
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...
EST_write_status save(const EST_String name, const EST_String EST_filetype="")
Definition: EST_Track.cc:1230
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:154
const int present(const K &rkey) const
Returns true if key is present.
Definition: EST_TKVL.cc:222
const V & val(const K &rkey, bool m=0) const
return value according to key (const)
Definition: EST_TKVL.cc:145
EST_Features f
Definition: EST_Relation.h:100
EST_read_status load(const EST_String &filename, const EST_String &type="esps")
const float F(const EST_String &name) const
Definition: EST_Item.h:135
Utility EST_String Functions header file.