Day5:AI + Python 智能整理会议纪要,从录音到待办一键搞定
一、开会半小时,纪要写两小时?
这是职场最常见的场景之一:
上午10点,你参加了一场重要会议,参会8人,讨论了项目进度、风险排查、下周计划……
会议很高效,50分钟结束。
但你看着会议纪要模板发呆:
两小时过去,纪要还没写完。
或者更糟的情况:
你临时被拉进一个会,手上没笔没纸,全凭记忆。
会后老板问:「会上定的 deadline 是哪天?」
你:「……好像是下周五?」
老板:「是下周四。」
这种尴尬,一次都不想再经历。
二、会议纪要的自动化思路
传统纪要工作流:
会议录音 → 人工听写(2小时)→ 整理成文(1小时)→ 提取待办(30分钟)
自动化工作流:
会议录音 → AI 语音识别(5分钟)→ AI 提取关键信息(1分钟)→ 生成纪要(1分钟)
核心技术栈:
- 语音识别:将录音转为文字(Whisper / 讯飞 / 百度语音)
- 文本处理
- AI 提取
三、方案一:本地 Whisper 语音识别
OpenAI 开源的 Whisper 是目前最可靠的本地语音转文字方案,支持中文,准确率很高。
3.1 安装 Whisper
pip install openai-whisper# 还需要安装 ffmpeg(Windows 用户)# 下载地址:https://ffmpeg.org/download.html
3.2 语音转文字代码
def transcribe_audio(audio_path, output_text_path=None):# 模型选择:tiny/base/small/medium/large,越大越准越慢model = whisper.load_model("base")print(f"正在转录:{audio_path}")result = model.transcribe(transcript = result["text"]with open(output_text_path, "w", encoding="utf-8") as f:print(f"转录完成,已保存至:{output_text_path}")"meeting_2026_04_10.mp3",print(f"转录文本长度:{len(text)} 字符")
运行效果:
正在转录:meeting_2026_04_10.mp3Detecting language using up to the first 30 seconds...Detected language: Chinese转录完成,已保存至:meeting_transcript.txt
3.3 分段转录(带时间戳)
会议很长时,需要知道每句话是谁说的、在什么时间:
def transcribe_with_timestamps(audio_path, output_path=None):model = whisper.load_model("base")result = model.transcribe(audio_path, language="zh")segments = result["segments"]start = format_time(seg["start"])end = format_time(seg["end"])text = seg["text"].strip()formatted_lines.append(f"[{start} - {end}] {text}")transcript = "\n".join(formatted_lines)with open(output_path, "w", encoding="utf-8") as f:def format_time(seconds):mins = int(seconds // 60)return f"{mins:02d}:{secs:02d}"transcribe_with_timestamps("meeting.mp3", "meeting_with_time.txt")
输出示例:
[00:00 - 00:08] 好,我们开始今天的项目周会[00:09 - 00:23] 首先请张三汇报一下前端进度[00:24 - 01:15] 好的,前端页面已经完成了80%,剩下的主要是详情页优化...
四、方案二:云端语音识别 API
如果不想本地跑模型,可以用云服务商的 API:
以讯飞为例:
from datetime import datetimefrom urllib.parse import urlencodedef xunfei_asr(audio_path, app_id, api_key, api_secret):with open(audio_path, "rb") as f:audio_base64 = base64.b64encode(audio_data).decode()url = "https://iat-api.xfyun.cn/v2/iat""Content-Type": "application/json","X-CurTime": str(int(datetime.now().timestamp())),"X-Param": base64.b64encode(json.dumps({"X-CheckSum": "" # 实际需要计算response = requests.post(url, headers=headers, json=body)if result.get("code") == "0":raise Exception(f"识别失败:{result}")
注:各云厂商 API 的鉴权方式不同,需要参考官方文档。实际使用时建议用官方 SDK。
五、AI 提取关键信息
转录完的文字往往是「流水账」,需要提取:
5.1 使用 LLM 提取结构化信息
def extract_meeting_info(transcript, api_key):请从以下会议记录中提取关键信息,以 JSON 格式返回:- action_items: 待办事项列表,每项包含 task(任务描述)、assignee(负责人)、deadline(截止日期)response = openai.ChatCompletion.create({"role": "system", "content": "你是一个专业的会议纪要助手。"},{"role": "user", "content": prompt}result = response.choices[0].message.contentreturn json.loads(result)张三汇报了前端进度,目前完成80%,预计下周四全部完成。王五提出测试用例需要补充,他负责本周五前完成补充。info = extract_meeting_info(transcript, "your-openai-api-key")print(json.dumps(info, ensure_ascii=False, indent=2))
输出示例:
"participants": ["张三", "李四", "王五"],"decisions": ["下周三进行整体提测"],"summary": "本次周会主要讨论了项目进度,前端完成80%,后端API已联调,确定下周三提测。"
5.2 使用本地 LLM(无需联网)
如果担心数据隐私,可以用本地模型如 Ollama:
def extract_with_ollama(transcript):prompt = f"""从会议记录中提取:主题、参会人、关键决策、待办事项。response = requests.post("http://localhost:11434/api/generate", json={"model": "llama2-chinese", # 或其他模型return result["response"]
六、生成标准化会议纪要
提取完信息,生成标准格式的纪要文档:
def generate_meeting_minutes(info, output_path):from datetime import datetime**会议主题**:{info.get('topic', '未指定')}**会议时间**:{datetime.now().strftime('%Y年%m月%d日')}**参会人员**:{'、'.join(info.get('participants', []))}{info.get('summary', '无')}for i, decision in enumerate(info.get('decisions', []), 1):content += f"{i}. {decision}\n"content += "\n---\n\n## 三、待办事项\n\n| 序号 | 任务 | 负责人 | 截止日期 | 状态 |\n|------|------|--------|----------|------|\n"for i, item in enumerate(info.get('action_items', []), 1):content += f"| {i} | {item.get('task', '-')} | {item.get('assignee', '-')} | {item.get('deadline', '-')} | 待完成 |\n"**发送时间**:""" + datetime.now().strftime('%Y-%m-%d %H:%M')with open(output_path, "w", encoding="utf-8") as f:print(f"会议纪要已生成:{output_path}")generate_meeting_minutes(info, "meeting_minutes_2026_04_10.md")
输出效果:
本次周会主要讨论了项目进度,前端完成80%,后端API已联调,确定下周三提测。| 序号 | 任务 | 负责人 | 截止日期 | 状态 ||------|------|--------|----------|------|| 1 | 完成前端剩余开发工作 | 张三 | 下周四 | 待完成 || 2 | 补充测试用例 | 王五 | 本周五 | 待完成 |
七、完整自动化流程
把以上步骤串联起来:
def process_meeting_audio(audio_path, openai_key=None):print("\n[1/4] 语音转文字...")transcript_path = audio_path.replace(".mp3", "_transcript.txt")transcript = transcribe_audio(audio_path, transcript_path)print("\n[2/4] AI 提取关键信息...")info = extract_meeting_info(transcript, openai_key)print("(未提供 API Key,跳过 AI 提取)")"summary": transcript[:100] + "..."print("\n[3/4] 生成会议纪要...")minutes_path = audio_path.replace(".mp3", "_minutes.md")minutes = generate_meeting_minutes(info, minutes_path)print("\n[4/4] 发送邮件通知...")# send_email_with_attachment(...)print(f"- 转录文本:{transcript_path}")print(f"- 会议纪要:{minutes_path}")process_meeting_audio("meeting_2026_04_10.mp3", "your-api-key")
八、进阶技巧
技巧一:说话人分离
多人会议需要区分谁说了什么:
def diarize_speakers(audio_path):from pyannote.audio import Pipelinepipeline = Pipeline.from_pretrained("pyannote/speaker-diarization",use_auth_token="your-huggingface-token"diarization = pipeline(audio_path)for turn, _, speaker in diarization.itertracks(yield_label=True):print(f"{speaker}: {turn.start:.1f}s - {turn.end:.1f}s")
技巧二:会议纪要模板库
按会议类型使用不同模板:
"project": "项目评审纪要模板.md","training": "培训会议纪要模板.md"def generate_with_template(info, template_type="weekly"):template_file = TEMPLATES.get(template_type, TEMPLATES["weekly"])
技巧三:与日历集成
自动从会议邀请中提取信息:
def fetch_meeting_info_from_calendar(meeting_date):client = caldav.DAVClient(url="https://caldav.example.com",principal = client.principal()calendars = principal.calendars()for event in calendars[0].date_search(meeting_date):vevent = event.vobject_instance.vevent"topic": vevent.summary.value,"participants": vevent.attendee_list if hasattr(vevent, 'attendee_list') else [],"start": vevent.dtstart.value
九、Day5 小结
今天我们学习了:
1. 语音识别
2. AI 信息提取
3. 纪要生成
4. 完整工作流
十、今日作业
- 基础练习
- 安装 Whisper,录制一段 1 分钟的语音测试转录
- 尝试 base 和 small 模型,比较速度和准确率
- 实战任务
- 挑战任务
十一、预告
Day6:文件批量整理 —— 自动分类、重命名、归档,让文件管理不再混乱。
我们会用 Python 实现一个智能文件整理器,自动按类型、日期、项目分类文件。
💡 系列回顾
- Day1:Excel 批量清洗
- Day2:Word 批量排版
- Day3:PPT 自动生成
- Day4:邮件通知自动化
- Day5:会议纪要智能整理 ✅
关注「量子位开发手记」,每天解锁一个办公自动化技能