允许 model.generate 使用bytes io, 以便不写入文件,节省io时间 (#2343)
| | |
| | | ): # 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,] |