diff --git a/tafrigh/recognizers/wit_recognizer.py b/tafrigh/recognizers/wit_recognizer.py index 74bec36..3c9b51a 100644 --- a/tafrigh/recognizers/wit_recognizer.py +++ b/tafrigh/recognizers/wit_recognizer.py @@ -86,10 +86,11 @@ def recognize( 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) + + transcriptions.append(async_result.get()) yield { 'progress': round(len(transcriptions) / len(segments) * 100, 2), @@ -98,8 +99,6 @@ def recognize( else None, } - time.sleep(0.1) - shutil.rmtree(temp_directory) return transcriptions