diff --git a/weclone-audio/src/SparkTTS.py b/weclone-audio/src/SparkTTS.py index 948ae42..518f5db 100644 --- a/weclone-audio/src/SparkTTS.py +++ b/weclone-audio/src/SparkTTS.py @@ -184,7 +184,8 @@ class SparkTTS: # Trim the output tokens to remove the input tokens generated_ids = [ - output_ids[len(input_ids) :] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids) + output_ids[len(input_ids) :] + for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids) ] # Decode the generated tokens into text @@ -192,7 +193,9 @@ class SparkTTS: # Extract semantic token IDs from the generated text pred_semantic_ids = ( - torch.tensor([int(token) for token in re.findall(r"bicodec_semantic_(\d+)", predicts)]).long().unsqueeze(0) + torch.tensor([int(token) for token in re.findall(r"bicodec_semantic_(\d+)", predicts)]) + .long() + .unsqueeze(0) ) if gender is not None: diff --git a/weclone-audio/src/get_sample_audio.py b/weclone-audio/src/get_sample_audio.py index 4d2d89d..4ca2849 100644 --- a/weclone-audio/src/get_sample_audio.py +++ b/weclone-audio/src/get_sample_audio.py @@ -14,7 +14,9 @@ def main(): default=os.path.join(os.path.dirname(__file__), "sample.wav"), help="Path to save the audio file (default: sample.wav in script directory)", ) - parser.add_argument("--rate", type=int, default=24000, help="Sample rate for audio conversion (default: 24000)") + parser.add_argument( + "--rate", type=int, default=24000, help="Sample rate for audio conversion (default: 24000)" + ) args = parser.parse_args() diff --git a/weclone/cli.py b/weclone/cli.py index 59d6550..0d80e7f 100644 --- a/weclone/cli.py +++ b/weclone/cli.py @@ -203,7 +203,9 @@ def _check_versions(): logger.warning( f"警告:您的 settings.jsonc 文件版本 ({settings_version}) 与项目建议的配置版本 ({config_guide_version}) 不一致。" ) - logger.warning("这可能导致意外行为或错误。请从 settings.template.json 复制或更新您的 settings.jsonc 文件。") + logger.warning( + "这可能导致意外行为或错误。请从 settings.template.json 复制或更新您的 settings.jsonc 文件。" + ) # TODO 根据版本号打印更新日志 logger.warning(f"配置文件更新日志:\n{config_changelog}") elif PYPROJECT_PATH.exists(): # 如果文件存在但未读到版本 diff --git a/weclone/data/chat_parsers/wechat_parser.py b/weclone/data/chat_parsers/wechat_parser.py index 8fc4522..0ea54c6 100644 --- a/weclone/data/chat_parsers/wechat_parser.py +++ b/weclone/data/chat_parsers/wechat_parser.py @@ -24,7 +24,9 @@ def copy_wechat_image_dat(wechat_data_dir): data_processor = DataProcessor() if not os.path.exists(data_processor.csv_folder) or not os.listdir(data_processor.csv_folder): - print(f"错误:目录 '{data_processor.csv_folder}' 不存在或为空,请检查路径并确保其中包含 CSV 聊天数据文件。") + print( + f"错误:目录 '{data_processor.csv_folder}' 不存在或为空,请检查路径并确保其中包含 CSV 聊天数据文件。" + ) return csv_files = data_processor.get_csv_files() diff --git a/weclone/data/qa_generator.py b/weclone/data/qa_generator.py index 1caf5db..de7f907 100644 --- a/weclone/data/qa_generator.py +++ b/weclone/data/qa_generator.py @@ -90,7 +90,9 @@ class DataProcessor: def main(self): if not os.path.exists(self.csv_folder) or not os.listdir(self.csv_folder): - logger.error(f"错误:目录 '{self.csv_folder}' 不存在或为空,请检查路径并确保其中包含 CSV 聊天数据文件。") + logger.error( + f"错误:目录 '{self.csv_folder}' 不存在或为空,请检查路径并确保其中包含 CSV 聊天数据文件。" + ) return csv_files = self.get_csv_files() diff --git a/weclone/eval/cli_demo.py b/weclone/eval/cli_demo.py index 04e3d3a..801b6c3 100644 --- a/weclone/eval/cli_demo.py +++ b/weclone/eval/cli_demo.py @@ -13,7 +13,9 @@ def main(): chat_model = ChatModel() messages = [] - print("Welcome to the CLI application, use `clear` to remove the history, use `exit` to exit the application.") + print( + "Welcome to the CLI application, use `clear` to remove the history, use `exit` to exit the application." + ) while True: try: diff --git a/weclone/utils/config.py b/weclone/utils/config.py index 2582f1a..c5ce5d3 100644 --- a/weclone/utils/config.py +++ b/weclone/utils/config.py @@ -33,7 +33,9 @@ def load_config(arg_type: str): dataset_info_path = os.path.join(config["dataset_dir"], "dataset_info.json") dataset_info = commentjson.load(open(dataset_info_path, "r", encoding="utf-8"))[config["dataset"]] if dataset_info["columns"].get("history") is None: - logger.warning(f"{config['dataset']}数据集不包history字段,尝试使用wechat-sft-with-history数据集") + logger.warning( + f"{config['dataset']}数据集不包history字段,尝试使用wechat-sft-with-history数据集" + ) config["dataset"] = "wechat-sft-with-history" if "image" in s_config["make_dataset_args"]["include_type"]: config["dataset"] = "wechat-mllm-sft" diff --git a/weclone/utils/length_cdf.py b/weclone/utils/length_cdf.py index 7d2e17b..5032176 100644 --- a/weclone/utils/length_cdf.py +++ b/weclone/utils/length_cdf.py @@ -57,7 +57,9 @@ def length_cdf( ) tokenizer_module = load_tokenizer(model_args) template = get_template_and_fix_tokenizer(tokenizer_module["tokenizer"], data_args) # type: ignore - trainset = get_dataset(template, model_args, data_args, training_args, "sft", **tokenizer_module)["train_dataset"] # type: ignore + trainset = get_dataset(template, model_args, data_args, training_args, "sft", **tokenizer_module)[ + "train_dataset" + ] # type: ignore total_num = len(trainset) # type: ignore length_dict = defaultdict(int) for sample in tqdm(trainset["input_ids"], desc="Collecting lengths"): # type: ignore