| 95 | static void emit_word (Econtext * self, guint offset, guint len, guint id) { |
| 96 | post_message (self, gst_structure_new ("espeak-word", |
| 97 | "offset", G_TYPE_UINT, offset, |
| 98 | "len", G_TYPE_UINT, len, "id", G_TYPE_UINT, id, NULL)); |
| 99 | } |
| 100 | |
| 101 | static void emit_sentence (Econtext * self, guint offset, guint len, guint id) { |
| 102 | post_message (self, gst_structure_new ("espeak-sentence", |
| 103 | "offset", G_TYPE_UINT, offset, |
| 104 | "len", G_TYPE_UINT, len, "id", G_TYPE_UINT, id, NULL)); |
| 105 | } |
| 106 | |
100 | | GstStructure *data = gst_structure_new ("espeak-mark", |
101 | | "offset", G_TYPE_UINT, offset, |
102 | | "mark", G_TYPE_STRING, mark, |
103 | | NULL); |
104 | | if (!self->bus) |
105 | | self->bus = gst_element_get_bus (self->emitter); |
106 | | GstMessage *msg = |
107 | | gst_message_new_element (GST_OBJECT (self->emitter), data); |
108 | | gst_bus_post (self->bus, msg); |
| 108 | post_message (self, gst_structure_new ("espeak-mark", |
| 109 | "offset", G_TYPE_UINT, offset, |
| 110 | "mark", G_TYPE_STRING, mark, NULL)); |
221 | | |
222 | | for (event = spin->events_pos; TRUE; ++event) { |
223 | | espeak_EVENT *i = |
224 | | &g_array_index (spin->events, espeak_EVENT, event); |
225 | | |
226 | | GST_DEBUG ("event=%zd i->type=%d i->text_position=%d", |
227 | | event, i->type, i->text_position); |
228 | | |
229 | | if (i->type == espeakEVENT_LIST_TERMINATED) { |
230 | | sample_offset = spin_size; |
| 223 | espeak_EVENT *i = |
| 224 | &g_array_index (spin->events, espeak_EVENT, spin->events_pos); |
| 225 | |
| 226 | GST_DEBUG ("event=%zd i->type=%d i->text_position=%d", |
| 227 | event, i->type, i->text_position); |
| 228 | |
| 229 | if (i->type == espeakEVENT_LIST_TERMINATED) { |
| 230 | sample_offset = spin_size; |
| 231 | } else { |
| 232 | switch (i->type) { |
| 233 | case espeakEVENT_MARK: |
| 234 | emit_mark (self, i->text_position, i->id.name); |
239 | | } |
240 | | } |
241 | | |
242 | | return sample_offset - spin->sound_offset; |
243 | | } |
244 | | |
245 | | inline gsize mark (Econtext * self, Espin * spin, gsize size_to_play) { |
246 | | if (spin->mark_name) { |
247 | | emit_mark (self, spin->mark_offset, spin->mark_name); |
248 | | spin->mark_offset = 0; |
249 | | spin->mark_name = NULL; |
250 | | } |
251 | | |
252 | | gsize spin_size = spin->sound->len; |
253 | | gsize event; |
254 | | gsize sample_offset = 0; |
255 | | guint mark_offset = 0; |
256 | | const gchar *mark_name = NULL; |
257 | | |
258 | | for (event = spin->events_pos; TRUE; ++event) { |
259 | | espeak_EVENT *i = |
260 | | &g_array_index (spin->events, espeak_EVENT, event); |
261 | | |
262 | | GST_DEBUG ("event=%zd i->type=%d i->text_position=%d", |
263 | | event, i->type, i->text_position); |
264 | | |
265 | | if (i->type == espeakEVENT_LIST_TERMINATED) { |
266 | | sample_offset = spin_size; |
267 | | break; |
268 | | } else if (i->type == espeakEVENT_MARK) { |
269 | | if (i->sample == 0) { |
270 | | if (spin->sound_offset == 0) |
271 | | emit_mark (self, i->text_position, i->id.name); |
272 | | continue; |
273 | | } |
274 | | |
275 | | mark_offset = i->text_position; |
276 | | mark_name = i->id.name; |
277 | | sample_offset = i->sample * 2; |
| 239 | case espeakEVENT_SENTENCE: |
| 240 | emit_sentence (self, i->text_position, i->length, i->id.number); |