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 3a25f64 commit 950f3f5
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions tafrigh/recognizers/wit_recognizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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)

Expand Down

0 comments on commit 950f3f5

Please sign in to comment.