Skip to content

Commit

Permalink
Remove sleep and use AsyncResult.wait instead of it
Browse files Browse the repository at this point in the history
  • Loading branch information
AliOsm committed Aug 25, 2023
1 parent 15a19c7 commit aa6214c
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions tafrigh/recognizers/wit_recognizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -98,8 +99,6 @@ def recognize(
else None,
}

time.sleep(0.1)

shutil.rmtree(temp_directory)

return transcriptions
Expand Down

0 comments on commit aa6214c

Please sign in to comment.