写代码自动把商品介绍转成带货口播稿,颠覆直播不知道说啥。

📅 发布时间:2026/7/5 21:02:02 👁️ 浏览次数:
写代码自动把商品介绍转成带货口播稿,颠覆直播不知道说啥。
商品介绍转带货口播稿自动化工具 项目结构product_to_live/├── README.md # 项目说明文档├── requirements.txt # 依赖包清单├── core/ # 核心模块│ ├── __init__.py│ ├── text_processor.py # 文本处理器│ ├── pain_point_generator.py # 痛点生成器│ ├── script_builder.py # 脚本构建器│ └── voice_optimizer.py # 语音优化器├── utils/ # 工具模块│ ├── __init__.py│ ├── templates.py # 模板管理│ └── helpers.py # 辅助函数├── examples/ # 示例文件│ ├── product_sample.json│ └── output_script.json├── main.py # 主程序入口├── demo.py # 演示脚本└── knowledge_cards.md # 核心知识点卡片 README.md# ️ 商品介绍转带货口播稿自动化工具## 项目简介这是一个基于Python的智能带货口播稿生成系统专为直播带货场景设计。通过分析商品介绍文本自动生成包含**实际应用场景**、**痛点引入**、**核心逻辑讲解**的完整带货脚本。 **适用人群**电商主播、直播运营、内容创作者、数字文化艺术创新创业课程学习者## ✨ 核心功能| 功能模块 | 说明 ||---------|------|| 场景分析 | 自动提取商品适用的真实生活场景 || 痛点挖掘 | AI驱动的用户痛点识别与描述 || 逻辑拆解 | 将产品卖点转化为易懂的逻辑链条 || 话术生成 | 生成符合直播节奏的口语化脚本 || ️ 语音优化 | 针对口语表达的文本优化 |## 快速开始### 1️⃣ 安装依赖bashpip install -r requirements.txt### 2️⃣ 准备商品信息创建 product_info.json 文件json{product_name: 智能保温杯,category: 生活用品,features: [316不锈钢, 智能温控, 24小时保温, 一键开盖],price: 129元,original_price: 299元,target_user: 上班族、学生党}### 3️⃣ 运行程序bashpython main.py --input product_info.json --output live_script.json### 4️⃣ 查看结果bashpython demo.py## 输出示例json{script_title: 智能保温杯带货脚本,sections: [{section_type: scene_introduction,content: 想象一下寒冬早晨赶地铁的你...},{section_type: pain_point,content: 是不是经常遇到这种情况刚泡好的咖啡...},{section_type: core_logic,content: 这款杯子厉害在哪三层真空锁温技术...}],full_script: ...完整口播稿...}## ️ 代码结构core/├── text_processor.py # 文本预处理与关键词提取├── pain_point_generator.py # 痛点分析与生成├── script_builder.py # 脚本组装与格式化└── voice_optimizer.py # 口语化优化处理utils/├── templates.py # 场景化话术模板库└── helpers.py # 通用工具函数## 核心知识点详见 [knowledge_cards.md](knowledge_cards.md)## 贡献指南欢迎提交Issue和PR请确保代码符合PEP8规范。## 许可证MIT License © 2026 Digital Culture Innovation Course requirements.txtjieba0.42.1 # 中文分词snownlp0.12.3 # 中文自然语言处理numpy1.21.0 # 数值计算pandas1.3.0 # 数据处理pyyaml6.0 # YAML配置解析requests2.26.0 # HTTP请求可选用于调用API 核心模块代码core/text_processor.py 文本处理器模块功能商品信息预处理、关键词提取、语义分析import jiebaimport refrom typing import Dict, List, Tuplefrom collections import Counterclass ProductTextProcessor:商品文本处理器核心职责1. 清洗和标准化商品介绍文本2. 提取关键特征词和产品卖点3. 识别目标用户群体4. 分析产品所属场景类别def __init__(self):初始化处理器加载自定义词典self._load_custom_dict()# 场景关键词映射表 - 数字文化艺术课程中的场景化思维应用self.scene_keywords {居家: [家用, 卧室, 客厅, 厨房, 家居, 家庭],办公: [办公室, 工作, 电脑, 会议, 加班, 职场],出行: [旅行, 出差, 户外, 通勤, 路上, 外出],运动: [健身, 跑步, 瑜伽, 户外, 锻炼, 运动],学习: [学生, 学校, 考试, 读书, 自习, 上课],送礼: [礼物, 送人, 礼品, 亲友, 节日, 生日]}# 痛点关键词映射表self.pain_keywords {时间: [慢, 耗时, 等待, 久, 耽误, 来不及],质量: [坏, 烂, 差, 故障, 易损, 不耐用],价格: [贵, 不值, 性价比, 太贵, 划不来],体验: [麻烦, 难用, 复杂, 累, 不舒服, 费劲],效果: [没用, 无效, 不明显, 失望, 达不到]}def _load_custom_dict(self):加载自定义词典技术要点- 扩展jieba分词的专业词汇- 提升特定领域如美妆、数码的分词准确率custom_words [智能控温, 一键操作, 食品级, 防漏设计,长效续航, 快充技术, 人体工学, 亲肤材质]for word in custom_words:jieba.add_word(word)def preprocess_text(self, raw_text: str) - str:文本预处理Args:raw_text: 原始商品介绍文本Returns:清洗后的标准化文本处理逻辑1. 移除特殊符号和多余空格2. 统一标点符号3. 去除无意义修饰词# 移除HTML标签和特殊符号cleaned re.sub(r[^], , raw_text)cleaned re.sub(r[^\u4e00-\u9fa5a-zA-Z0-9。、], , cleaned)# 合并连续空格cleaned re.sub(r\s, , cleaned).strip()return cleaneddef extract_features(self, text: str) - List[str]:提取产品核心特征Args:text: 预处理后的文本Returns:特征词列表算法思路- 基于TF-IDF思想的特征权重计算- 过滤停用词和低价值词汇# 分词处理words jieba.cut(text)# 过滤停用词和单字stopwords {的, 了, 是, 有, 和, 与, 或, 等, 款, 个}filtered_words [w for w in wordsif len(w) 1 and w not in stopwords]# 统计词频返回高频词作为特征word_counts Counter(filtered_words)top_features [w for w, _ in word_counts.most_common(10)]return top_featuresdef identify_scenes(self, text: str) - List[Tuple[str, float]]:识别适用场景Args:text: 商品描述文本Returns:[(场景名, 匹配度), ...] 按匹配度降序排列应用场景描述在直播带货中准确描述使用场景能让观众产生代入感这是数字文化艺术课程中情境化叙事的典型应用scene_scores []for scene, keywords in self.scene_keywords.items():score sum(1 for kw in keywords if kw in text)if score 0:# 归一化分数scene_scores.append((scene, score / len(keywords)))return sorted(scene_scores, keylambda x: x[1], reverseTrue)def detect_pain_points(self, category: str, features: List[str]) - List[Dict]:检测潜在用户痛点Args:category: 产品分类features: 产品特征列表Returns:痛点描述列表引入痛点痛点是购买决策的关键触发点本方法结合产品分类和特征预测用户可能遇到的问题pain_points []# 根据产品分类选择基础痛点模板base_pains {数码电子: [设备卡顿影响效率, 电池续航不足, 操作复杂学不会],家居用品: [清洁维护麻烦, 占用空间大, 质量不耐用],美妆护肤: [效果不明显, 刺激皮肤, 性价比低],服装配饰: [尺码不合适, 易皱易变形, 搭配困难]}# 获取基础痛点category_pains base_pains.get(category, base_pains[家居用品])# 为每个痛点添加具体化描述for pain in category_pains:pain_points.append({pain_category: self._categorize_pain(pain),description: pain,intensity: self._calculate_intensity(pain, features)})return pain_pointsdef _categorize_pain(self, pain_desc: str) - str:将痛点归类到预定义的痛点类别for category, keywords in self.pain_keywords.items():if any(kw in pain_desc for kw in keywords):return categoryreturn 其他def _calculate_intensity(self, pain: str, features: List[str]) - int:计算痛点强度 (1-5分)核心逻辑讲解痛点强度 基础权重 特征关联度- 基础权重根据痛点类型预设- 特征关联度产品特征能解决该痛点的程度base_weight 3 # 默认中等强度# 根据关键词调整基础权重intensity_boost {时间: 1, 质量: 2, 价格: 1,体验: 1, 效果: 2}for cat, boost in intensity_boost.items():if self._categorize_pain(pain) cat:base_weight min(5, base_weight boost)breakreturn base_weightdef analyze_target_user(self, text: str) - Dict:分析目标用户群体Args:text: 商品描述Returns:目标用户画像字典user_groups {年龄层: [],职业特征: [],消费特点: [],使用习惯: []}# 年龄层识别age_patterns {年轻人: [年轻, 潮流, 时尚, 新潮, Z世代],中年人: [成熟, 稳重, 品质, 实用, 家庭],老年人: [老年, 父母, 长辈, 易用, 健康]}for group, patterns in age_patterns.items():if any(p in text for p in patterns):user_groups[年龄层].append(group)return user_groupscore/pain_point_generator.py 痛点生成器模块功能基于产品信息生成有感染力的痛点描述核心教学点用户心理洞察与场景化表达from typing import List, Dictfrom dataclasses import dataclassimport randomdataclassclass PainPoint:痛点数据类属性说明- trigger: 触发场景什么情况下会出现这个痛点- problem: 具体问题表现- emotion: 用户情绪反应- cost: 带来的损失/困扰trigger: strproblem: stremotion: strcost: strintensity: int # 1-5, 痛点强度class PainPointGenerator:痛点生成器设计理念在直播带货中痛点的描述需要扎心要让观众产生这说的就是我的共鸣这是数字文化艺术中共情设计的应用def __init__(self):初始化痛点生成器加载话术模板库self.templates self._load_templates()def _load_templates(self) - Dict:加载痛点话术模板模板设计原则1. 具体场景化避免抽象描述2. 情绪可视化让观众感受到痛苦3. 后果明确化放大痛点带来的影响return {时间浪费: {triggers: [早上急着出门时,开会前最后一分钟,下班高峰期路上,周末想睡懒觉时],problems: [却发现{}还没准备好,还得花时间等{},手忙脚乱找不到{},不得不重新再来一遍],emotions: [那种焦急上火的感觉,瞬间就想发火,整个人都不好了,恨不得穿越回去],costs: [一整天的好心情都毁了,重要的事情被耽误了,还差点迟到被扣钱,连带着家人也被影响]},质量问题: {triggers: [用了不到一周就,关键时刻突然,刚买回来就发现,朋友聚会时竟然],problems: [出现{}问题,直接罢工不干了,跟描述完全不符,让场面一度很尴尬],emotions: [气得想退货,对品牌彻底失望,感觉被欺骗了,再也不想买这类产品],costs: [钱花了还生一肚子气,影响工作进度,还得重新花钱买新的,坏了口碑和朋友信任]},使用体验: {triggers: [第一次尝试使用时,教老人家怎么用时,赶时间想快速操作时,双手都占着的时候],problems: [发现操作太复杂,怎么都搞不明白,需要好几个步骤,根本不符合直觉],emotions: [挫败感特别强,越急越出错,怀疑自己智商,索性不用了],costs: [学习成本太高,时间全浪费在摸索上,好东西被闲置,还得找简单替代品]},经济压力: {triggers: [看到心动的产品时,算完总账才发现,对比完价格后,想给家人买时],problems: [价格高得离谱,性价比实在太低,同样功能别家更便宜,钱包真的扛不住],emotions: [只能望而却步,纠结到失眠,感觉不值得,只能忍痛放弃],costs: [错过真正需要的好物,将就买便宜的反而更费钱,心里一直惦记着,生活质量上不去]}}def generate_pain_narratives(self,product_name: str,features: List[str],target_scenes: List[str]) - List[PainPoint]:生成痛点叙述Args:product_name: 产品名称features: 产品特征target_scenes: 目标使用场景Returns:痛点列表核心逻辑讲解1. 根据产品类型选择痛点类别2. 从模板库随机选择元素组合3. 用产品信息填充模板占位符4. 根据特征计算痛点强度pain_narratives []# 确定主要痛点类别基于产品特征primary_pain_types self._determine_pain_types(features)for pain_type in primary_pain_types:if pain_type in self.templates:template self.templates[pain_type]# 随机组合模板元素narrative self._compose_narrative(template,product_name,features,target_scenes)if narrative:pain_narratives.append(narrative)# 限制数量并排序pain_narratives sorted(pain_narratives,keylambda x: x.intensity,reverseTrue)[:3]return pain_narrativesdef _determine_pain_types(self, features: List[str]) - List[str]:根据产品特征确定痛点类型优先级核心逻辑讲解- 分析特征关键词与痛点类型的关联性- 返回最可能的痛点类别列表pain_mapping {智能: [使用体验, 经济压力],便携: [时间浪费, 使用体验],耐用: [质量问题],高端: [经济压力],复杂: [使用体验],快速: [时间浪费],长效: [时间浪费, 质量问题]}detected_types set()for feature in features:for keyword, types in pain_mapping.items():if keyword in feature:detected_types.update(types)# 默认返回常见痛点类型if not detected_types:detected_types {时间浪费, 质量问题, 使用体验}return list(detected_types)def _compose_narrative(self,template: Dict,product_name: str,features: List[str],scenes: List[str]) - PainPoint:组合单个痛点叙述引入痛点技巧- 触发场景要具体且常见- 问题描述要形象生动- 情绪描述要引发共鸣- 后果说明要戳中要害try:trigger random.choice(template[triggers])problem random.choice(template[problems]).format(product_name)emotion random.choice(template[emotions])cost random.choice(template[costs])# 计算痛点强度intensity self._calculate_intensity(template, features, scenes)return PainPoint(triggertrigger,problemproblem,emotionemotion,costcost,intensityintensity)except IndexError:return Nonedef _calculate_intensity(self,template: Dict,features: List[str],scenes: List[str]) - int:计算痛点强度评分评分维度1. 场景普遍性越普遍强度越高2. 特征缺失度产品缺少对应特征则强度高3. 情绪冲击度负面词汇密度base_score 3# 场景普遍性加成common_scenes {居家, 办公, 出行}scene_match len(set(scenes) common_scenes)base_score min(scene_match, 2)# 特征匹配检查简化版feature_text .join(features)negative_indicators [复杂, 慢, 贵, 难]has_negative any(ind in feature_text for ind in negative_indicators)if has_negative:base_score - 1 # 产品已有改进痛点强度降低return max(1, min(5, base_score))def format_for_live(self, pain_point: PainPoint) - str:将痛点格式化为直播口播用语语音优化要点- 多用口语化表达- 加入停顿标记- 增强情绪感染力script f【痛点引入】{pain_point.trigger}——{pain_point.problem}{pain_point.emotion}你知道吗{pain_point.cost}停顿2秒眼神扫视观众我就问大家这种事你们遇到过吗评论区打个1让我看看有多少同路人return scriptcore/script_builder.py 脚本构建器模块功能将各模块输出整合成完整的带货口播稿核心教学点内容架构设计与节奏把控from typing import Dict, List, Optionalfrom dataclasses import dataclass, fieldimport jsonfrom datetime import timedeltadataclassclass ScriptSection:脚本章节数据类用于组织口播稿的结构化内容section_id: intsection_type: str # scene, pain, logic, solution, ctatitle: strcontent: strduration_estimate: int # 预估时长秒key_points: List[str] field(default_factorylist)visual_cues: List[str] field(default_factorylist)class LiveScriptBuilder:直播脚本构建器设计理念好的直播脚本像一部微电影有起承转合有情绪起伏有行动召唤这是数字文化艺术中叙事结构设计的实践def __init__(self):初始化脚本构建器self.sections: List[ScriptSection] []self.section_counter 0self.total_duration 0def build_complete_script(self,product_info: Dict,pain_points: List,features: List[str],scenes: List[str]) - Dict:构建完整带货脚本核心逻辑讲解脚本结构 开场吸睛 场景代入 痛点扎心 方案呈现 逻辑证明 价值塑造 行动召唤这是AIDA营销模型在直播场景的变体应用self.sections []self.section_counter 0# 1. 开场吸睛self._add_opening_section(product_info)# 2. 场景代入self._add_scene_section(scenes, product_info)# 3. 痛点扎心self._add_pain_sections(pain_points)# 4. 方案呈现self._add_solution_section(product_info, features)# 5. 逻辑证明self._add_logic_section(features, product_info)# 6. 价值塑造self._add_value_section(product_info)# 7. 行动召唤self._add_cta_section(product_info)return self._compile_final_script()def _add_opening_section(self, product_info: Dict):添加开场章节开场三要素1. 身份建立我是谁为什么推荐2. 悬念设置今天有什么惊喜3. 价值预告能解决什么问题self.section_counter 1opening_content f【开场·黄金3秒】哈喽家人们欢迎来到{product_info.get(brand, 好物)}专场身体前倾语速稍快制造紧迫感今天要给大家安利的这个宝贝我敢说90%的人都需要不是我吹用过之后你们一定会回来谢我停顿环视镜头先别急着划走因为今天的价格我怕你不敢信{product_info[product_name]}到底有多神听我给你们细细道来section ScriptSection(section_idself.section_counter,section_typeopening,title开场吸睛,contentopening_content,duration_estimate20,key_points[身份建立, 悬念设置, 价值预告],visual_cues[展示产品包装, 比心手势, 神秘微笑])self.sections.append(section)def _add_scene_section(self, scenes: List, product_info: Dict):添加场景代入章节实际应用场景描述通过具体生活场景让观众产生这就是我的代入感这是数字文化艺术中情境化思维的核心应用self.section_counter 1# 选择最匹配的场景primary_scene scenes[0][0] if scenes else 日常使用scene_descriptions {居家: f想象一下周末的早晨你正窝在沙发上追剧...,办公: f想想看办公室里你正忙着赶项目报告...,出行: f画面切到高铁上利用AI解决实际问题如果你觉得这个工具好用欢迎关注长安牧笛