当前位置: 首页 > news >正文

华为云Flexus+DeepSeek征文|基于Dify+ModelArts开发AI智能会议助手

1. 背景与目标​

企业会议效率提升需求强烈,传统人工记录会议纪要耗时耗力。本文将指导如何基于Dify平台,结合华为云ModelArts Studio服务华为云实时语音识别(RASR)服务,构建一个智能会议助手,实现:

​语音转文字​(华为云实时语音识别 RASR)
​会议纪要自动生成​(Dify + LLM)
​待办事项提取​(结构化输出)
在这里插入图片描述

在这里插入图片描述

实时语音识别 RASR

实时语音识别(Real-time ASR),将连续的音频流实时转换成文本,语音识别更快。可应用于直播实时字幕、会议实时记录、即时文本生成等场景
在这里插入图片描述

2. 前期准备​

2.1 华为云账号与权限​

注册华为云账号:华为云官网
开通以下服务:
​Dify 应用开发平台​(Dify 控制台)
​语音识别(RASR)​​(RASR 文档)
​大模型服务​(如盘古大模型,或兼容的第三方 LLM)

​2.2 开发环境​

Python 3.8+(用于调用华为云ModelArts API)
requests 库(HTTP 请求)
ffmpeg(音频格式转换,可选)
安装依赖:

pip install requests

​3. 核心功能实现​

​3.1 华为云实时语音识别(RASR)- 语音转文字​

华为云 RASR 支持多种音频格式(如 .wav、.mp3),需先获取 ​Access Key​ 和 ​Project ID。
在这里插入图片描述
在这里插入图片描述

​代码示例:调用华为云 RASR​

import requests
import base64
import json
import time# 华为云 RASR 配置
AK = "your-access-key"  # 替换为你的 Access Key
SK = "your-secret-key"  # 替换为你的 Secret Key
PROJECT_ID = "your-project-id"  # 替换为你的 Project ID
REGION = "cn-north-4"  # 华北-北京四
RASR_URL = f"https://rasr.{REGION}.myhuaweicloud.com/v1/{PROJECT_ID}/speech-to-text"def get_token():"""获取华为云 Token"""token_url = "https://iam.myhuaweicloud.com/v3/auth/tokens"headers = {"Content-Type": "application/json"}data = {"auth": {"identity": {"methods": ["password"],"password": {"user": {"name": "your-username",  # 替换为你的用户名"password": "your-password",  # 替换为你的密码"domain": {"name": "your-domain"}  # 替换为你的域名}}},"scope": {"project": {"id": PROJECT_ID}}}}response = requests.post(token_url, headers=headers, json=data)return response.headers["X-Subject-Token"]def speech_to_text(audio_file_path):"""语音转文字"""token = get_token()headers = {"Content-Type": "application/json","X-Auth-Token": token}# 读取音频文件并转为 Base64with open(audio_file_path, "rb") as f:audio_data = base64.b64encode(f.read()).decode("utf-8")# 构造请求体payload = {"config": {"encoding": "WAV",  # 音频格式(WAV/MP3)"sample_rate": 16000,  # 采样率(16kHz)"language": "zh-CN"  # 语言(中文)},"audio": {"data": audio_data}}response = requests.post(RASR_URL, headers=headers, json=payload)result = response.json()if "result" in result:return result["result"]["text"]else:raise Exception("RASR 转换失败: " + str(result))# 测试
if __name__ == "__main__":text = speech_to_text("meeting_recording.wav")print("转写结果:", text)

​输出示例:​​

转写结果: 今天的会议主要讨论了项目进度和下一步计划…

​3.2 Dify 平台配置 LLM 会议助手​

​​3.2.1 创建 Dify 应用​

登录 Dify 控制台,点击“创建应用”。
选择“从零开始”或“智能对话助手”模板。
配置 LLM(如华为云盘古大模型或兼容的 GPT 模型)。

在这里插入图片描述

​​3.2.2 设计 Prompt(提示词工程)​​

在 Dify 中配置 LLM 的输入 Prompt,例如:

你是一个智能会议助手,请根据以下会议记录,生成结构化纪要:

  1. 会议主题
  2. 主要讨论内容
  3. 关键决策
  4. 待办事项(格式:- [任务](负责人:XXX,截止时间:XXX))
    会议记录:
    {input_text}

3.2.3 调用 Dify API 生成纪要


Dify 提供 REST API,通过 Python 调用。

​代码示例: 调用 Dify API​

import requestsDIFY_API_URL = "https://api.dify.ai/v1/chat-messages"  # 替换为你的 Dify API 地址
DIFY_API_KEY = "your-dify-api-key"  # 替换为你的 Dify API Keydef generate_meeting_summary(meeting_text):"""调用 Dify LLM 生成会议纪要"""headers = {"Content-Type": "application/json","Authorization": f"Bearer {DIFY_API_KEY}"}payload = {"query": meeting_text,"response_mode": "blocking","user": "user-123"  # 用户标识}response = requests.post(DIFY_API_URL, headers=headers, json=payload)result = response.json()return result["answer"]# 测试
if __name__ == "__main__":meeting_text = speech_to_text("meeting_recording.wav")  # 先转文字summary = generate_meeting_summary(meeting_text)print("会议纪要:", summary)

输出示例:

会议纪要:

  1. 会议主题:Q3 项目进度汇报
  2. 主要讨论内容:前端开发延迟,后端 API 已完成
  3. 关键决策:增加前端开发人力
  4. 待办事项:
  • [完成登录模块](负责人:张三,截止时间:2024-07-15)
  • [测试支付接口](负责人:李四,截止时间:2024-07-20)

​3.3 完整流程整合


将 RASR 和 Dify API 整合为一个完整脚本:

def meeting_assistant(audio_file_path):"""智能会议助手完整流程"""# 1. 语音转文字print("正在转写语音...")meeting_text = speech_to_text(audio_file_path)print("转写完成:", meeting_text[:100] + "...")  # 打印前 100 字符# 2. 生成纪要print("正在生成纪要...")summary = generate_meeting_summary(meeting_text)print("会议纪要:\n", summary)if __name__ == "__main__":meeting_assistant("meeting_recording.wav")

​4. 部署与扩展​

4.1 部署方式​

​Dify 云服务​:直接使用华为云Flexus托管的 Dify 服务。

在这里插入图片描述

​私有化部署​:在本地服务器部署 Dify 和 RASR 服务(需申请权限)

​4.2 扩展功能​

​待办事项提取为 JSON​:修改 LLM Prompt,让输出更结构化
​多语言支持​:调用华为云翻译服务(ST)。
​前端集成​:开发 Web 页面上传音频并展示纪要。

在这里插入图片描述

<!DOCTYPE html>
<html lang="zh-CN">
<head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>智能会议纪要生成</title><style>body {font-family: 'Arial', sans-serif;max-width: 800px;margin: 0 auto;padding: 20px;line-height: 1.6;}h1 {color: #333;text-align: center;}.upload-container {border: 2px dashed #ccc;padding: 20px;text-align: center;margin-bottom: 20px;border-radius: 5px;}.upload-container:hover {border-color: #999;}#file-input {display: none;}.upload-btn {background-color: #4CAF50;color: white;padding: 10px 20px;border: none;border-radius: 4px;cursor: pointer;font-size: 16px;}.upload-btn:hover {background-color: #45a049;}#status {margin: 20px 0;padding: 10px;border-radius: 4px;}.loading {background-color: #f8f8f8;color: #666;}.success {background-color: #dff0d8;color: #3c763d;}.error {background-color: #f2dede;color: #a94442;}#summary {white-space: pre-wrap;background-color: #f9f9f9;padding: 15px;border-radius: 4px;border: 1px solid #ddd;margin-top: 20px;}</style>
</head>
<body><h1>智能会议纪要生成</h1><div class="upload-container"><p>点击下方按钮上传会议录音文件(支持WAV/MP3格式)</p><input type="file" id="file-input" accept=".wav,.mp3"><button class="upload-btn" id="upload-btn">选择文件并生成纪要</button><p id="file-name">未选择文件</p></div><div id="status"></div><h2>会议纪要</h2><div id="summary">纪要将在此处显示...</div><script>document.getElementById('upload-btn').addEventListener('click', function() {document.getElementById('file-input').click();});document.getElementById('file-input').addEventListener('change', function(e) {if (e.target.files.length > 0) {const file = e.target.files[0];document.getElementById('file-name').textContent = '已选择: ' + file.name;} else {document.getElementById('file-name').textContent = '未选择文件';}});document.getElementById('upload-btn').addEventListener('click', function() {const fileInput = document.getElementById('file-input');if (fileInput.files.length === 0) {showStatus('请选择文件后再上传', 'error');return;}const file = fileInput.files[0];if (!['wav', 'mp3'].includes(file.name.split('.').pop().toLowerCase())) {showStatus('只支持WAV或MP3格式的音频文件', 'error');return;}uploadFile(file);});function uploadFile(file) {showStatus('正在上传文件...', 'loading');const formData = new FormData();formData.append('audio', file);fetch('/upload', {method: 'POST',body: formData}).then(response => response.json()).then(data => {if (data.success) {showStatus('纪要生成成功!', 'success');document.getElementById('summary').textContent = data.summary;} else {showStatus('错误: ' + data.error, 'error');}}).catch(error => {showStatus('上传失败: ' + error.message, 'error');});}function showStatus(message, type) {const statusDiv = document.getElementById('status');statusDiv.textContent = message;statusDiv.className = type;}</script>
</body>
</html>

​5. 总结​

🚀 🚀 🚀 通过本文的指导,您已成功在华为云Flexus服务器上部署了Dify-LLM应用开发平台。现在可以开始构建各种基于大语言模型的创新应用,从智能客服到内容生成,可能性无限。

华为云Flexus的强大计算能力与Dify-LLM的便捷开发体验相结合,为AI应用开发提供了高效可靠的解决方案。随着平台的深入使用,您还可以探索更多高级功能和定制选项,以满足特定的业务需求。

在这里插入图片描述

http://www.lqws.cn/news/550153.html

相关文章:

  • 本地部署 WordPress 博客完整指南(基于 XAMPP)
  • nt!MiFlushSectionInternal函数分析从nt!IoSynchronousPageWrite函数到Ntfs!NtfsFsdWrite函数
  • 三阶落地:腾讯云Serverless+Spring Cloud的微服务实战架构
  • React中的ErrorBoundary
  • 【经验】新版Chrome中Proxy SwitchyOmega2已实效,改为ZeroOmega
  • 车载诊断架构 --- 诊断与ECU平台工作说明书
  • SQL Server for Linux 如何实现高可用架构
  • 【策划所需编程知识】
  • 中国双非高校经费TOP榜数据分析
  • 【记录】Ubuntu|Ubuntu服务器挂载新的硬盘的流程(开机自动挂载)
  • SQL学习笔记4
  • MFC获取本机所有IP、局域网所有IP、本机和局域网可连接IP
  • 一起endpoint迷路的问题排查总结
  • 浅谈Apache HttpClient的相关配置和使用
  • git add 报错UnicodeDecodeError: ‘gbk‘ codec can‘t decode byte 0xaf in position 42
  • SOCKS 协议版本 5 (RFC 1928)
  • 【stm32】HAL库开发——CubeMX配置串口通讯(中断方式)
  • VUE使用过程中的碰到问题记录
  • 自动对焦技术助力TGV检测 半导体检测精度大突破
  • 工作台-02.代码开发
  • Linux信号机制:从入门到精通
  • [Python]-基础篇1- 从零开始的Python入门指南
  • 微调大语言模型(生成任务),怎么评估它到底“变好”了?
  • Python网安-zip文件暴力破解
  • Java:链接mysql数据库报错:CommunicationsException: Communications link failure
  • Coze API如何上传文件能得到文件的file_url
  • 缓解停车难的城市密码:4G地磁检测器如何重构车位资源分配
  • Discrete Audio Tokens: More Than a Survey
  • TensorRT-LLM的深度剖析:关键问题与核心局限性
  • Java-异常类