允许 model.generate 使用bytes io, 以便不写入文件,节省io时间 (#2343)

This commit is contained in:
maliubiao 2024-12-29 22:33:22 +08:00 committed by GitHub
parent a3a1c55c4c
commit 172a3152b4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -86,8 +86,10 @@ def load_audio_text_image_video(
): # download url to local file
data_or_path_or_list = download_from_url(data_or_path_or_list)
if isinstance(data_or_path_or_list, str) and os.path.exists(data_or_path_or_list): # local file
if (isinstance(data_or_path_or_list, str) and os.path.exists(data_or_path_or_list)) or hasattr(data_or_path_or_list, 'read'): # local file or bytes io
if data_type is None or data_type == "sound":
if hasattr(data_or_path_or_list, "read") and hasattr(data_or_path_or_list, "seek"):
data_or_path_or_list.seek(0)
# if use_ffmpeg:
# data_or_path_or_list = _load_audio_ffmpeg(data_or_path_or_list, sr=fs)
# data_or_path_or_list = torch.from_numpy(data_or_path_or_list).squeeze() # [n_samples,]