add
游雁
2024-05-14 699b006ee5a6d0748fc9d37f7c068af7c98c2c8e
funasr/utils/misc.py
@@ -70,11 +70,27 @@
    yaml_file = os.path.join(kwargs.get("output_dir", "./"), "config.yaml")
    OmegaConf.save(config=kwargs, f=yaml_file)
    print(kwargs)
    logging.info(f"kwargs: {kwargs}")
    logging.info("config.yaml is saved to: %s", yaml_file)
    # model_path = kwargs.get("model_path")
    # if model_path is not None:
    #     config_json = os.path.join(model_path, "configuration.json")
    #     if os.path.exists(config_json):
    #         shutil.copy(config_json, os.path.join(kwargs.get("output_dir", "./"), "configuration.json"))
    model_path = kwargs.get("model_path", None)
    if model_path is not None:
        config_json = os.path.join(model_path, "configuration.json")
        if os.path.exists(config_json):
            shutil.copy(
                config_json, os.path.join(kwargs.get("output_dir", "./"), "configuration.json")
            )
def extract_filename_without_extension(file_path):
    """
    从给定的文件路径中提取文件名(不包含路径和扩展名)
    :param file_path: 完整的文件路径
    :return: 文件名(不含路径和扩展名)
    """
    # 首先,使用os.path.basename获取路径中的文件名部分(含扩展名)
    filename_with_extension = os.path.basename(file_path)
    # 然后,使用os.path.splitext分离文件名和扩展名
    filename, extension = os.path.splitext(filename_with_extension)
    # 返回不包含扩展名的文件名
    return filename