From 6065f1847ff2213b429b53fbc90b9d56ba30bcb7 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Wed, 25 Jan 2023 06:45:06 +0530 Subject: [PATCH] Cleanup develop_speech() --- src/calibre/utils/windows/winspeech.py | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/src/calibre/utils/windows/winspeech.py b/src/calibre/utils/windows/winspeech.py index 05c9353539..cb433b500d 100644 --- a/src/calibre/utils/windows/winspeech.py +++ b/src/calibre/utils/windows/winspeech.py @@ -10,6 +10,13 @@ from threading import Thread from calibre.utils.ipc.simple_worker import start_pipe_worker +SSML_SAMPLE = ''' + + + We are selling roses and daisies. + + +''' def decode_msg(line: bytes) -> dict: parts = line.strip().split(b' ', 2) @@ -23,7 +30,7 @@ def start_worker(): return start_pipe_worker('from calibre_extensions.winspeech import run_main_loop; raise SystemExit(run_main_loop())') -def develop_speech(text='Lucca brazzi sleeps with the fishes'): +def develop_speech(text=SSML_SAMPLE): p = start_worker() print('\x1b[32mSpeaking', text, '\x1b[39m]]'[:-2], flush=True) q = Queue() @@ -40,17 +47,25 @@ def develop_speech(text='Lucca brazzi sleeps with the fishes'): p.stdin.flush() Thread(name='Echo', target=echo_output, args=(p,), daemon=True).start() + exit_code = 0 with closing(p.stdin), closing(p.stdout): + text = text.replace('\n', ' ') + st = 'ssml' if '