Merge branch 'feature/voice_send'

This commit is contained in:
Cai
2025-10-19 20:30:51 +08:00
15 changed files with 674 additions and 219 deletions

View File

@@ -191,13 +191,15 @@ class ASEngineClient:
print(f"Failed to send text to route '{route}': {e}")
return False
def send_voice(self, route: str, voice_data: bytes, id:str) -> bool:
def send_voice(self, route: str, voice_data: bytes, id:str=None) -> bool:
"""
发送语音数据
:param route: 目标路由
:param voice_data: 语音数据字节流
:return: 是否发送成功
"""
if id is None:
id = self.id
if not self.connected:
print("Not connected to server")
return False
@@ -205,7 +207,6 @@ class ASEngineClient:
try:
# 编码语音数据为base64
# voice_data = 'data:image/jpeg;base64,' +base64.b64encode(voice_data).decode('utf-8')
# 发送数据
self.sio.emit(
route,
@@ -289,4 +290,3 @@ class HSAEngineClient(ASEngineClient):
self.send_text('markdown-in', fmd, self.id)
self.send_text('markdown-prompt-in', fmdp, self.id)
self.send_text('score-prompt-in', fsp, self.id)