Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAleksey Lim <alsroot@member.fsf.org>2009-03-10 00:26:13 (GMT)
committer Aleksey Lim <alsroot@member.fsf.org>2009-03-10 00:26:13 (GMT)
commitf3ea135c59da300e6b5bbd7205650bf16d4da1e6 (patch)
tree901f7aad5e438760e3f5e8afd5a4eb62b460de5a
parentc6e90af27e2933537322a924deb25b9d475b7710 (diff)
Rewrite text_position hacks to treat wrong positions
-rw-r--r--src/espeak.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/espeak.c b/src/espeak.c
index d42a984..4db1f7b 100644
--- a/src/espeak.c
+++ b/src/espeak.c
@@ -56,6 +56,7 @@ typedef struct
goffset last_word;
goffset mark_offset;
const gchar *mark_name;
+ goffset last_mark;
} Espin;
struct _Econtext
@@ -444,12 +445,25 @@ synth_cb(short *data, int numsamples, espeak_EVENT *events)
NULL, NULL);
espeak_EVENT *i;
+
for (i = events; i->type != espeakEVENT_LIST_TERMINATED; ++i)
{
if (i->type == espeakEVENT_WORD)
--i->text_position;
else if (i->type == espeakEVENT_MARK)
{
+ // suppress failed text_position values
+ if (spin->last_mark)
+ {
+ goffset pos = strstr(spin->context->text +
+ spin->last_mark, "/>") - spin->context->text + 2;
+ if (i->text_position <= spin->last_mark ||
+ pos > i->text_position)
+ i->text_position = pos;
+ }
+
+ spin->last_mark = i->text_position;
+
gchar *pos = spin->context->text + i->text_position;
gint turn = 0;
@@ -491,6 +505,7 @@ synth(Econtext *self, Espin *spin)
spin->mark_offset = -1;
spin->mark_name = NULL;
spin->last_word = -1;
+ spin->last_mark = 0;
espeak_SetParameter(espeakPITCH, g_atomic_int_get(&self->pitch), 0);
espeak_SetParameter(espeakRATE, g_atomic_int_get(&self->rate), 0);