返回顶部
s

senseaudio-voice-chatbot语音聊天机器人

Build real-time voice chatbot applications with natural conversation flow and customizable personalities. Use when users want to create voice assistants, conversational AI, or interactive voice agents.

作者: admin | 来源: ClawHub
源自
ClawHub
版本
V 1.0.0
安全检测
已通过
326
下载量
免费
免费
0
收藏
概述
安装方式
版本历史

senseaudio-voice-chatbot

SenseAudio 语音聊天机器人

构建具有自然对话流程、情感识别和可定制个性的实时语音聊天机器人应用。

该技能的功能

  • - 创建支持语音的聊天机器人应用
  • 支持低延迟的实时语音对话
  • 实现带上下文的多轮对话
  • 自定义聊天机器人的个性和知识库
  • 与现有应用集成

实施指南

步骤 1:获取可用代理

python
import requests

def getavailableagents(page=1, size=10):
url = https://api.senseaudio.cn/v1/realtime/agents
headers = {Authorization: fBearer {API_KEY}}
params = {page: page, size: size}

response = requests.get(url, headers=headers, params=params)
return response.json()

示例响应:

{

total: 10,

list: [

{

id: 690f53770e9d9d60d98ba7a8,

title: 客服代理,

avatar: https://example.com/avatar.jpg,

intro: 专业客服助手

}

]

}

步骤 2:创建对话会话

python
def createdialoguesession(agentid, newdialogue=True, conv_id=None):
url = https://api.senseaudio.cn/v1/realtime/invoke
headers = {
Authorization: fBearer {API_KEY},
Content-Type: application/json
}

payload = {
agentid: agentid,
newdialogue: newdialogue
}

if not newdialogue and convid:
payload[convid] = convid

response = requests.post(url, headers=headers, json=payload)
return response.json()

返回:

{

conv_id: 9b8260e2-19d9-4609-abe7-3b74ac16b677,

app_id: d4432b04117aj77r7755c2d8e86e140b,

room_id: lO81loRAfmUMFIwY,

roomuserid: 360706506,

token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...

}

步骤 3:连接实时语音

python
import asyncio
import websockets
import json

async def voicechatbotsession(roomid, token, appid):
# 使用 WebRTC 或 WebSocket 进行实时音频传输
# 这是一个简化示例

session_info = {
roomid: roomid,
token: token,
appid: appid
}

# 连接语音服务
# 具体实现取决于实时通信协议
# 基于浏览器的应用通常使用 WebRTC

return session_info

步骤 4:管理对话状态

python
class VoiceChatbot:
def init(self, agentid, apikey):
self.agentid = agentid
self.apikey = apikey
self.conv_id = None
self.room_id = None
self.session_active = False

def start_conversation(self):
开始新对话
result = createdialoguesession(
agentid=self.agentid,
new_dialogue=True
)

self.convid = result[convid]
self.roomid = result[roomid]
self.session_active = True

return result

def continue_conversation(self):
继续现有对话
if not self.conv_id:
raise ValueError(没有可继续的活跃对话)

result = createdialoguesession(
agentid=self.agentid,
new_dialogue=False,
convid=self.convid
)

self.roomid = result[roomid]
return result

def check_status(self):
检查代理是否在运行
url = https://api.senseaudio.cn/v1/realtime/status
headers = {Authorization: fBearer {self.api_key}}
params = {roomid: self.roomid}

response = requests.get(url, headers=headers, params=params)
return response.json()

def end_conversation(self):
停止代理
url = https://api.senseaudio.cn/v1/realtime/leave
headers = {
Authorization: fBearer {self.api_key},
Content-Type: application/json
}
payload = {roomid: self.roomid}

response = requests.post(url, headers=headers, json=payload)
self.session_active = False
return response.json()

高级功能

基于 Web 的语音聊天机器人

html



语音聊天机器人





就绪



多用户支持

python
class ChatbotManager:
def init(self, api_key):
self.apikey = apikey
self.active_sessions = {}

def createsession(self, userid, agent_id):
chatbot = VoiceChatbot(agentid, self.apikey)
sessioninfo = chatbot.startconversation()

self.activesessions[userid] = {
chatbot: chatbot,
sessioninfo: sessioninfo,
started_at: datetime.now()
}

return session_info

def getsession(self, userid):
return self.activesessions.get(userid)

def endsession(self, userid):
if userid in self.activesessions:
session = self.activesessions[userid]
session[chatbot].end_conversation()
del self.activesessions[userid]

对话分析

python
def trackconversationmetrics(convid, roomid):
metrics = {
convid: convid,
roomid: roomid,
start_time: datetime.now(),
end_time: None,
duration: None,
user_messages: 0,
agent_responses: 0
}

return metrics

def updatemetrics(metrics, eventtype):
if eventtype == usermessage:
metrics[user_messages] += 1
elif eventtype == agentresponse:
metrics[agent_responses] += 1
elif eventtype == sessionend:
metrics[end_time] = datetime.now()
metrics[duration] = (metrics[endtime] - metrics[starttime]).total_seconds()

return metrics

使用场景

客服机器人

python
def createcustomerservicebot(agentid):
创建客服语音机器人

chatbot = VoiceChatbot(agentid, APIKEY)

# 开始对话
session = chatbot.start_conversation()

# 监控状态
while chatbot.session_active:
status = chatbot.check_status()
if status[status] == STOPPED:
break

time.sleep(5)

return session

教育助手

python
def createlearningassistant(agentid, studentid):
创建个性化学习助手

chatbot = VoiceChatbot(agentid, APIKEY)

# 开始新课
session = chatbot.start_conversation

标签

skill ai

通过对话安装

该技能支持在以下平台通过对话安装:

OpenClaw WorkBuddy QClaw Kimi Claude

方式一:安装 SkillHub 和技能

帮我安装 SkillHub 和 chatbot-1776107595 技能

方式二:设置 SkillHub 为优先技能安装源

设置 SkillHub 为我的优先技能安装源,然后帮我安装 chatbot-1776107595 技能

通过命令行安装

skillhub install chatbot-1776107595

下载

⬇ 下载 senseaudio-voice-chatbot v1.0.0(免费)

文件大小: 3.96 KB | 发布时间: 2026-4-15 12:02

v1.0.0 最新 2026-4-15 12:02
Initial release of the SenseAudio Voice Chatbot skill.

- Enables real-time, voice-enabled chatbot applications with natural conversation flow.
- Supports multi-turn dialogue, emotion recognition, and customizable personalities.
- Provides implementation examples for session management, agent selection, and integration with web or Python applications.
- Includes guidance for multi-user management and conversation analytics tracking.
- Requires a SenseAudio API key for use.

Archiver·手机版·闲社网·闲社论坛·羊毛社区· 多链控股集团有限公司 · 苏ICP备2025199260号-1

Powered by Discuz! X5.0   © 2024-2025 闲社网·线报更新论坛·羊毛分享社区·http://xianshe.com

p2p_official_large
返回顶部