'commit'
This commit is contained in:
@@ -84,17 +84,8 @@ async def streaming_chat(websocket: WebSocket):
|
||||
except Exception as e:
|
||||
logger.error(f"发送ASR结果失败: {str(e)}")
|
||||
return
|
||||
|
||||
# 定义音频回调函数,将音频块发送给前端
|
||||
async def audio_callback(audio_chunk):
|
||||
logger.info(f"发送音频块,大小: {len(audio_chunk)}")
|
||||
try:
|
||||
await websocket.send_bytes(audio_chunk)
|
||||
logger.info("音频块发送成功")
|
||||
except Exception as e:
|
||||
logger.error(f"发送音频块失败: {str(e)}")
|
||||
raise
|
||||
|
||||
|
||||
|
||||
# 获取学伴响应内容(包含题目信息)
|
||||
logger.info("获取学伴响应内容...")
|
||||
llm_chunks = []
|
||||
@@ -160,16 +151,12 @@ async def process_asr(audio_path: str) -> dict:
|
||||
try:
|
||||
# 上传文件到华为云OBS
|
||||
audio_url = upload_file_to_obs(audio_path)
|
||||
|
||||
# 创建ASR客户端实例
|
||||
asr_client = ASRClient()
|
||||
|
||||
# 设置音频文件URL
|
||||
asr_client.file_url = audio_url
|
||||
|
||||
# 处理ASR任务并获取文本结果
|
||||
text_result = asr_client.process_task()
|
||||
|
||||
# 构建返回结果
|
||||
return {
|
||||
"text": text_result,
|
||||
|
Reference in New Issue
Block a user