From b66d1d4469ef0ba66c3c7d8a94e2a03dd683f69b Mon Sep 17 00:00:00 2001 From: dscripka Date: Sun, 2 Apr 2023 08:47:03 -0400 Subject: [PATCH] Bugfix for bulk predict function --- openwakeword/utils.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/openwakeword/utils.py b/openwakeword/utils.py index 7b5340c..2fab0ac 100644 --- a/openwakeword/utils.py +++ b/openwakeword/utils.py @@ -364,6 +364,11 @@ def bulk_predict( # Create openWakeWord model objects n_batches = max(1, len(file_paths)//ncpu) remainder = len(file_paths) % ncpu + + if remainder == len(file_paths): + ncpu = len(file_paths) + remainder = 0 + chunks = [file_paths[i:i+n_batches] for i in range(0, max(1, len(file_paths)-remainder), n_batches)] for i in range(1, remainder+1): chunks[i-1].append(file_paths[-1*i])