Edinburgh Speech Tools
2.1-release
ch_utt_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) 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
46
using namespace
std
;
47
48
int
main
(
int
argc,
char
*argv[])
49
{
50
EST_String
out_file, ext;
51
EST_StrList
files;
52
EST_Option
al;
53
54
parse_command_line
(argc, argv,
55
EST_String
(
"Usage: "
56
"ch_utt <input file> -o <output file> <options>\n"
57
"Summary: change/copy utterance file\n"
58
"use \"-\" to make input and output files stdin/out\n"
59
"-h Options help\n"
60
"-f <string> Feature to use as item ID when merging utterances.\n"
61
"-o <ofile> output file name\n"
62
"-otype <string> output file type: \n"
63
"-sysdir <string> Look for unqualified system entities in this directory"
64
) +
options_utterance_filetypes_long
(),
65
files, al);
66
67
EST_Utterance
utt;
68
EST_read_status
rstat;
69
70
EST_String
feat = al.
present
(
"-f"
)?al.
sval
(
"-f"
):
EST_String
(
"name"
);
71
72
if
(al.
present
(
"-sysdir"
))
73
utterance_xml_register_id
(
"^\\([^/]*\\)"
,
74
al.
sval
(
"-sysdir"
) +
"/\\1"
);
75
76
rstat=utt.
load
(files.
first
());
77
78
if
(rstat ==
read_format_error
)
79
EST_error
(
"Bad format in %s"
, (
const
char
*)files.
first
());
80
else
if
(rstat !=
read_ok
)
81
EST_sys_error
(
"Error reading %s"
, (
const
char
*)files.
first
());
82
83
EST_Utterance
u;
84
85
EST_Litem
*
fp
= files.
head
()->
next
();
86
for
(; fp !=
NULL
; fp=fp->
next
())
87
{
88
rstat = u.load(files(fp));
89
90
if
(rstat ==
read_format_error
)
91
EST_error
(
"Bad format in %s"
, (
const
char
*)files(fp));
92
else
if
(rstat !=
read_ok
)
93
EST_sys_error
(
"Error reading %s"
, (
const
char
*)files(fp));
94
95
utterance_merge
(utt, u, feat);
96
}
97
98
EST_String
otype = al.
present
(
"-otype"
)? al.
sval
(
"-otype"
) : (
EST_String
)
"est"
;
99
100
if
(al.
present
(
"-o"
))
101
utt.
save
(al.
sval
(
"-o"
), otype);
102
else
103
{
104
utt.
save
(
"-"
, otype);
105
}
106
107
return
0;
108
}
109
utterance_merge
int utterance_merge(EST_Utterance &utt, EST_Utterance &sub_utt, EST_Item *utt_root, EST_Item *sub_root)
Definition:
EST_Utterance.cc:305
EST_Utterance::save
EST_write_status save(const EST_String &filename, const EST_String &type="est_ascii") const
Definition:
EST_Utterance.cc:524
EST_Utterance::load
EST_read_status load(const EST_String &filename)
Definition:
EST_Utterance.cc:452
read_ok
The file was read in successfully.
Definition:
EST_rw_status.h:113
EST_UItem
Definition:
EST_UList.h:49
std
EST_UItem::next
EST_UItem * next()
Definition:
EST_UList.h:55
options_utterance_filetypes_long
EST_String options_utterance_filetypes_long(void)
Definition:
EST_utterance_aux.cc:53
EST_Option::sval
const EST_String & sval(const EST_String &rkey, int m=1) const
Definition:
EST_Option.cc:93
EST_sys_error
#define EST_sys_error
Definition:
EST_error.h:108
read_format_error
The file exists but is not in the format specified.
Definition:
EST_rw_status.h:115
NULL
NULL
Definition:
EST_WFST.cc:55
EST_error
#define EST_error
Definition:
EST_error.h:104
EST_TList::first
const T & first() const
return const reference to first item in list
Definition:
EST_TList.h:152
EST_cmd_line.h
EST_Option
Definition:
EST_Option.h:50
EST_read_status
EST_read_status
Definition:
EST_rw_status.h:111
EST_error.h
EST_TKVL::present
int present(const K &rkey) const
Returns true if key is present.
Definition:
EST_TKVL.cc:222
EST_UList::head
EST_UItem * head() const
Definition:
EST_UList.h:97
fp
LISP fp
Definition:
kkcompile.cc:63
EST_String
EST_String
Definition:
EST_features_aux.cc:50
EST_Utterance
Definition:
EST_Utterance.h:53
parse_command_line
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
utterance_xml_register_id
void utterance_xml_register_id(const EST_String pattern, const EST_String result)
Definition:
EST_utterance_aux.cc:68
EST_ling_class.h
main
int main(int argc, char *argv[])
Definition:
ch_utt_main.cc:48
EST_String
Definition:
EST_String.h:76
EST_TList
Definition:
EST_TList.h:61
main
ch_utt_main.cc
Generated on Fri Oct 6 2017 18:25:29 for Edinburgh Speech Tools by
1.8.11