abb128 / LiveCaptions

Linux Desktop application that provides live captioning
GNU General Public License v3.0
1.31k stars 32 forks source link

Output Text To stdout #59

Closed TKK13909 closed 1 year ago

TKK13909 commented 1 year ago

I think it would be very useful to be able to use this program in conjunction with other programs in the command line.

nicknesh commented 1 year ago

Just change line_generator_set_text - file line-gen.c line 315. It will print penultimate line

void line_generator_set_text(struct line_generator *lg, GtkLabel *lbl) {
    char *head = &lg->output[0];
    *head = '\0';    

    static char the_last_printed_line[AC_LINE_MAX];

    for(int i=AC_LINE_COUNT-1; i>=0; i--) {
        struct line *curr = &lg->lines[REL_LINE_IDX(lg->current_line, -i)];
        head += sprintf(head, "%s", curr->text);

        if(i != 0) head += sprintf(head, "\n");

        if( i == 1){ // print the penultimate line
            if( strcmp(the_last_printed_line, curr->text) != 0){
                printf("%s\n", curr->text);
                strcpy(the_last_printed_line, curr->text);
            }
        }
    }

    gtk_label_set_markup(lbl, lg->output);
}
abb128 commented 1 year ago

There is an example application in https://github.com/abb128/april-asr that allows you to stream audio as stdin and get results in stdout. Since this is a GUI application I don't think it makes sense to add stdout, but I'm adding a DBus API instead (https://github.com/abb128/LiveCaptions/issues/72)