From 91bcccf388c50ef6c010a806a23722b1bcff6dfc Mon Sep 17 00:00:00 2001 From: Marko Hlavaty Date: Sat, 14 Mar 2026 07:53:06 +0100 Subject: [PATCH] Fix crash when output lacks 'text' key with --out-txt enabled --- .../whisper/whisper_streaming/whisper_server.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/simulstreaming/whisper/whisper_streaming/whisper_server.py b/simulstreaming/whisper/whisper_streaming/whisper_server.py index 26c51d8..2b61f24 100644 --- a/simulstreaming/whisper/whisper_streaming/whisper_server.py +++ b/simulstreaming/whisper/whisper_streaming/whisper_server.py @@ -61,11 +61,14 @@ def send_result(self, iteration_output): # - the next words: segment transcript if iteration_output: if self.out_txt: - message = "%1.0f %1.0f %s" % (iteration_output['start'] * 1000, iteration_output['end'] * 1000, iteration_output['text']) + if 'text' in iteration_output: + message = "%1.0f %1.0f %s" % (iteration_output['start'] * 1000, iteration_output['end'] * 1000, iteration_output['text']) + print(message, flush=True, file=sys.stderr) + self.connection.send(message) else: message = json.dumps(iteration_output) - print(message, flush=True, file=sys.stderr) - self.connection.send(message) + print(message, flush=True, file=sys.stderr) + self.connection.send(message) else: logger.debug("No text in this segment") @@ -152,4 +155,4 @@ def main_server(factory, add_args): proc.process() conn.close() logger.info('Connection to client closed') - logger.info('Connection closed, terminating.') \ No newline at end of file + logger.info('Connection closed, terminating.')