From 7883d1cae47d3e4d5fc8b60612f15ff8f05d250e Mon Sep 17 00:00:00 2001 From: Sam Pullara Date: Thu, 16 Nov 2023 00:34:05 -0800 Subject: [PATCH] talk-llama : improve quote and backtick handling (#1364) * ISSUE-1329: replace " with ' so it doesn't try to execute code in backticks. * Typo * Update to keep possessives in the output Closes the ' then puts a ' in quotes then reopens the ' to escape the ' characters. --- examples/talk-llama/talk-llama.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/talk-llama/talk-llama.cpp b/examples/talk-llama/talk-llama.cpp index 925f9b61..aae392bd 100644 --- a/examples/talk-llama/talk-llama.cpp +++ b/examples/talk-llama/talk-llama.cpp @@ -686,8 +686,8 @@ int main(int argc, char ** argv) { } } - text_to_speak = ::replace(text_to_speak, "\"", ""); - int ret = system((params.speak + " " + std::to_string(voice_id) + " \"" + text_to_speak + "\"").c_str()); + text_to_speak = ::replace(text_to_speak, "'", "'\"'\"'"); + int ret = system((params.speak + " " + std::to_string(voice_id) + " '" + text_to_speak + "'").c_str()); if (ret != 0) { fprintf(stderr, "%s: failed to speak\n", __func__); }