From bc06223cb5b63bfed03a103c731e5c9fae427f2f Mon Sep 17 00:00:00 2001 From: HstSethi Date: Fri, 21 Mar 2025 14:48:13 +0530 Subject: [PATCH] fix(python): Add an error check for tot_samples to prevent zero division error --- python/vosk/transcriber/transcriber.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/python/vosk/transcriber/transcriber.py b/python/vosk/transcriber/transcriber.py index 8dd048f4..7b6ac0b3 100644 --- a/python/vosk/transcriber/transcriber.py +++ b/python/vosk/transcriber/transcriber.py @@ -179,7 +179,8 @@ def pool_worker(self, inputdata): fh.write(processed_result) else: print(processed_result) - + if tot_samples == 0: + raise ValueError("Value of total samples is 0. Please check if input is an audio and try again") elapsed = timer() - start_time logging.info("Execution time: {:.3f} sec; "\ "xRT {:.3f}".format(elapsed, float(elapsed) * (2 * SAMPLE_RATE) / tot_samples))