Debian Codegraph @

main/flitevox_info_main.c

raw
1 /*************************************************************************/
2 /* */
3 /* Language Technologies Institute */
4 /* Carnegie Mellon University */
5 /* Copyright (c) 2014 */
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 /* CARNEGIE MELLON UNIVERSITY 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 CARNEGIE MELLON UNIVERSITY 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: Alan W Black ([email protected]) */
34 /* Date: November 2014 */
35 /*************************************************************************/
36 /* */
37 /* For setting and viewing features in a .flitevox clustergen file */
38 /* */
39 /*************************************************************************/
40
41 #include <stdio.h>
42 #include <string.h>
43 #include <sys/time.h>
44 #include <unistd.h>
45
46 #include "cst_args.h"
47 #include "flite.h"
48
49 void *flite_set_lang_list(void);
50
51 int main(int argc, char **argv)
52 {
53 cst_features *args=new_features();
54 cst_voice *v;
55 const char *voice_name, *feat;
56
57 (void)cst_args(argv,argc,
58 "usage: flitevox_info [OPTIONS]\n"
59 "-voice <string> Pathname to flitevox file\n"
60 "-set <string> Set given feature name\n"
61 "-get <string> Get given feature name\n"
62 "-val <string> Value to set\n"
63 "-info Output general info on voice\n"
64 "set/get features in a flitevox voice.",
65 args);
66
67 flite_init();
68 flite_set_lang_list();
69
70 if (!feat_present(args,"-voice"))
71 {
72 fprintf(stderr,"no voice specified\n");
73 exit(-1);
74 }
75 voice_name = feat_string(args,"-voice");
76 v = flite_voice_load(voice_name);
77 if (v == NULL)
78 {
79 fprintf(stderr,"can't load voice %s\n",voice_name);
80 exit(-1);
81 }
82
83 if (feat_present(args,"-info"))
84 {
85 cst_feat_print(stdout,v->features);
86 } else if (feat_present(args,"-set"))
87 {
88 feat = get_param_string(args,"-set","feat");
89 if (!feat_present(args,"-val"))
90 {
91 fprintf(stderr,"no feat val given for %s\n",feat);
92 exit(-1);
93 }
94 /* set the feature */
95 feat_set_string(v->features,feat,feat_string(args,"-val"));
96
97 /* printf("awb_debug: setting %s %s\n",feat,
98 feat_string(v->features,feat)); */
99 /* save the voice back out again */
100 flite_voice_dump(v,voice_name);
101 }
102 else if (feat_present(args,"-get"))
103 {
104 feat = get_param_string(args,"-get","feat");
105 printf("%s \"%s\"\n",feat,feat_string(v->features,feat));
106 }
107
108 delete_voice(v);
109 delete_features(args);
110
111 return 0;
112
113 }