From 84b27ea593b5809f83d929a4b104b437d3f695bb Mon Sep 17 00:00:00 2001 From: DIng <1442618363@qq.com> Date: Sun, 4 Jan 2026 22:50:53 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9C=A8=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E4=B8=AD=E5=85=B3=E9=97=AD=E6=9C=AC=E7=B3=BB=E7=BB=9F=E8=87=AA?= =?UTF-8?q?=E5=8A=A8=E6=92=AD=E6=94=BE=E5=92=8C=E5=BD=95=E9=9F=B3=E8=AF=86?= =?UTF-8?q?=E5=88=AB=E5=8A=9F=E8=83=BD=EF=BC=8C=E5=B9=B6=E6=8A=8A=E5=9B=9E?= =?UTF-8?q?=E7=AD=94=E7=94=9F=E6=88=90=E7=9A=84=E9=9F=B3=E9=A2=91=E6=8E=A8?= =?UTF-8?q?=E7=BB=99=E5=A4=A7=E5=B1=8Fweb=E6=92=AD=E6=94=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config.json | 4 ++-- core/fay_core.py | 29 +++++++++++++++++++++++++++-- gui/flask_server.py | 5 ++++- 3 files changed, 33 insertions(+), 5 deletions(-) diff --git a/config.json b/config.json index 716ad4c..8b54049 100644 --- a/config.json +++ b/config.json @@ -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, diff --git a/core/fay_core.py b/core/fay_core.py index ec4874b..0c942fc 100644 --- a/core/fay_core.py +++ b/core/fay_core.py @@ -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) diff --git a/gui/flask_server.py b/gui/flask_server.py index e762bcb..1b45b91 100644 --- a/gui/flask_server.py +++ b/gui/flask_server.py @@ -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