File: | modules/Intonation/gen_int.cc |
Location: | line 77, column 5 |
Description: | Value stored to 'targrel' is never read |
1 | /*************************************************************************/ |
2 | /* */ |
3 | /* Centre for Speech Technology Research */ |
4 | /* University of Edinburgh, UK */ |
5 | /* Copyright (c) 1996,1997 */ |
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 : Alan W Black */ |
34 | /* Date : April 1996 */ |
35 | /*-----------------------------------------------------------------------*/ |
36 | /* */ |
37 | /* A general intonation method for implementing various simple rule */ |
38 | /* intonation systems. It allows a list of targets to be predicted */ |
39 | /* in a way fully specified by the user without changing the C/C++ code */ |
40 | /* This was specifically designed to replace the simple intonation mode */ |
41 | /* monotone mode, and implemented generic ToBI type labels. */ |
42 | /* */ |
43 | /* This was to help Gregor Moehler do German ToBI as well as get a */ |
44 | /* we can use for a rule-based English ToBI for comparison with trained */ |
45 | /* versions */ |
46 | /* */ |
47 | /*=======================================================================*/ |
48 | #include <cstdio> |
49 | #include "festival.h" |
50 | #include "intonation.h" |
51 | |
52 | using namespace std; |
53 | |
54 | static void check_targs(EST_Utterance *u); |
55 | static EST_Item *find_nearest_seg(EST_Utterance *u,float pos); |
56 | |
57 | LISP FT_Int_Targets_General_Utt(LISP utt) |
58 | { |
59 | // Predict F0 targets |
60 | EST_Utterance *u = get_c_utt(utt)(utterance(utt)); |
61 | EST_Item *s; |
62 | EST_Item *seg; |
63 | EST_Relation *targrel; |
64 | LISP gen_params, targets, t; |
65 | LISP tfunc; // a lisp function that returns list of targets and values |
66 | |
67 | // Create some down step accents |
68 | gen_params = siod_get_lval("int_general_params", |
69 | "no general intonation simple params"); |
70 | tfunc = get_param_lisp("targ_func",gen_params,NIL((struct obj *) 0)); |
71 | if (tfunc == NIL((struct obj *) 0)) |
72 | { |
73 | cerr << "Int Target General: no target function specified" << endl; |
74 | festival_error()(errjmp_ok ? longjmp(*est_errjmp,1) : festival_tidy_up(),exit (-1)); |
75 | } |
76 | |
77 | targrel = u->create_relation("Target"); |
Value stored to 'targrel' is never read | |
78 | |
79 | for (s=u->relation("Syllable")->first(); s != 0 ; s=s->next()) |
80 | { |
81 | targets = |
82 | leval(cons(tfunc,cons(utt,cons(siod(s),NIL((struct obj *) 0)))),NIL((struct obj *) 0)); |
83 | // Add the given targets |
84 | for (t=targets; t != NIL((struct obj *) 0); t=cdr(t)) |
85 | { |
86 | seg = find_nearest_seg(u,get_c_float(car(car(t)))); |
87 | add_target(*u,seg,get_c_float(car(car(t))), |
88 | get_c_float(car(cdr(car(t))))); |
89 | } |
90 | } |
91 | |
92 | check_targs(u); |
93 | |
94 | return utt; |
95 | } |
96 | |
97 | static EST_Item *find_nearest_seg(EST_Utterance *u,float pos) |
98 | { |
99 | // Find the segment that this target falls within. |
100 | // This naively searchs from the start of the segments, |
101 | // this is not very efficient |
102 | EST_Item *seg; |
103 | |
104 | for (seg=u->relation("Segment")->first(); seg != 0;seg=seg->next()) |
105 | { |
106 | if (seg->F("end") >= pos) |
107 | return seg; |
108 | } |
109 | |
110 | cerr << "Int Target General: target past end of segments at " << |
111 | pos << endl; |
112 | festival_error()(errjmp_ok ? longjmp(*est_errjmp,1) : festival_tidy_up(),exit (-1)); |
113 | return NULL__null; |
114 | } |
115 | |
116 | static void check_targs(EST_Utterance *u) |
117 | { |
118 | // Check targets are in order |
119 | EST_Item *t; |
120 | float l = 0.0; |
121 | |
122 | for (t=u->relation("Target")->first_leaf(); t != 0;t=next_leaf(t)) |
123 | { |
124 | if (t->F("pos") < l) |
125 | { |
126 | cerr << "Int Target General: targets out of order" << endl; |
127 | festival_error()(errjmp_ok ? longjmp(*est_errjmp,1) : festival_tidy_up(),exit (-1)); |
128 | } |
129 | l = t->F("pos"); |
130 | } |
131 | } |
132 | |
133 |