在配置文件中关闭本系统自动播放和录音识别功能,并把回答生成的音频推给大屏web播放
This commit is contained in:
parent
84551d59eb
commit
84b27ea593
@ -26,7 +26,7 @@
|
||||
},
|
||||
"items": [],
|
||||
"source": {
|
||||
"automatic_player_status": true,
|
||||
"automatic_player_status": false,
|
||||
"automatic_player_url": "http://127.0.0.1:6000",
|
||||
"liveRoom": {
|
||||
"enabled": false,
|
||||
@ -34,7 +34,7 @@
|
||||
},
|
||||
"record": {
|
||||
"device": "",
|
||||
"enabled": true
|
||||
"enabled": false
|
||||
},
|
||||
"wake_word": "\u5c0f\u6a44\u6984",
|
||||
"wake_word_enabled": true,
|
||||
|
||||
@ -66,6 +66,22 @@ modules = {
|
||||
|
||||
}
|
||||
|
||||
def get_public_base():
|
||||
"""
|
||||
方案A:返回大屏可访问的后端基址
|
||||
优先用 config.json 的 server.public_base
|
||||
否则退回 cfg.fay_url:5000(你原来的)
|
||||
"""
|
||||
try:
|
||||
config_util.load_config()
|
||||
pb = config_util.config.get("server", {}).get("public_base", "")
|
||||
if pb:
|
||||
return pb.rstrip("/")
|
||||
except Exception:
|
||||
pass
|
||||
return f"http://{cfg.fay_url}:5000"
|
||||
|
||||
|
||||
#大语言模型回复
|
||||
def handle_chat_message(msg, username='User', observation=''):
|
||||
text = ''
|
||||
@ -431,6 +447,15 @@ class FeiFei:
|
||||
can_auto_play = False
|
||||
|
||||
self.speaking = True
|
||||
|
||||
# ✅ 方案A:把本次音频的 http url 推给大屏web端播放
|
||||
http_audio = f"{get_public_base()}/audio/{os.path.basename(file_url)}"
|
||||
if wsa_server.get_web_instance().is_connected(interact.data.get("user")):
|
||||
wsa_server.get_web_instance().add_cmd({
|
||||
"Username": interact.data.get("user"),
|
||||
"audioUrl": http_audio
|
||||
})
|
||||
|
||||
#推送远程音频
|
||||
MyThread(target=self.__send_remote_device_audio, args=[file_url, interact]).start()
|
||||
|
||||
@ -454,8 +479,8 @@ class FeiFei:
|
||||
threading.Timer(audio_length, self.send_play_end_msg, [interact]).start()
|
||||
|
||||
#面板播放
|
||||
if config_util.config["interact"]["playSound"]:
|
||||
self.__play_sound(file_url, audio_length, interact)
|
||||
# if config_util.config["interact"]["playSound"]:
|
||||
# self.__play_sound(file_url, audio_length, interact)
|
||||
|
||||
except Exception as e:
|
||||
print(e)
|
||||
|
||||
@ -529,7 +529,10 @@ def chat1():
|
||||
def serve_audio(filename):
|
||||
audio_file = os.path.join(os.getcwd(), "samples", filename)
|
||||
if os.path.exists(audio_file):
|
||||
return send_file(audio_file)
|
||||
resp = send_file(audio_file)
|
||||
# ✅ 推荐:避免浏览器缓存旧音频(大屏轮播/重复播放时更稳)
|
||||
resp.headers["Cache-Control"] = "no-store"
|
||||
return resp
|
||||
else:
|
||||
return jsonify({'error': '文件未找到'}), 404
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user