mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-07-26 09:03:54 +08:00
update:上报聊天音频
This commit is contained in:
@@ -4,7 +4,7 @@ from loguru import logger
|
||||
from config.config_loader import load_config
|
||||
from config.settings import check_config_file
|
||||
|
||||
SERVER_VERSION = "0.3.13"
|
||||
SERVER_VERSION = "0.3.14"
|
||||
|
||||
|
||||
def get_module_abbreviation(module_name, module_dict):
|
||||
|
||||
@@ -146,24 +146,12 @@ def get_agent_models(
|
||||
|
||||
|
||||
def report(
|
||||
mac_address: str, session_id: str, chat_type: int, content: str, opus_data
|
||||
mac_address: str, session_id: str, chat_type: int, content: str, audio
|
||||
) -> Optional[Dict]:
|
||||
"""带熔断的业务方法示例"""
|
||||
if not content or not ManageApiClient._instance:
|
||||
return None
|
||||
try:
|
||||
# 处理opus_data为列表的情况
|
||||
if isinstance(opus_data, list):
|
||||
# 将列表中的所有bytes数据合并
|
||||
combined_data = b"".join(opus_data)
|
||||
else:
|
||||
combined_data = opus_data
|
||||
|
||||
# 将二进制数据转换为Base64编码的字符串
|
||||
opus_data_base64 = (
|
||||
base64.b64encode(combined_data).decode("utf-8") if combined_data else None
|
||||
)
|
||||
|
||||
return ManageApiClient._instance._execute_request(
|
||||
"POST",
|
||||
f"/agent/chat-history/report",
|
||||
@@ -172,7 +160,9 @@ def report(
|
||||
"sessionId": session_id,
|
||||
"chatType": chat_type,
|
||||
"content": content,
|
||||
"opusDataBase64": opus_data_base64,
|
||||
"audioBase64": (
|
||||
base64.b64encode(audio).decode("utf-8") if audio else None
|
||||
),
|
||||
},
|
||||
)
|
||||
except Exception as e:
|
||||
|
||||
Reference in New Issue
Block a user