mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Allow interleaved waits in develop_loop
This commit is contained in:
parent
46731246c6
commit
32155c172c
@ -62,7 +62,7 @@ def encode_to_file_object(text, output) -> int:
|
||||
return sz
|
||||
|
||||
|
||||
def develop_loop(wait_for, *commands):
|
||||
def develop_loop(*commands):
|
||||
p = start_worker()
|
||||
q = Queue()
|
||||
|
||||
@ -84,10 +84,12 @@ def develop_loop(wait_for, *commands):
|
||||
send('1 echo Synthesizer started')
|
||||
send('1 volume 0.1')
|
||||
for command in commands:
|
||||
if isinstance(command, str):
|
||||
send(command)
|
||||
else:
|
||||
while True:
|
||||
m = q.get()
|
||||
if m['related_to'] != wait_for:
|
||||
if m['related_to'] != command:
|
||||
continue
|
||||
if m['payload_type'] == 'media_state_changed' and m['state'] == 'ended':
|
||||
break
|
||||
@ -122,7 +124,7 @@ def develop_speech(text='Lucca Brazzi sleeps with the fishes.', mark_words=True)
|
||||
|
||||
with SharedMemory(size=max_buffer_size(text)) as shm:
|
||||
sz = encode_to_file_object(text, shm)
|
||||
develop_loop(2, f'2 speak {st} shm {sz} {shm.name}')
|
||||
develop_loop(f'2 speak {st} shm {sz} {shm.name}', 2)
|
||||
|
||||
|
||||
def develop_save(text='Lucca Brazzi sleeps with the fishes.', filename="speech.wav"):
|
||||
@ -130,4 +132,4 @@ def develop_save(text='Lucca Brazzi sleeps with the fishes.', filename="speech.w
|
||||
st = 'ssml' if '<speak' in text else 'text'
|
||||
with SharedMemory(size=max_buffer_size(text)) as shm:
|
||||
sz = encode_to_file_object(text, shm)
|
||||
develop_loop(2, f'2 save {st} {sz} {shm.name} {filename}')
|
||||
develop_loop(f'2 save {st} {sz} {shm.name} {filename}', 2)
|
||||
|
Loading…
x
Reference in New Issue
Block a user