diff --git a/tafrigh/recognizers/wit_recognizer.py b/tafrigh/recognizers/wit_recognizer.py index 74bec36..ee52eac 100644 --- a/tafrigh/recognizers/wit_recognizer.py +++ b/tafrigh/recognizers/wit_recognizer.py @@ -83,13 +83,10 @@ def recognize( for index, segment in enumerate(segments) ] - transcriptions = [] - with tqdm(total=len(segments), disable=self.verbose is not False) as pbar: - while async_results: - if async_results[0].ready(): - transcriptions.append(async_results.pop(0).get()) - pbar.update(1) + for async_result in async_results: + async_result.wait() + pbar.update(1) yield { 'progress': round(len(transcriptions) / len(segments) * 100, 2), @@ -98,7 +95,7 @@ def recognize( else None, } - time.sleep(0.1) + transcriptions = [async_result.get() for async_result in async_results] shutil.rmtree(temp_directory)