1 /*************************************************************************/
2 /* */
3 /* Centre for Speech Technology Research */
4 /* University of Edinburgh, UK */
5 /* Copyright (c) 1995,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 /* */
34 /* Authors: Richard Caley */
35 /* ------------------------------------------------------------------- */
36 /* Label conversion main file */
37 /* */
38 /*************************************************************************/
39
40
41 #include <cstdlib>
42 #include "EST_error.h"
43 #include "EST_ling_class.h"
44 #include "EST_cmd_line.h"
45
main(int argc,char * argv[])46 int main(int argc, char *argv[])
47 {
48 EST_String out_file, ext;
49 EST_StrList files;
50 EST_Option al;
51
52 parse_command_line(argc, argv,
53 EST_String("Usage: "
54 "ch_utt <input file> -o <output file> <options>\n"
55 "Summary: change/copy utterance file\n"
56 "use \"-\" to make input and output files stdin/out\n"
57 "-h Options help\n"
58 "-f <string> Feature to use as item ID when merging utterances.\n"
59 "-o <ofile> output file name\n"
60 "-otype <string> output file type: \n"
61 "-sysdir <string> Look for unqualified system entities in this directory"
62 ) + options_utterance_filetypes_long(),
63 files, al);
64
65 EST_Utterance utt;
66 EST_read_status rstat;
67
68 EST_String feat = al.present("-f")?al.sval("-f"):EST_String("name");
69
70 if (al.present("-sysdir"))
71 utterance_xml_register_id("^\\([^/]*\\)",
72 al.sval("-sysdir") + "/\\1");
73
74 rstat=utt.load(files.first());
75
76 if (rstat == read_format_error)
77 EST_error("Bad format in %s", (const char *)files.first());
78 else if (rstat != read_ok)
79 EST_sys_error("Error reading %s", (const char *)files.first());
80
81 EST_Utterance u;
82
83 EST_Litem *fp = files.head()->next();
84 for(; fp != NULL; fp=fp->next())
85 {
86 rstat = u.load(files(fp));
87
88 if (rstat == read_format_error)
89 EST_error("Bad format in %s", (const char *)files(fp));
90 else if (rstat != read_ok)
91 EST_sys_error("Error reading %s", (const char *)files(fp));
92
93 utterance_merge(utt, u, feat);
94 }
95
96 EST_String otype = al.present("-otype")? al.sval("-otype") : (EST_String)"est";
97
98 if (al.present("-o"))
99 utt.save(al.sval("-o"), otype);
100 else
101 {
102 utt.save("-", otype);
103 }
104
105 return 0;
106 }
107
108