| | |
| | | if isinstance(data_or_path_or_list, str) and os.path.exists(data_or_path_or_list): # local file |
| | | if data_type is None or data_type == "sound": |
| | | data_or_path_or_list, audio_fs = torchaudio.load(data_or_path_or_list) |
| | | data_or_path_or_list = data_or_path_or_list[0, :] |
| | | if kwargs.get("reduce_channels", True): |
| | | data_or_path_or_list = data_or_path_or_list.mean(0) |
| | | elif data_type == "text" and tokenizer is not None: |
| | | data_or_path_or_list = tokenizer.encode(data_or_path_or_list) |
| | | elif data_type == "image": # undo |
| | |
| | | # if data_in is a file or url, set is_final=True |
| | | if "cache" in kwargs: |
| | | kwargs["cache"]["is_final"] = True |
| | | kwargs["cache"]["is_streaming_input"] = False |
| | | elif isinstance(data_or_path_or_list, str) and data_type == "text" and tokenizer is not None: |
| | | data_or_path_or_list = tokenizer.encode(data_or_path_or_list) |
| | | elif isinstance(data_or_path_or_list, np.ndarray): # audio sample point |