https://github.com/williamh/espeakup/pull/22

---
 espeak.c    |   19 ++++++++++---------
 espeakup.h  |    2 ++
 softsynth.c |   16 ++++++++++++++++
 3 files changed, 28 insertions(+), 9 deletions(-)

--- a/espeak.c
+++ b/espeak.c
@@ -47,7 +47,7 @@ const int volumeMultiplier = 22;
 volatile int stop_requested = 0;
 int paused_espeak = 1;
 
-static int acsint_callback(short *wav, int numsamples, espeak_EVENT * events)
+static int callback(short *wav, int numsamples, espeak_EVENT * events)
 {
 	int i;
 	for (i = 0; events[i].type !=  espeakEVENT_LIST_TERMINATED; i++) {
@@ -55,8 +55,7 @@ static int acsint_callback(short *wav, i
 			int mark = atoi(events[i].id.name);
 			if ((mark < 0) || (mark > 255))
 				continue;
-			putchar(mark);
-			fflush(stdout);
+			softsynth_reportindex(mark);
 		}
 	}
 	return 0;
@@ -327,9 +326,7 @@ static void reinitialize_espeak(struct s
 		return;
 	}
 
-	/* We need a callback in acsint mode, but not in speakup mode. */
-	if (espeakup_mode == ESPEAKUP_MODE_ACSINT)
-		espeak_SetSynthCallback(acsint_callback);
+	espeak_SetSynthCallback(callback);
 
 	/* Set parameters again */
 	espeak_SetVoiceByName(s->voice);
@@ -345,6 +342,7 @@ static void reinitialize_espeak(struct s
 static void queue_process_entry(struct synth_t *s)
 {
 	espeak_ERROR error;
+	char markbuff[50];
 	static struct espeak_entry_t *current = NULL;
 
 	if (current != queue_peek(synth_queue)) {
@@ -362,6 +360,11 @@ static void queue_process_entry(struct s
 	case CMD_SET_FREQUENCY:
 		error = set_frequency(s, current->value, current->adjust);
 		break;
+	case CMD_SET_MARK:
+		snprintf(markbuff, sizeof(markbuff), "<mark name=\"%d\"/>", current->value);
+		error = espeak_Synth(markbuff, strlen(markbuff)+1, 0, POS_CHARACTER,
+				     0, espeakSSML, NULL, NULL);
+		break;
 	case CMD_SET_PITCH:
 		error = set_pitch(s, current->value, current->adjust);
 		break;
@@ -413,9 +416,7 @@ int initialize_espeak(struct synth_t *s)
 		return -1;
 	}
 
-	/* We need a callback in acsint mode, but not in speakup mode. */
-	if (espeakup_mode == ESPEAKUP_MODE_ACSINT)
-		espeak_SetSynthCallback(acsint_callback);
+	espeak_SetSynthCallback(callback);
 
 	/* Setup initial voice parameters */
 	if (defaultVoice && defaultVoice[0]) {
--- a/espeakup.h
+++ b/espeakup.h
@@ -38,6 +38,7 @@ enum espeakup_mode_t {
 
 enum command_t {
 	CMD_SET_FREQUENCY,
+	CMD_SET_MARK,
 	CMD_SET_PITCH,
 	CMD_SET_RANGE,
 	CMD_SET_PUNCTUATION,
@@ -87,6 +88,7 @@ extern void *espeak_thread(void *arg);
 extern int open_softsynth(void);
 extern void close_softsynth(void);
 extern void *softsynth_thread(void *arg);
+extern void softsynth_reportindex(int index);
 extern volatile int should_run;
 extern volatile int stop_requested;
 extern int paused_espeak;
--- a/softsynth.c
+++ b/softsynth.c
@@ -124,6 +124,9 @@ static int process_command(struct synth_
 		case 'f':
 			cmd = CMD_SET_FREQUENCY;
 			break;
+		case 'i':
+			cmd = CMD_SET_MARK;
+			break;
 		case 'p':
 			cmd = CMD_SET_PITCH;
 			break;
@@ -328,3 +331,16 @@ void *softsynth_thread(void *arg)
 	pthread_mutex_unlock(&queue_guard);
 	return NULL;
 }
+
+void softsynth_reportindex(int index)
+{
+	if (espeakup_mode == ESPEAKUP_MODE_ACSINT) {
+		putchar(index);
+		fflush(stdout);
+	} else {
+		char buf[16];
+		snprintf(buf, sizeof(buf), "%d", index);
+		if (write(softFD, buf, strlen(buf)) < 0)
+			perror("Writing index failed");
+	}
+}
