Skip to content

Commit

Permalink
Return the best only if all fallbacks failed
Browse files Browse the repository at this point in the history
  • Loading branch information
TheoBoyer committed May 21, 2023
1 parent a72a044 commit f677284
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion whisper/transcribe.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ def decode_with_fallback(segment: torch.Tensor) -> DecodingResult:
temperatures = (
[temperature] if isinstance(temperature, (int, float)) else temperature
)
decode_result = None
results = {}

for t in temperatures:
Expand Down Expand Up @@ -183,8 +184,11 @@ def decode_with_fallback(segment: torch.Tensor) -> DecodingResult:
needs_fallback = False # silence
if not needs_fallback:
break
else:
# all failed
return max(results.values(), key=lambda r: r.avg_logprob)

return max(results.values(), key=lambda r: r.avg_logprob)
return decode_result

seek = 0
input_stride = exact_div(
Expand Down

0 comments on commit f677284

Please sign in to comment.