Skip to content

Commit

Permalink
misc_text_to_speech() <-- needed to encode quotes. 🐱
Browse files Browse the repository at this point in the history
  • Loading branch information
root authored and root committed Feb 22, 2023
1 parent 4c31bd5 commit 2c3298d
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
Binary file modified midilink
Binary file not shown.
25 changes: 22 additions & 3 deletions misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1054,11 +1054,30 @@ int misc_text_to_speech_sz(char * txt, size_t len)
{
if (misc_check_file("/media/fat/linux/pico2wave"))
{
char fmt[] = "/media/fat/linux/pico2wave --wave=/tmp/txtout.wav %c%s%c;";
char * tmp = malloc(len + sizeof(fmt));
char cmd[] = "/media/fat/linux/pico2wave --wave=/tmp/txtout.wav \"";
char * c = strchr(txt, '"');
size_t quoteCount = 1;
for (size_t src = 0; src < len; src++)
if (txt[src] == '"')
quoteCount++;
char * tmp = malloc(len + sizeof(cmd) + quoteCount);
if(tmp)
{
sprintf(tmp, fmt, '"', txt, '"');
strcpy(tmp, cmd);
size_t dst = sizeof(cmd) -1;
//we need to encode the quotes.... \"
for(size_t src = 0;src < len; src++)
{
if (txt[src] != '"')
tmp[dst++] = txt[src];
else
{
tmp[dst++] = '\\';
tmp[dst++] = '\"';
}
}
tmp[dst++] = '"';
tmp[dst] = 0x00;
//misc_make_file("/tmp/tst.txt", tmp);
system(tmp);
free(tmp);
Expand Down
Binary file modified mlinkutil
Binary file not shown.

0 comments on commit 2c3298d

Please sign in to comment.