Skip to content

Commit

Permalink
修复funasr指令页面
Browse files Browse the repository at this point in the history
  • Loading branch information
worm128 committed Jul 24, 2024
1 parent 19cc0e5 commit dfb9efe
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 23 deletions.
25 changes: 17 additions & 8 deletions api.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ def http_cmd():
cmdCore.cmd("all",cmdstr,"0", "http_cmd")
return jsonify({"status": "成功"})

# http说话复读
# http说话复读【postman调用】
@app.route("/say", methods=["POST"])
def http_say():
text = request.data.decode("utf-8")
Expand All @@ -157,17 +157,17 @@ def http_emote():
text = data["text"]
emote_thread1 = Thread(target=emoteOper.emote_ws, args=(1, 0.2, text))
emote_thread1.start()
return "ok"
return jsonify({"status": "成功"})

# http唱歌接口处理
# http唱歌接口处理【fastgpt调用】
@app.route("/http_sing", methods=["GET"])
def http_sing():
songname = request.args["songname"]
username = "所有人"
singCore.http_sing(songname,username)
return jsonify({"status": "成功"})

# http绘画接口处理
# http绘画接口处理【fastgpt调用】
@app.route("/http_draw", methods=["GET"])
def http_draw():
drawname = request.args["drawname"]
Expand All @@ -184,7 +184,7 @@ def http_scene():
return jsonify({"status": "成功"})


# http接口处理
# http接口处理【postman接口调用】
@app.route("/msg", methods=["POST"])
def input_msg():
data = request.json
Expand All @@ -196,7 +196,7 @@ def input_msg():
return jsonify({"status": "成功"})


# 聊天回复弹框处理
# 聊天回复弹框处理【html回复框回调】
@app.route("/chatreply", methods=["GET"])
def chatreply():
CallBackForTest = request.args.get("CallBack")
Expand All @@ -205,14 +205,23 @@ def chatreply():
jsonStr = CallBackForTest + jsonStr
return jsonStr

# 聊天
# 聊天【用户funasr语音对话】
@app.route("/chat", methods=["POST", "GET"])
def chat():
CallBackForTest = request.args.get("CallBack")
uid = request.args.get("uid")
username = request.args.get("username")
text = request.args.get("text")
jsonStr = llmCore.http_chat(text,uid,username)
# =========处理消息开始========
status = "成功"
traceid = str(uuid.uuid4())
if text is None:
jsonStr = "({\"traceid\": \"" + traceid + "\",\"status\": \"值为空\",\"content\": \"" + text + "\"})"
return jsonStr
# 消息处理
entranceCore.msg_deal(traceid, text, uid, username)
jsonStr = "({\"traceid\": \"" + traceid + "\",\"status\": \"" + status + "\",\"content\": \"" + text + "\"})"
# =========end========
if CallBackForTest is not None:
jsonStr = CallBackForTest + jsonStr
return jsonStr
Expand Down
14 changes: 0 additions & 14 deletions func/llm/llm_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,20 +188,6 @@ def check_answer(self):
answers_thread = Thread(target=self.aiResponseTry)
answers_thread.start()

# http接口:聊天
def http_chat(self,text,uid,username):
status = "成功"
traceid = str(uuid.uuid4())
if text is None:
jsonStr = "({\"traceid\": \"" + traceid + "\",\"status\": \"值为空\",\"content\": \"" + text + "\"})"
return jsonStr

# 消息处理
self.msg_deal(traceid, text, uid, username)

jsonStr = "({\"traceid\": \"" + traceid + "\",\"status\": \"" + status + "\",\"content\": \"" + text + "\"})"
return jsonStr

# 进入直播间欢迎语
def check_welcome_room(self):
count = len(self.llmData.WelcomeList)
Expand Down
2 changes: 1 addition & 1 deletion func/tts/tts_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def tts_say_do(self,json):
text = trans_json["translated"]

# 合成语音
pattern = "(《|》)" # 过滤特殊字符,这些字符会影响语音合成
pattern = "(《|》|(|))" # 过滤特殊字符,这些字符会影响语音合成
text = re.sub(pattern, "", text)
status = self.vists.get_vists(filename, text, emotion)
if status == 0:
Expand Down

0 comments on commit dfb9efe

Please sign in to comment.