🚀 商品介绍转带货口播稿自动化工具
📁 项目结构
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️⃣ 安装依赖
bash
pip install -r requirements.txt
2️⃣ 准备商品信息
创建 product_info.json 文件:
json
{
"product_name": "智能保温杯",
"category": "生活用品",
"features": ["316不锈钢", "智能温控", "24小时保温", "一键开盖"],
"price": "129元",
"original_price": "299元",
"target_user": "上班族、学生党"
}
3️⃣ 运行程序
bash
python main.py --input product_info.json --output live_script.json
4️⃣ 查看结果
bash
python 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 # 通用工具函数
📚 核心知识点
🤝 贡献指南
欢迎提交Issue和PR!请确保代码符合PEP8规范。
📄 许可证
MIT License © 2026 Digital Culture Innovation Course
📦 requirements.txt
jieba>=0.42.1 # 中文分词 snownlp>=0.12.3 # 中文自然语言处理 numpy>=1.21.0 # 数值计算 pandas>=1.3.0 # 数据处理 pyyaml>=6.0 # YAML配置解析 requests>=2.26.0 # HTTP请求(可选,用于调用API)
🔧 核心模块代码
core/text_processor.py
""" 📄 文本处理器模块 功能:商品信息预处理、关键词提取、语义分析 """
import jieba import re from typing import Dict, List, Tuple from collections import Counter
class 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 cleaned
def extract_features(self, text: str) -> List[str]:
"""
提取产品核心特征
Args:
text: 预处理后的文本
Returns:
特征词列表
算法思路:
- 基于TF-IDF思想的特征权重计算
- 过滤停用词和低价值词汇
"""
# 分词处理
words = jieba.cut(text)
# 过滤停用词和单字
stopwords = {"的", "了", "是", "有", "和", "与", "或", "等", "款", "个"}
filtered_words = [ w for w in words if 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_features
def 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, key=lambda x: x[1], reverse=True)
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_points
def _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 category
return "其他"
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)
break
return base_weight
def 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_groups
core/pain_point_generator.py
""" 😣 痛点生成器模块 功能:基于产品信息生成有感染力的痛点描述 核心教学点:用户心理洞察与场景化表达 """
from typing import List, Dict from dataclasses import dataclass import random
@dataclass class PainPoint: """ 痛点数据类
属性说明:
- trigger: 触发场景(什么情况下会出现这个痛点)
- problem: 具体问题表现
- emotion: 用户情绪反应
- cost: 带来的损失/困扰
"""
trigger: str
problem: str
emotion: str
cost: str
intensity: 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,
key=lambda x: x.intensity,
reverse=True
)[:3]
return pain_narratives
def _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(
trigger=trigger,
problem=problem,
emotion=emotion,
cost=cost,
intensity=intensity
)
except IndexError:
return None
def _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 script
core/script_builder.py
""" 🎭 脚本构建器模块 功能:将各模块输出整合成完整的带货口播稿 核心教学点:内容架构设计与节奏把控 """
from typing import Dict, List, Optional from dataclasses import dataclass, field import json from datetime import timedelta
@dataclass class ScriptSection: """ 脚本章节数据类
用于组织口播稿的结构化内容
"""
section_id: int
section_type: str # scene, pain, logic, solution, cta
title: str
content: str
duration_estimate: int # 预估时长(秒)
key_points: List[str] = field(default_factory=list)
visual_cues: List[str] = field(default_factory=list)
class LiveScriptBuilder: """ 直播脚本构建器
设计理念:
好的直播脚本像一部微电影
有起承转合,有情绪起伏,有行动召唤
这是数字文化艺术中"叙事结构设计"的实践
"""
def __init__(self):
"""初始化脚本构建器"""
self.sections: List[ScriptSection] = []
self.section_counter = 0
self.total_duration = 0
def 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 += 1
opening_content = f"""【开场·黄金3秒】
哈喽家人们!欢迎来到{product_info.get('brand', '好物')}专场!
(身体前倾,语速稍快,制造紧迫感) 今天要给大家安利的这个宝贝,我敢说90%的人都需要! 不是我吹,用过之后你们一定会回来谢我!
(停顿,环视镜头) 先别急着划走,因为今天的价格,我怕你不敢信! {product_info['product_name']},到底有多神? 听我给你们细细道来~"""
section = ScriptSection(
section_id=self.section_counter,
section_type="opening",
title="开场吸睛",
content=opening_content,
duration_estimate=20,
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解决实际问题,如果你觉得这个工具好用,欢迎关注长安牧笛!