mirror of
https://github.com/openai/whisper.git
synced 2025-11-23 22:15:58 +00:00
allow_pickle=False while loading of mel matrix IN audio.py (#1511)
* Update audio.py The `mel_filters` function is using a `np.load` function to load a pre-computed mel filterbank matrix. This function is not thread-safe, which means that if it is called from multiple threads at the same time, it may corrupt the data. To fix this, you can use the `torch.load` function instead. This function is thread-safe, so it will not corrupt the data if it is called from multiple threads at the same time. * Update audio.py updated the docstring * allow_pickle=False * newline --------- Co-authored-by: Jong Wook Kim <jongwook@nyu.edu> Co-authored-by: Jong Wook Kim <jongwook@openai.com>
This commit is contained in:
parent
b7d277acd5
commit
7dfcd56304
@ -101,9 +101,9 @@ def mel_filters(device, n_mels: int = N_MELS) -> torch.Tensor:
|
|||||||
)
|
)
|
||||||
"""
|
"""
|
||||||
assert n_mels == 80, f"Unsupported n_mels: {n_mels}"
|
assert n_mels == 80, f"Unsupported n_mels: {n_mels}"
|
||||||
with np.load(
|
|
||||||
os.path.join(os.path.dirname(__file__), "assets", "mel_filters.npz")
|
filters_path = os.path.join(os.path.dirname(__file__), "assets", "mel_filters.npz")
|
||||||
) as f:
|
with np.load(filters_path, allow_pickle=False) as f:
|
||||||
return torch.from_numpy(f[f"mel_{n_mels}"]).to(device)
|
return torch.from_numpy(f[f"mel_{n_mels}"]).to(device)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user