cleanup whisper a little (#639)

This commit is contained in:
Awni Hannun
2024-03-30 13:13:58 -07:00
committed by GitHub
parent f6283ef7ce
commit 78c431dc25
6 changed files with 237 additions and 221 deletions

View File

@@ -239,12 +239,13 @@ def generate(
),
range(max_tokens),
):
if token == tokenizer.eos_token_id:
break
token = token.item()
if n == 0:
prompt_time = time.perf_counter() - tic
tic = time.perf_counter()
tokens.append(token.item())
if token == tokenizer.eos_token_id:
break
tokens.append(token)
if verbose:
s = tokenizer.decode(tokens)