debug: 修复了多个bug

1.完成了端侧发送杂音识别
2.修复minimax返回帧解析错误bug
3.修复了返回过慢的bug
This commit is contained in:
killua committed 2024-06-10 02:28:16 +08:00
1 parent 02272c8a8b
commit dba43836b6
9 files changed
+193 -88

No files matched your search

+37 -6
View File
@@ -1,14 +1,14 @@
import json
import time
import base64
from datetime import datetime
import io
from websocket import create_connection
data = {
"text": "",
"audio": "",
"meta_info": {
"session_id":"a36c9bb4-e813-4f0e-9c75-18e049c60f48",
"session_id":"469f4a99-12a5-45a6-bc91-353df07423b6",
"stream": True,
"voice_synthesize": True,
"is_end": False,
@@ -48,10 +48,17 @@ def send_json():
# 发送最后一个数据块和流结束信号
send_audio_chunk(websocket, b'') # 发送空数据块表示结束
# 等待并打印接收到的数据
print("等待接收:", datetime.now())
wait_start_time = time.time()
print("开始等待返回数据:", datetime.now().strftime('%Y-%m-%d %H:%M:%S.%f'))
audio_bytes = b''
is_receive_first_frame = False
while True:
data_ws = websocket.recv()
if not is_receive_first_frame:
wait_end_time = time.time()
print("等待时间:", wait_end_time - wait_start_time)
is_receive_first_frame = True
try:
message_json = json.loads(data_ws)
print(message_json) # 打印接收到的消息
@@ -59,10 +66,34 @@ def send_json():
break # 如果没有接收到消息,则退出循环
except Exception as e:
audio_bytes += data_ws
print(e)
# print(e)
print("接收完毕:", datetime.now())
websocket.close()
# 模拟检测到杂音时,只发一帧end
def send_one_end_frame():
websocket = create_connection('ws://114.214.236.207:7878/api/chat/streaming/temporary')
data["meta_info"]["is_end"] = True
send_audio_chunk(websocket, b'') # 发送空数据块表示结束
audio_bytes = b''
is_receive_first_frame = False
while True:
data_ws = websocket.recv()
if not is_receive_first_frame:
wait_end_time = time.time()
is_receive_first_frame = True
try:
message_json = json.loads(data_ws)
print(message_json) # 打印接收到的消息
if message_json["type"] == "close":
break # 如果没有接收到消息,则退出循环
except Exception as e:
audio_bytes += data_ws
# print(e)
websocket.close()
# 启动事件循环
send_json()
# send_json()
send_one_end_frame()