Edinburgh Speech Tools  2.4-release
 All Classes Functions Variables Typedefs Enumerations Enumerator Friends 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 /** @name <command>tilt_synthesis</command> <emphasis>Generate F0 contours from Tilt descriptions</emphasis>
47  * @id tilt_synthesis-manual
48  * @toc
49  */
50 
51 //@{
52 
53 void extract_channels(EST_Wave &single, const EST_Wave &multi, EST_IList &ch_list);
54 
55 /**@name Synopsis
56  */
57 //@{
58 
59 //@synopsis
60 
61 /**
62 tilt_synthesis generates a F0 contour, given a label file containing
63 parameterised Tilt or RFC events.
64 
65 A detailed description of the Tilt intonation model can be found in the
66 <link linkend="tilt-overview">Tilt model overview</link> section.
67 
68 
69 */
70 
71 //@}
72 
73 /**@name OPTIONS
74  */
75 //@{
76 
77 //@options
78 
79 //@}
80 
81 
82 int main (int argc, char *argv[])
83 {
84  EST_Track fz, nfz;
85  EST_Relation ev;
86  EST_Option al, op;
87  EST_String out_file("-"), ev_format, pstring;
88  EST_StrList files, event_list;
89  EST_Item *e;
90 
91  float shift;
92  const float default_frame_shift = 0.01; // i.e 10ms intervals
93 
94  parse_command_line
95  (argc, argv,
96  EST_String("[input label file] -o [output file] [options]") +
97  "Summary: generate F0 file from tilt or RFC label file\n"
98  "use \"-\" to make input and output files stdin/out\n"
99  "-h Options help\n\n"+
100  "-noconn Synthesize events only - no connections in output\n"
101  "-o <ofile> Output F0 file\n"
102  "-otype <string> File type for output label file\n"
103  "-event_names <string> List of labels to be classed as events. \n"
104  " Lists are specified as quoted strings with spaces \n"
105  " separating each item, e.g.: \"a b c d\"\n\n"
106  "-s <float> Frame spacing of generated contour in seconds\n",
107  files, al);
108 
109  out_file = al.present("-o") ? al.val("-o") : (EST_String)"-";
110  init_lib_ops(al, op);
111 
112  ev.load(files.first());
113 
114  // temporary fix until status of start and end is finalised
115  float prev_end = 0.0;
116 
117  for (e = ev.head(); e; e = e->next())
118  {
119  e->set("start", prev_end);
120  prev_end = e->F("end");
121  }
122 
123  pstring = al.present("-event_names") ? al.val("-event_names"):
124  EST_String("a b ab pos");
125  StringtoStrList(pstring, event_list);
126 
127  convert_to_broad(ev, event_list, "int_event");
128  shift = al.present("-s") ? al.fval("-s") : default_frame_shift;
129 
130  if (ev.f("intonation_style") == "tilt")
131  tilt_synthesis(fz, ev, shift, al.present("-noconn"));
132  else
133  {
134 // validate_rfc_stream(ev);
135  fill_rfc_types(ev);
136 // cout << ev;
137  rfc_synthesis(fz, ev, shift, al.present("-noconn"));
138  }
139 
140  fz.set_channel_name("F0", 0);
141 
142  fz.save(out_file, al.val("-otype"));
143  return 0;
144 }
145 
146 /** @name Input Intonation Files
147 
148 The input should be a label file containing the tilt parameters for the
149 events in feature format. An example, in xlabel format, is shown below:
150 </para>
151 <para>
152 <screen>
153 intonation_style tilt
154 #
155 0.29 26 phrase_start ; ev.f0 115.234 ; position 0.29 ;
156 0.53 26 a ; int_event 1 ; ev.f0 118.171 ; position 0.53 ; tilt.amp 21.8602 ;
157  tilt.dur 0.26 ; tilt.tilt -0.163727 ;
158 0.77 26 a ; int_event 1 ; ev.f0 112.694 ; position 0.77 ; tilt.amp 27.0315 ;
159  tilt.dur 0.32 ; tilt.tilt -0.446791 ;
160 1.53 26 a ; int_event 1 ; ev.f0 100.83 ; position 1.53 ; tilt.amp 7.507 ;
161  tilt.dur 0.22 ; tilt.tilt -0.296317 ;
162 1.79 26 phrase_end ; ev.f0 92.9785 ; position 1.79 ;
163 </screen>
164 </para>
165 <para>
166 tilt_synthesis can also generate F0 contours from RFC parameters:
167 </para>
168 <para>
169 <screen>
170 intonation_style rfc
171 #
172 0.29 26 phrase_start ; ev.f0 115.234 ; position 0.29 ;
173 0.53 26 a ; ev.f0 118.171 ; rfc.rise_amp 8.19178 ; rfc.rise_dur 0.12 ;
174  rfc.fall_amp -13.6684 ; rfc.fall_dur 0.14 ; position 0.53 ;
175  0.77 26 a ; ev.f0 112.694 ; rfc.rise_amp 6.50673 ; rfc.rise_dur 0.1 ;
176  rfc.fall_amp -20.5248 ; rfc.fall_dur 0.22 ; position 0.77 ;
177 1.53 26 a ; ev.f0 100.83 ; rfc.rise_amp 1.55832 ; rfc.rise_dur 0.11 ;
178  rfc.fall_amp -6.09238 ; rfc.fall_dur 0.11 ; position 1.53 ;
179 1.79 26 phrase_end ; ev.f0 92.9785 ; position 1.79 ;
180 </screen>
181 </para>
182 <para>
183 The feature in the header, "intonation_style tilt" or
184 "intonation_style rfc" is needed for the tilt_synthesis program to know which
185 type of synthesis to perform.
186 
187 */
188 
189 //@{
190 //@}
191 
192 //@}
193 
194 
195 void override_lib_ops(EST_Option &a_list, EST_Option &al)
196 {
197  // general options
198  a_list.override_val("sample_rate", al.val("-f", 0));
199 }
200