Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Dec 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion funasr/utils/load_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,]
Expand Down