From 0a4b2d0dd49c7b4c18bdbaa8aa044397f6414d57 Mon Sep 17 00:00:00 2001 From: tlatorre Date: Sun, 6 Nov 2022 03:14:04 -0600 Subject: add text to speech and change beer symbol to water symbol --- Makefile | 2 ++ vito.c | 15 +++++++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 8f37d1e..8d99230 100644 --- a/Makefile +++ b/Makefile @@ -14,6 +14,8 @@ install: vito cp vito.desktop ${HOME}/Desktop/example-vito.desktop xdg-desktop-menu install ${HOME}/Desktop/example-vito.desktop xdg-desktop-menu forceupdate + @echo -e "\033[91mMake sure you run:\033[0m" + @echo -e " \033[1m$$ dnf install gtts mpg123\033[0m" clean: rm vito diff --git a/vito.c b/vito.c index 760949d..9b76c56 100644 --- a/vito.c +++ b/vito.c @@ -1,5 +1,6 @@ #include #include +#include #define LEN(x) ((sizeof(x)/sizeof(0[x])) / ((size_t)(!(sizeof(x) % sizeof(0[x]))))) @@ -19,7 +20,8 @@ GtkTextTag *tag; #define LEFT_ARROW "\xe2\x86\x90" #define CLEAR_SCREEN "\xe2\x8e\x9a" -#define DRINK "\xf0\x9f\x8d\xba" +#define SOUND "\xf0\x9f\x94\x8a" +#define DRINK "\xf0\x9f\x9a\xb0" #define FOOD "\xf0\x9f\x8d\xb2" #define TIRED "\xf0\x9f\x98\xab" #define HAPPY "\xf0\x9f\x98\x80" @@ -60,6 +62,7 @@ const char *alphabet[] = { "z", LEFT_ARROW, CLEAR_SCREEN, + SOUND, "_", NEWLINE, "!", @@ -67,7 +70,7 @@ const char *alphabet[] = { "." }; -char buf[1000000]; +char buf[100000]; /* The current alphabetical letter. */ int current_letter = 0; @@ -132,6 +135,14 @@ static int released(GtkWidget *widget, gpointer data) } else if (!strcmp(current_char,CLEAR_SCREEN)) { current_position = 0; current_letter = 0; + } else if (!strcmp(current_char,SOUND)) { + char cmd[1000000]; + buf[current_position] = '\0'; + sprintf(cmd, "gtts-cli \"%s\" --output vito.mp3", buf); + if (!system(cmd)) { + system("mpg123 vito.mp3"); + system("rm vito.mp3"); + } } else if (!strcmp(current_char,"_")) { sprintf(buf+current_position," "); current_position += strlen(current_char); -- cgit