From 6225fdbeae2a40c28da5b26d9af3f01e5a1c827e Mon Sep 17 00:00:00 2001 From: Christopher Brannon Date: Thu, 10 Mar 2016 10:11:54 -0800 Subject: [PATCH] Fix spelling keystrokes and char-by-char echo. Original patch courtesy of Samuel Thibault and modified to work with the current code by Chris. --- espeak.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/espeak.c b/espeak.c index fb973e7..0aa6a62 100644 --- a/espeak.c +++ b/espeak.c @@ -166,8 +166,25 @@ static espeak_ERROR speak_text(struct synth_t *s) if (espeakup_mode == ESPEAKUP_MODE_ACSINT) synth_mode |= espeakSSML; - rc = espeak_Synth(s->buf, s->len + 1, 0, POS_CHARACTER, 0, synth_mode, - NULL, NULL); + if (espeakup_mode == ESPEAKUP_MODE_SPEAKUP && (s->len == 1)) { + char *buf; + int n; + n = asprintf(&buf, + "%c", + s->buf[0]); + if (n == -1) { + /* D'oh. Not much to do on allocation failure. + * Perhaps espeak will happen to say the character */ + rc = espeak_Synth(s->buf, s->len + 1, 0, POS_CHARACTER, + 0, synth_mode, NULL, NULL); + } else { + rc = espeak_Synth(buf, n + 1, 0, POS_CHARACTER, 0, + espeakSSML, NULL, NULL); + free(buf); + } + } else + rc = espeak_Synth(s->buf, s->len + 1, 0, POS_CHARACTER, 0, + synth_mode, NULL, NULL); return rc; }