~alcinnz/rhapsode

afc9cc592f9d66e4a58fe519d7d907575b82b765 — Adrian Cochrane 4 years ago 87da55f
Extract navigation state out of SSML <marker>s.
1 files changed, 13 insertions(+), 1 deletions(-)

M src/main.c
M src/main.c => src/main.c +13 -1
@@ 3,6 3,7 @@
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <pthread.h>

#include "HsFFI.h"
#include <espeak-ng/espeak_ng.h>


@@ 55,9 56,20 @@ int read_mono(SNDFILE *fd, SF_INFO *info, short *out) {
    return i;
}

pthread_mutex_t marker_mutex = PTHREAD_MUTEX_INITIALIZER;
int paragraph_no, section_no;
int tablerow, tablecol, tableno, in_table;
int capture_marks(short *wav, int numsamples, espeak_EVENT *events) {
    while (events->type != 0) {
        if (events->type == espeakEVENT_MARK) printf("%s:\n", events->id.name);
        if (events->type == espeakEVENT_MARK) {
            pthread_mutex_lock(&marker_mutex);
            in_table = 0;
            if (sscanf(events->id.name, "-rhaps-paragraph%i", &paragraph_no) == 1) {}
            else if (sscanf(events->id.name, "-rhaps-section%i", &section_no) == 1) {}
            else if (sscanf(events->id.name, "-rhaps-tablecell%i:%ix%i",
                    &tableno, &tablerow, &tablecol) == 3) {in_table = 1;}
            pthread_mutex_unlock(&marker_mutex);
        }
        events++;
    }
    return 0;