Merge pull request #1450 from xinnan-tech/tts-huoshan-fix

Tts huoshan fix
This commit is contained in:
欣南科技
2025-06-02 21:26:05 +08:00
committed by GitHub
4 changed files with 25 additions and 7 deletions
+9 -1
View File
@@ -202,7 +202,15 @@ change_role;get_weather;get_news;play_music;hass_get_state;hass_set_state
#### 2. 配置小智开源服务端MCP配置信息
切换到小智开源服务端`xiaozhi-esp32-server`的`mcp_server_settings.json`文件内,在`"mcpServers"`的括号内添加以下内容:
进入`data`目录,找到`.mcp_server_settings.json`文件。
如果你的`data`目录下没有`.mcp_server_settings.json`文件,
- 请把在`xiaozhi-server`文件夹根目录的`mcp_server_settings.json`文件复制到`data`目录下,并重命名为`.mcp_server_settings.json`
- 或[下载这个文件](https://github.com/xinnan-tech/xiaozhi-esp32-server/blob/main/main/xiaozhi-server/mcp_server_settings.json),下载到`data`目录下,并重命名为`.mcp_server_settings.json`
修改`"mcpServers"`里的这部分的内容:
```json
"Home Assistant": {
+7 -2
View File
@@ -46,8 +46,13 @@ async def main():
check_ffmpeg_installed()
config = load_config()
# 生成随机密钥并添加到配置中
config["server"]["auth_key"] = str(uuid.uuid4().hex)
# 默认使用manager-api的secret作为auth_key
# 如果secret为空,则生成随机密钥
# auth_key用于jwt认证,比如视觉分析接口的jwt认证
auth_key = config.get("manager-api", {}).get("secret", "")
if not auth_key or len(auth_key) == 0 or "" in auth_key:
auth_key = str(uuid.uuid4().hex)
config["server"]["auth_key"] = auth_key
# 添加 stdin 监控任务
stdin_task = asyncio.create_task(monitor_stdin())
@@ -37,17 +37,19 @@ class VisionHandler:
async def handle_post(self, request):
"""处理 MCP Vision POST 请求"""
response = None # 初始化response变量
try:
# 验证token
is_valid, token_device_id = self._verify_auth_token(request)
if not is_valid:
return web.Response(
response = web.Response(
text=json.dumps(
self._create_error_response("无效的认证token或token已过期")
),
content_type="application/json",
status=401,
)
return response
# 获取请求头信息
device_id = request.headers.get("Device-Id", "")
@@ -120,11 +122,11 @@ class VisionHandler:
vllm_type, current_config["VLLM"][select_vllm_module]
)
response = vllm.response(question, image_base64)
result = vllm.response(question, image_base64)
return_json = {
"success": True,
"result": response,
"result": result,
}
response = web.Response(
@@ -146,7 +148,8 @@ class VisionHandler:
content_type="application/json",
)
finally:
self._add_cors_headers(response)
if response:
self._add_cors_headers(response)
return response
async def handle_get(self, request):
@@ -74,6 +74,8 @@ async def checkWakeupWords(conn, text):
text_hello = WAKEUP_CONFIG["text"]
if not text_hello:
text_hello = text
if conn.tts is None:
return False
conn.tts.tts_one_sentence(
conn, ContentType.FILE, content_file=file, content_detail=text_hello
)