Debian Codegraph @

main/word_times_main.c

raw
1 /*************************************************************************/
2 /* */
3 /* Language Technologies Institute */
4 /* Carnegie Mellon University */
5 /* Copyright (c) 2001 */
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: January 2001 */
35 /*************************************************************************/
36 /* */
37 /* For text to phones */
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 #include "../lang/usenglish/usenglish.h"
50 #include "../lang/cmulex/cmu_lex.h"
51
52 static cst_voice *cmu_us_no_wave = NULL;
53
54 static cst_utterance *no_wave_synth(cst_utterance *u)
55 {
56 return u;
57 }
58
59 static cst_voice *register_cmu_us_no_wave(const char *voxdir)
60 {
61 cst_voice *v = new_voice();
62 cst_lexicon *lex;
63
64 v->name = "no_wave_voice";
65
66 /* Set up basic values for synthesizing with this voice */
67 usenglish_init(v);
68 feat_set_string(v->features,"name","cmu_us_no_wave");
69
70 /* Lexicon */
71 lex = cmu_lex_init();
72 feat_set(v->features,"lexicon",lexicon_val(lex));
73
74 /* Intonation */
75 feat_set_float(v->features,"int_f0_target_mean",95.0);
76 feat_set_float(v->features,"int_f0_target_stddev",11.0);
77
78 feat_set_float(v->features,"duration_stretch",1.1);
79
80 /* Post lexical rules */
81 feat_set(v->features,"postlex_func",uttfunc_val(lex->postlex));
82
83 /* Waveform synthesis: diphone_synth */
84 feat_set(v->features,"wave_synth_func",uttfunc_val(&no_wave_synth));
85
86 cmu_us_no_wave = v;
87
88 return cmu_us_no_wave;
89 }
90
91 int main(int argc, char **argv)
92 {
93 cst_val *files;
94 cst_features *args=new_features();
95 cst_voice *v;
96 cst_utterance *u;
97 cst_item *s;
98 const char *text, *name;
99
100 files =
101 cst_args(argv,argc,
102 "usage: t2p \"word word word\"\n"
103 "Convert text to US English phonemes.",
104 args);
105
106 if (files)
107 text = val_string(val_car(files));
108 else
109 {
110 fprintf(stderr,"no text specified\n");
111 exit(-1);
112 }
113
114 flite_init();
115 v = register_cmu_us_no_wave(NULL);
116
117 u = flite_synth_text(text,v);
118
119 for (s=relation_head(utt_relation(u,"Token"));
120 s;
121 s = item_next(s))
122 {
123 name = item_feat_string(s,"name");
124 /* Print word name and end time in waveform */
125 printf("%s %f",name,ffeature_float(s,"R:Token.daughtern.R:SylStructure.daughtern.daughtern.end"));
126 printf("\n");
127 }
128
129 delete_utterance(u);
130 delete_features(args);
131 delete_val(files);
132
133 return 0;
134 }