mirror of
https://github.com/openai/whisper.git
synced 2025-11-29 16:38:40 +00:00
Explicitly closing model file after reading it (#630)
This commit is contained in:
parent
4179ed2475
commit
fd8f80c8b8
@ -39,7 +39,8 @@ def _download(url: str, root: str, in_memory: bool) -> Union[bytes, str]:
|
|||||||
raise RuntimeError(f"{download_target} exists and is not a regular file")
|
raise RuntimeError(f"{download_target} exists and is not a regular file")
|
||||||
|
|
||||||
if os.path.isfile(download_target):
|
if os.path.isfile(download_target):
|
||||||
model_bytes = open(download_target, "rb").read()
|
with open(download_target, "rb") as f:
|
||||||
|
model_bytes = f.read()
|
||||||
if hashlib.sha256(model_bytes).hexdigest() == expected_sha256:
|
if hashlib.sha256(model_bytes).hexdigest() == expected_sha256:
|
||||||
return model_bytes if in_memory else download_target
|
return model_bytes if in_memory else download_target
|
||||||
else:
|
else:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user