From 172a3152b42af36443ec6a0a39969471c35b893d Mon Sep 17 00:00:00 2001 From: maliubiao Date: Sun, 29 Dec 2024 22:33:22 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=81=E8=AE=B8=20model.generate=20=E4=BD=BF?= =?UTF-8?q?=E7=94=A8bytes=20io,=20=E4=BB=A5=E4=BE=BF=E4=B8=8D=E5=86=99?= =?UTF-8?q?=E5=85=A5=E6=96=87=E4=BB=B6=EF=BC=8C=E8=8A=82=E7=9C=81io?= =?UTF-8?q?=E6=97=B6=E9=97=B4=20(#2343)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- funasr/utils/load_utils.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/funasr/utils/load_utils.py b/funasr/utils/load_utils.py index 1d80fcf36..072b578ef 100644 --- a/funasr/utils/load_utils.py +++ b/funasr/utils/load_utils.py @@ -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,]