Compare commits

...

7 commits

Author SHA1 Message Date
Hồ Công Sử
b4f5800816
Merge 946d6e5823 into b545623b38 2026-11-16 14:53:18 +08:00
wengzh
b545623b38
Merge pull request #3561 from xinnan-tech/py-test-mem
Py test mem
2026-11-16 14:52:51 +08:00
Sakura-RanChen
63e2bcec8a revert(config): 移除 mem_report_only 出厂配置块,维持单模块 fail-fast 契约
回退 #3547 的核心改动。
mem_report_only 仅在智控台模式下有意义:选项及配置块由 manager-api数据库下发,不依赖本地 config.yaml。
2026-11-13 17:42:16 +08:00
zhenglieAllen
c74a6aaa68
fix(config): 修正 XunfeiSparkLLM 的 base_url 误填成火山方舟地址 (#3546)
现象:把 selected_module.VLLM 设为 XunfeiSparkLLM 后,视觉理解请求全部失败
(鉴权失败或 404),而且讯飞的 api_key 会被发到火山引擎。

原因:config.yaml 里 VLLM.XunfeiSparkLLM.base_url 填的是
https://ark.cn-beijing.volces.com/api/v3 —— 那是上面 LLM.DoubaoLLM 的火山
方舟地址,疑似复制粘贴时带串了。core/providers/vllm/openai.py 取端点时
base_url 优先于 url,所以这个值会直接生效;配套的 model_name: lite 是讯飞
的模型名,在火山方舟上并不存在。

改法:base_url 改成讯飞星火官方 OpenAI 兼容端点
https://spark-api-open.xf-yun.com/v1,并在注释里写明端点与模型名的出处。

测试:新增 tests/config/test_provider_endpoints.py,用一张「provider ->
端点主机名」对照表把这类串台钉死。修复前该用例失败,修复后通过。

Co-authored-by: Allen <zljtx2008@gmail.com>
2026-11-13 16:51:00 +08:00
zhenglieAllen
0d7180d898
fix(config): 给 mem_report_only 补上 Memory 配置块 (#3547)
* fix(config): 给 mem_report_only 补上 Memory 配置块

现象
把 selected_module.Memory 设成 mem_report_only 后,服务在连接初始化阶段
直接崩:

    KeyError: 'mem_report_only'

原因
core/providers/memory/mem_report_only/ 下有完整的 provider 实现,
core/connection.py 的 _initialize_memory 里也显式处理了它
(`if memory_type == "nomem" or memory_type == "mem_report_only"`),
但 config.yaml 的 Memory 段只配了 mem0ai / powermem / nomem /
mem_local_short 四项,没有 mem_report_only。

而 core/connection.py 取配置的方式是直接下标:

    memory_type = self.config["Memory"][self.config["selected_module"]["Memory"]]["type"]

于是只要在 selected_module 里选了 mem_report_only,这个下标就取不到,
连接初始化阶段 KeyError。data/.config.yaml 那边也是整段替换
(self.config["Memory"] = private_config["Memory"]),用户光改
selected_module 而不重复声明一遍 Memory 段,一样会炸。

改法
在 config.yaml 的 Memory 段补上 mem_report_only 配置块(type:
mem_report_only),让出厂配置自洽 —— 选了就能直接用,不需要用户自己
再补一段配置。

测试
新增 tests/config/test_provider_registry.py,钉死两条不变量:
- selected_module 里选中的 provider 必须在对应配置段里存在(防启动期 KeyError);
- 每个 provider 段的每个键,type 字段都必须指向真实存在的实现
  (防「配置有、实现没有」);
- Memory 这类一一对应的模块,实现里有的 provider 配置里必须有(防本次
  这种「实现有、配置没有」)。

修复前 test_every_implemented_provider_is_configured[Memory] 失败,
修复后通过。本地全量:5 failed / 99 passed / 33 skipped / 8 errors,
失败项与改动前完全一致(本地缺 portalocker / pytest-asyncio / edge_tts,
CI 由 requirements.txt 提供),无回归。

* docs(readme): 组件列表补齐 mem_report_only 与科大讯飞视觉模型

现象
README 的「本项目支持的平台/组件列表」有两处和实际出厂配置对不上:

1. VLLM 视觉模型表只列了「阿里百炼、智谱ChatGLMVLLM」,但 config.yaml 的
   VLLM 段出厂就带了 XunfeiSparkLLM(讯飞星火)这个 provider。
2. Memory 记忆存储表只列了 mem0ai / powermem / mem_local_short / nomem,
   没有 mem_report_only —— 而 core/providers/memory/mem_report_only/ 里有
   实现,core/connection.py 里也显式处理了它。

原因
这两个表是手工维护的,新增 provider 时没有同步。VLLM 段的讯飞星火尤其
隐蔽:它的 base_url 还被误填成了火山方舟的地址(ark.cn-beijing.volces.com),
看起来像是没在用,于是没人往表里补。

改法
6 份 README(README.md + docs/readme/ 下的 en/de/es/vi/pt_BR)同步更新:

- VLLM 视觉模型表的「支持平台」列补上科大讯飞 / iFLYTEK。免费平台列不动 ——
  讯飞星火虽有免费额度,但每个模型要单独开通服务后才能用,不属于开箱免费。
- Memory 记忆存储表补上 mem_report_only 一行(使用方式「仅上报」,
  备注「只上报聊天记录,不做记忆总结」,取自 provider 自身的 docstring)。

测试
纯文档改动,无代码路径变化。本次一并把 VLLM 表和 Memory 表跟 config.yaml
的实际内容对齐,避免再出现「文档列的组件在配置里选不到」的情况。

---------

Co-authored-by: Allen <zljtx2008@gmail.com>
2026-11-13 16:31:17 +08:00
Ho Cong Su
946d6e5823 Merge branch 'main' of https://github.com/xinnan-tech/xiaozhi-esp32-server 2026-07-01 20:16:55 +07:00
Ho Cong Su
b3e3d1ae4f Viet hoa giao dien Digital Human va cau hinh TTS 2026-06-29 03:02:37 +07:00
17 changed files with 333 additions and 161 deletions

View file

@ -272,7 +272,7 @@ Websocket接口地址: wss://2662r3426b.vicp.fun/xiaozhi/v1/
| 使用方式 | 支持平台 | 免费平台 | | 使用方式 | 支持平台 | 免费平台 |
|:---:|:---:|:---:| |:---:|:---:|:---:|
| OpenAI 接口调用 | 阿里百炼、智谱ChatGLMVLLM | 智谱ChatGLMVLLM | | OpenAI 接口调用 | 阿里百炼、智谱ChatGLMVLLM、科大讯飞 | 智谱ChatGLMVLLM |
实际上,任何支持 OpenAI 接口调用的 VLLM 均可接入使用。 实际上,任何支持 OpenAI 接口调用的 VLLM 均可接入使用。
@ -322,6 +322,7 @@ Websocket接口地址: wss://2662r3426b.vicp.fun/xiaozhi/v1/
| Memory | [powermem](./docs/powermem-integration.md) | 本地总结 | 取决于LLM和DB | OceanBase开源,支持智能检索 | | Memory | [powermem](./docs/powermem-integration.md) | 本地总结 | 取决于LLM和DB | OceanBase开源,支持智能检索 |
| Memory | mem_local_short | 本地总结 | 免费 | | | Memory | mem_local_short | 本地总结 | 免费 | |
| Memory | nomem | 无记忆模式 | 免费 | | | Memory | nomem | 无记忆模式 | 免费 | |
| Memory | mem_report_only | 仅上报 | 免费 | 只上报聊天记录,不做记忆总结 |
--- ---

View file

@ -270,7 +270,7 @@ Tatsächlich kann jedes LLM, das OpenAI-Schnittstellenaufrufe unterstützt, inte
| Verwendungsmethode | Unterstützte Plattformen | Kostenlose Plattformen | | Verwendungsmethode | Unterstützte Plattformen | Kostenlose Plattformen |
|:---:|:---:|:---:| |:---:|:---:|:---:|
| OpenAI-Schnittstellenaufrufe | Alibaba Bailian, Zhipu ChatGLMVLLM | Zhipu ChatGLMVLLM | | OpenAI-Schnittstellenaufrufe | Alibaba Bailian, Zhipu ChatGLMVLLM, iFLYTEK | Zhipu ChatGLMVLLM |
Tatsächlich kann jedes VLLM, das OpenAI-Schnittstellenaufrufe unterstützt, integriert und verwendet werden. Tatsächlich kann jedes VLLM, das OpenAI-Schnittstellenaufrufe unterstützt, integriert und verwendet werden.
@ -320,6 +320,7 @@ Die Stimmabdruckerkennung erfordert einen separat bereitgestellten [voiceprint-a
| Memory | [powermem](../powermem-integration.md) | Lokale Zusammenfassung | Abhängig von LLM und DB | OceanBase Open Source, unterstützt intelligente Abfrage | | Memory | [powermem](../powermem-integration.md) | Lokale Zusammenfassung | Abhängig von LLM und DB | OceanBase Open Source, unterstützt intelligente Abfrage |
| Memory | mem_local_short | Lokale Zusammenfassung | Kostenlos | | | Memory | mem_local_short | Lokale Zusammenfassung | Kostenlos | |
| Memory | nomem | Kein Gedächtnismodus | Kostenlos | | | Memory | nomem | Kein Gedächtnismodus | Kostenlos | |
| Memory | mem_report_only | Nur Meldung | Kostenlos | Meldet nur Chat-Verläufe, keine Gedächtniszusammenfassung |
--- ---

View file

@ -270,7 +270,7 @@ In fact, any LLM that supports OpenAI interface calls can be integrated and used
| Usage Method | Supported Platforms | Free Platforms | | Usage Method | Supported Platforms | Free Platforms |
|:---:|:---:|:---:| |:---:|:---:|:---:|
| OpenAI interface calls | Alibaba Bailian, Zhipu ChatGLMVLLM | Zhipu ChatGLMVLLM | | OpenAI interface calls | Alibaba Bailian, Zhipu ChatGLMVLLM, iFLYTEK | Zhipu ChatGLMVLLM |
In fact, any VLLM that supports OpenAI interface calls can be integrated and used. In fact, any VLLM that supports OpenAI interface calls can be integrated and used.
@ -320,6 +320,7 @@ Voiceprint recognition requires a separately deployed [voiceprint-api](https://g
| Memory | [powermem](../powermem-integration.md) | Local summarization | Depends on LLM and DB | OceanBase open source, supports intelligent retrieval | | Memory | [powermem](../powermem-integration.md) | Local summarization | Depends on LLM and DB | OceanBase open source, supports intelligent retrieval |
| Memory | mem_local_short | Local summarization | Free | | | Memory | mem_local_short | Local summarization | Free | |
| Memory | nomem | No memory mode | Free | | | Memory | nomem | No memory mode | Free | |
| Memory | mem_report_only | Report only | Free | Only reports chat records, no memory summarization |
--- ---

View file

@ -270,7 +270,7 @@ En la práctica, se puede integrar cualquier LLM que admita llamadas por la inte
| Forma de uso | Plataformas compatibles | Plataformas gratuitas | | Forma de uso | Plataformas compatibles | Plataformas gratuitas |
|:---:|:---:|:---:| |:---:|:---:|:---:|
| Llamadas por la interfaz OpenAI | Alibaba Bailian, Zhipu ChatGLMVLLM | Zhipu ChatGLMVLLM | | Llamadas por la interfaz OpenAI | Alibaba Bailian, Zhipu ChatGLMVLLM, iFLYTEK | Zhipu ChatGLMVLLM |
En la práctica, se puede integrar cualquier VLLM que admita llamadas por la interfaz OpenAI. En la práctica, se puede integrar cualquier VLLM que admita llamadas por la interfaz OpenAI.
@ -320,6 +320,7 @@ El reconocimiento de huella de voz requiere desplegar por separado el servicio [
| Memory | [powermem](../powermem-integration.md) | Resumen local | Depende del LLM y de la base de datos | OceanBase de código abierto; admite búsqueda inteligente | | Memory | [powermem](../powermem-integration.md) | Resumen local | Depende del LLM y de la base de datos | OceanBase de código abierto; admite búsqueda inteligente |
| Memory | mem_local_short | Resumen local | Gratuito | | | Memory | mem_local_short | Resumen local | Gratuito | |
| Memory | nomem | Modo sin memoria | Gratuito | | | Memory | nomem | Modo sin memoria | Gratuito | |
| Memory | mem_report_only | Solo informe | Gratuito | Solo informa el historial de chat, sin resumen de memoria |
--- ---

View file

@ -270,7 +270,7 @@ Na verdade, qualquer LLM que suporte chamadas via interface OpenAI pode ser inte
| Método de Uso | Plataformas Suportadas | Plataformas Gratuitas | | Método de Uso | Plataformas Suportadas | Plataformas Gratuitas |
|:---:|:---:|:---:| |:---:|:---:|:---:|
| Chamadas via interface OpenAI | Alibaba Bailian, Zhipu ChatGLMVLLM | Zhipu ChatGLMVLLM | | Chamadas via interface OpenAI | Alibaba Bailian, Zhipu ChatGLMVLLM, iFLYTEK | Zhipu ChatGLMVLLM |
Na verdade, qualquer VLLM que suporte chamadas via interface OpenAI pode ser integrado e utilizado. Na verdade, qualquer VLLM que suporte chamadas via interface OpenAI pode ser integrado e utilizado.
@ -320,6 +320,7 @@ O reconhecimento de impressão vocal exige um serviço [voiceprint-api](https://
| Memória | [powermem](../powermem-integration.md) | Resumo local | Depende do LLM e BD | OceanBase de código aberto, suporta busca inteligente | | Memória | [powermem](../powermem-integration.md) | Resumo local | Depende do LLM e BD | OceanBase de código aberto, suporta busca inteligente |
| Memória | mem_local_short | Resumo local | Gratuito | | | Memória | mem_local_short | Resumo local | Gratuito | |
| Memória | nomem | Modo sem memória | Gratuito | | | Memória | nomem | Modo sem memória | Gratuito | |
| Memória | mem_report_only | Apenas relatório | Gratuito | Apenas reporta o histórico de chat, sem resumo de memória |
--- ---

View file

@ -271,7 +271,7 @@ Trên thực tế, bất kỳ LLM nào hỗ trợ gọi giao diện OpenAI đề
| Phương pháp sử dụng | Nền tảng hỗ trợ | Nền tảng miễn phí | | Phương pháp sử dụng | Nền tảng hỗ trợ | Nền tảng miễn phí |
|:---:|:---:|:---:| |:---:|:---:|:---:|
| Gọi giao diện OpenAI | Alibaba Bailian, Zhipu ChatGLMVLLM | Zhipu ChatGLMVLLM | | Gọi giao diện OpenAI | Alibaba Bailian, Zhipu ChatGLMVLLM, iFLYTEK | Zhipu ChatGLMVLLM |
Trên thực tế, bất kỳ VLLM nào hỗ trợ gọi giao diện OpenAI đều có thể truy cập sử dụng. Trên thực tế, bất kỳ VLLM nào hỗ trợ gọi giao diện OpenAI đều có thể truy cập sử dụng.
@ -321,6 +321,7 @@ Nhận dạng vân giọng cần dịch vụ [voiceprint-api](https://github.com
| Memory | [powermem](../powermem-integration.md) | Tóm tắt cục bộ | Phụ thuộc vào LLM và DB | OceanBase mã nguồn mở, hỗ trợ tìm kiếm thông minh | | Memory | [powermem](../powermem-integration.md) | Tóm tắt cục bộ | Phụ thuộc vào LLM và DB | OceanBase mã nguồn mở, hỗ trợ tìm kiếm thông minh |
| Memory | mem_local_short | Tóm tắt cục bộ | Miễn phí | | | Memory | mem_local_short | Tóm tắt cục bộ | Miễn phí | |
| Memory | nomem | Chế độ không có bộ nhớ | Miễn phí | | | Memory | nomem | Chế độ không có bộ nhớ | Miễn phí | |
| Memory | mem_report_only | Chỉ báo cáo | Miễn phí | Chỉ báo cáo lịch sử trò chuyện, không tóm tắt bộ nhớ |
--- ---

View file

@ -425,7 +425,7 @@ body {
font-weight: 500; font-weight: 500;
} }
/* 拨号按钮特殊样式 */ /* Kết nối按钮特殊样式 */
.dial-btn.dial-active { .dial-btn.dial-active {
background: rgba(237, 66, 69, 0.9); background: rgba(237, 66, 69, 0.9);
} }
@ -434,7 +434,7 @@ body {
background: rgba(237, 66, 69, 1); background: rgba(237, 66, 69, 1);
} }
/* 录音按钮特殊样式 */ /* Ghi âm按钮特殊样式 */
.control-btn.recording { .control-btn.recording {
background: rgba(237, 66, 69, 0.9); background: rgba(237, 66, 69, 0.9);
animation: pulse 1.5s infinite; animation: pulse 1.5s infinite;
@ -444,7 +444,7 @@ body {
background: rgba(237, 66, 69, 1); background: rgba(237, 66, 69, 1);
} }
/* 摄像头按钮特殊样式 */ /* Camera按钮特殊样式 */
#cameraBtn.camera-active { #cameraBtn.camera-active {
background: rgba(237, 66, 69, 0.9); background: rgba(237, 66, 69, 0.9);
} }
@ -453,7 +453,7 @@ body {
background: rgba(237, 66, 69, 1); background: rgba(237, 66, 69, 1);
} }
/* 录音按钮脉冲动画 */ /* Ghi âm按钮脉冲动画 */
@keyframes pulse { @keyframes pulse {
0% { 0% {
box-shadow: 0 0 0 0 rgba(237, 66, 69, 0.7); box-shadow: 0 0 0 0 rgba(237, 66, 69, 0.7);
@ -1242,7 +1242,7 @@ body {
background: #4f545c; background: #4f545c;
} }
/* ==================== 摄像头显示区域样式 ==================== */ /* ==================== Camera显示区域样式 ==================== */
.camera-container { .camera-container {
position: fixed; position: fixed;
top: 20px; top: 20px;

View file

@ -45,12 +45,12 @@
<!-- 主容器 --> <!-- 主容器 -->
<div class="container"> <div class="container">
<!-- 摄像头显示区域(可拖动) --> <!-- Camera显示区域(可拖动) -->
<div class="camera-container" id="cameraContainer"> <div class="camera-container" id="cameraContainer">
<video id="cameraVideo" autoplay playsinline muted></video> <video id="cameraVideo" autoplay playsinline muted></video>
<div class="camera-switch-mask" id="cameraSwitchMask"> <div class="camera-switch-mask" id="cameraSwitchMask">
<div class="camera-switch-container"> <div class="camera-switch-container">
<!-- 摄像头切换按钮 --> <!-- Camera切换按钮 -->
<div class="camera-switch" id="cameraSwitch"> <div class="camera-switch" id="cameraSwitch">
<svg class="btn-icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="7319" width="32" height="32"><path d="M722.1 530.3c0-44.9-13.8-86.5-37.2-120.9-0.3-0.6-0.6-1.2-0.9-1.7-2.9-4.2-6.1-8.1-9.2-12-0.4-0.5-0.7-1-1.1-1.5-21.4-26.3-48.3-46.7-78.7-59.9-0.8-0.4-1.7-0.8-2.5-1.2-4.9-2-9.8-3.8-14.9-5.5-1.8-0.6-3.6-1.3-5.4-1.8-4.4-1.3-8.8-2.4-13.3-3.5-2.5-0.6-4.9-1.2-7.4-1.7-1.2-0.2-2.4-0.6-3.6-0.8-3.3-0.6-6.7-0.8-10-1.3-2.3-0.3-4.6-0.7-6.9-0.9-5.6-0.5-11.2-0.8-16.7-0.9-1 0-2-0.1-3-0.1-0.2 0-0.3 0.1-0.5 0.1-42.8 0-84.6 13.1-120.4 38.6-11.5 8.1-14.2 24.1-6.2 35.7 8 11.6 23.8 14.4 35.2 6.3 27.7-19.7 60-29.6 93.1-29.3 4.8 0 9.5 0.3 14.1 0.7 1.4 0.2 2.8 0.4 4.3 0.5 3.8 0.5 7.6 1 11.3 1.8 1.6 0.3 3.3 0.8 4.9 1.1 3.7 0.8 7.3 1.7 10.9 2.8 1.1 0.4 2.2 0.8 3.4 1.2 4.1 1.3 8.1 2.8 12 4.5 0.4 0.2 0.8 0.4 1.2 0.5 23.6 10.3 44.3 26.1 60.4 45.9 0.1 0.1 0.2 0.3 0.3 0.4 22.7 28 36.4 63.9 36.4 102.9h-42.2L697 632.9l67.5-102.6h-42.4z m-119 133c-27.9 19.8-60.5 29.7-93.9 29.3-4.4-0.1-8.8-0.3-13.1-0.7-1.8-0.2-3.5-0.5-5.3-0.7-3.4-0.5-6.8-0.9-10.1-1.6-2-0.4-4-0.9-6.1-1.4-3.3-0.8-6.5-1.5-9.7-2.5-1.5-0.5-3-1-4.6-1.5-3.7-1.2-7.3-2.5-10.8-4-0.8-0.3-1.6-0.7-2.4-1.1-4.1-1.9-8.2-3.8-12.2-6l-0.6-0.3c-13.4-7.5-25.7-16.8-36.4-27.7-0.2-0.2-0.3-0.4-0.5-0.6-3.3-3.4-6.5-6.9-9.5-10.7-0.6-0.8-1.3-1.6-1.9-2.5-21.9-27.8-35.1-63-35.1-101.2h42.2l-67.5-102.6-67.5 102.6h42.2c0 45 13.9 86.7 37.3 121.1 0.3 0.5 0.5 1 0.8 1.5 2.4 3.5 5.1 6.8 7.7 10.1 1 1.3 1.9 2.6 2.9 3.8 3.9 4.7 7.9 9.2 12.1 13.5 0.4 0.4 0.8 0.9 1.2 1.3 14.1 14.3 30.1 26.4 47.4 36 0.5 0.3 0.9 0.6 1.4 0.8 5 2.7 10.1 5.2 15.3 7.5l3.9 1.8c4.4 1.9 9 3.5 13.6 5.1 2.2 0.7 4.4 1.5 6.6 2.2 4 1.2 8.1 2.2 12.3 3.2 2.8 0.7 5.5 1.4 8.3 1.9 1.2 0.3 2.3 0.6 3.4 0.8 3.9 0.7 7.8 1.1 11.8 1.6l4.2 0.6c7 0.7 14.1 1.2 21.1 1.2 42.9 0 84.7-13.3 120.6-38.8 11.4-8.2 14.2-24.1 6.2-35.8-8-11.5-23.8-14.3-35.3-6.2z m271.3-421.6H763c-26.5 0-82.9-119.7-112.5-119.7H370.6c-29.6 0-85.9 119.7-112.4 119.7H147.5c-46.3 0-83.9 40.2-83.9 89.7v478.8c0 49.6 37.6 89.8 83.9 89.8h726.9c46.3 0 83.9-40.1 83.9-89.8V331.4c0-49.5-37.6-89.7-83.9-89.7z m28 538.6c0 33.1-25 59.8-55.9 59.8h-671c-30.9 0-55.9-26.8-55.9-59.8V361.4c0-33 25-59.8 55.9-59.8h111.2c25.8 0 82-119.7 111.6-119.7h223.2c29.5 0 85.6 119.7 111.5 119.7h113.5c30.9 0 55.9 26.8 55.9 59.8v418.9z" p-id="7320" fill="#ffffff"></path></svg> <svg class="btn-icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="7319" width="32" height="32"><path d="M722.1 530.3c0-44.9-13.8-86.5-37.2-120.9-0.3-0.6-0.6-1.2-0.9-1.7-2.9-4.2-6.1-8.1-9.2-12-0.4-0.5-0.7-1-1.1-1.5-21.4-26.3-48.3-46.7-78.7-59.9-0.8-0.4-1.7-0.8-2.5-1.2-4.9-2-9.8-3.8-14.9-5.5-1.8-0.6-3.6-1.3-5.4-1.8-4.4-1.3-8.8-2.4-13.3-3.5-2.5-0.6-4.9-1.2-7.4-1.7-1.2-0.2-2.4-0.6-3.6-0.8-3.3-0.6-6.7-0.8-10-1.3-2.3-0.3-4.6-0.7-6.9-0.9-5.6-0.5-11.2-0.8-16.7-0.9-1 0-2-0.1-3-0.1-0.2 0-0.3 0.1-0.5 0.1-42.8 0-84.6 13.1-120.4 38.6-11.5 8.1-14.2 24.1-6.2 35.7 8 11.6 23.8 14.4 35.2 6.3 27.7-19.7 60-29.6 93.1-29.3 4.8 0 9.5 0.3 14.1 0.7 1.4 0.2 2.8 0.4 4.3 0.5 3.8 0.5 7.6 1 11.3 1.8 1.6 0.3 3.3 0.8 4.9 1.1 3.7 0.8 7.3 1.7 10.9 2.8 1.1 0.4 2.2 0.8 3.4 1.2 4.1 1.3 8.1 2.8 12 4.5 0.4 0.2 0.8 0.4 1.2 0.5 23.6 10.3 44.3 26.1 60.4 45.9 0.1 0.1 0.2 0.3 0.3 0.4 22.7 28 36.4 63.9 36.4 102.9h-42.2L697 632.9l67.5-102.6h-42.4z m-119 133c-27.9 19.8-60.5 29.7-93.9 29.3-4.4-0.1-8.8-0.3-13.1-0.7-1.8-0.2-3.5-0.5-5.3-0.7-3.4-0.5-6.8-0.9-10.1-1.6-2-0.4-4-0.9-6.1-1.4-3.3-0.8-6.5-1.5-9.7-2.5-1.5-0.5-3-1-4.6-1.5-3.7-1.2-7.3-2.5-10.8-4-0.8-0.3-1.6-0.7-2.4-1.1-4.1-1.9-8.2-3.8-12.2-6l-0.6-0.3c-13.4-7.5-25.7-16.8-36.4-27.7-0.2-0.2-0.3-0.4-0.5-0.6-3.3-3.4-6.5-6.9-9.5-10.7-0.6-0.8-1.3-1.6-1.9-2.5-21.9-27.8-35.1-63-35.1-101.2h42.2l-67.5-102.6-67.5 102.6h42.2c0 45 13.9 86.7 37.3 121.1 0.3 0.5 0.5 1 0.8 1.5 2.4 3.5 5.1 6.8 7.7 10.1 1 1.3 1.9 2.6 2.9 3.8 3.9 4.7 7.9 9.2 12.1 13.5 0.4 0.4 0.8 0.9 1.2 1.3 14.1 14.3 30.1 26.4 47.4 36 0.5 0.3 0.9 0.6 1.4 0.8 5 2.7 10.1 5.2 15.3 7.5l3.9 1.8c4.4 1.9 9 3.5 13.6 5.1 2.2 0.7 4.4 1.5 6.6 2.2 4 1.2 8.1 2.2 12.3 3.2 2.8 0.7 5.5 1.4 8.3 1.9 1.2 0.3 2.3 0.6 3.4 0.8 3.9 0.7 7.8 1.1 11.8 1.6l4.2 0.6c7 0.7 14.1 1.2 21.1 1.2 42.9 0 84.7-13.3 120.6-38.8 11.4-8.2 14.2-24.1 6.2-35.8-8-11.5-23.8-14.3-35.3-6.2z m271.3-421.6H763c-26.5 0-82.9-119.7-112.5-119.7H370.6c-29.6 0-85.9 119.7-112.4 119.7H147.5c-46.3 0-83.9 40.2-83.9 89.7v478.8c0 49.6 37.6 89.8 83.9 89.8h726.9c46.3 0 83.9-40.1 83.9-89.8V331.4c0-49.5-37.6-89.7-83.9-89.7z m28 538.6c0 33.1-25 59.8-55.9 59.8h-671c-30.9 0-55.9-26.8-55.9-59.8V361.4c0-33 25-59.8 55.9-59.8h111.2c25.8 0 82-119.7 111.6-119.7h223.2c29.5 0 85.6 119.7 111.5 119.7h113.5c30.9 0 55.9 26.8 55.9 59.8v418.9z" p-id="7320" fill="#ffffff"></path></svg>
</div> </div>
@ -62,7 +62,7 @@
<div class="connection-status-top"> <div class="connection-status-top">
<div class="status-indicator"> <div class="status-indicator">
<span class="status-dot status-disconnected"></span> <span class="status-dot status-disconnected"></span>
<span id="connectionStatus">离线</span> <span id="connectionStatus">Ngoại tuyến</span>
</div> </div>
</div> </div>
@ -101,28 +101,28 @@
<span class="btn-text">设置</span> <span class="btn-text">设置</span>
</button> </button>
<button class="control-btn" id="cameraBtn" title="请先连接服务器" disabled> <button class="control-btn" id="cameraBtn" title="Vui lòng kết nối máy chủ trước" disabled>
<svg class="btn-icon" viewBox="0 0 24 24" fill="currentColor"> <svg class="btn-icon" viewBox="0 0 24 24" fill="currentColor">
<path <path
d="M17,10.5V7A1,1 0 0,0 16,6H4A1,1 0 0,0 3,7V17A1,1 0 0,0 4,18H16A1,1 0 0,0 17,17V13.5L21,17.5V6.5L17,10.5Z" /> d="M17,10.5V7A1,1 0 0,0 16,6H4A1,1 0 0,0 3,7V17A1,1 0 0,0 4,18H16A1,1 0 0,0 17,17V13.5L21,17.5V6.5L17,10.5Z" />
</svg> </svg>
<span class="btn-text">摄像头</span> <span class="btn-text">Camera</span>
</button> </button>
<button class="control-btn dial-btn" id="dialBtn" title="拨号"> <button class="control-btn dial-btn" id="dialBtn" title="Kết nối">
<svg class="btn-icon" viewBox="0 0 24 24" fill="currentColor"> <svg class="btn-icon" viewBox="0 0 24 24" fill="currentColor">
<path <path
d="M6.62,10.79C8.06,13.62 10.38,15.94 13.21,17.38L15.41,15.18C15.69,14.9 16.08,14.82 16.43,14.93C17.55,15.3 18.75,15.5 20,15.5A1,1 0 0,1 21,16.5V20A1,1 0 0,1 20,21A17,17 0 0,1 3,4A1,1 0 0,1 4,3H7.5A1,1 0 0,1 8.5,4C8.5,5.25 8.7,6.45 9.07,7.57C9.18,7.92 9.1,8.31 8.82,8.59L6.62,10.79Z" /> d="M6.62,10.79C8.06,13.62 10.38,15.94 13.21,17.38L15.41,15.18C15.69,14.9 16.08,14.82 16.43,14.93C17.55,15.3 18.75,15.5 20,15.5A1,1 0 0,1 21,16.5V20A1,1 0 0,1 20,21A17,17 0 0,1 3,4A1,1 0 0,1 4,3H7.5A1,1 0 0,1 8.5,4C8.5,5.25 8.7,6.45 9.07,7.57C9.18,7.92 9.1,8.31 8.82,8.59L6.62,10.79Z" />
</svg> </svg>
<span class="btn-text">拨号</span> <span class="btn-text">Kết nối</span>
</button> </button>
<button class="control-btn" id="recordBtn" title="开始录音" disabled> <button class="control-btn" id="recordBtn" title="开始Ghi âm" disabled>
<svg class="btn-icon" viewBox="0 0 24 24" fill="currentColor"> <svg class="btn-icon" viewBox="0 0 24 24" fill="currentColor">
<path <path
d="M12,2A3,3 0 0,1 15,5V11A3,3 0 0,1 12,14A3,3 0 0,1 9,11V5A3,3 0 0,1 12,2M19,11C19,14.53 16.39,17.44 13,17.93V21H11V17.93C7.61,17.44 5,14.53 5,11H7A5,5 0 0,0 12,16A5,5 0 0,0 17,11H19Z" /> d="M12,2A3,3 0 0,1 15,5V11A3,3 0 0,1 12,14A3,3 0 0,1 9,11V5A3,3 0 0,1 12,2M19,11C19,14.53 16.39,17.44 13,17.93V21H11V17.93C7.61,17.44 5,14.53 5,11H7A5,5 0 0,0 12,16A5,5 0 0,0 17,11H19Z" />
</svg> </svg>
<span class="btn-text">录音</span> <span class="btn-text">Ghi âm</span>
</button> </button>
</div> </div>
</div> </div>
@ -185,7 +185,7 @@
<div class="input-group"> <div class="input-group">
<label for="serverUrl">WebSocket服务器地址:</label> <label for="serverUrl">WebSocket服务器地址:</label>
<input type="text" id="serverUrl" value="" readonly disabled <input type="text" id="serverUrl" value="" readonly disabled
placeholder="填写OTA地址后,点击拨号按钮自动连接" /> placeholder="填写OTA地址后,点击Kết nối按钮自动连接" />
</div> </div>
<div class="input-group"> <div class="input-group">
<label for="visionUrl">视觉分析地址:</label> <label for="visionUrl">视觉分析地址:</label>
@ -219,7 +219,7 @@
</div> </div>
</div> </div>
<div class="modal-actions"> <div class="modal-actions">
<button type="button" class="btn-primary" id="applyWakewordBtn">应用唤醒词</button> <button type="button" class="btn-primary" id="applyWakewordBtn">Áp dụng từ khóa đánh thức</button>
</div> </div>
</div> </div>
</div> </div>
@ -237,7 +237,7 @@
</div> </div>
<div class="mcp-actions"> <div class="mcp-actions">
<button class="btn-primary" id="addMcpToolBtn"> <button class="btn-primary" id="addMcpToolBtn">
➕ 添加新工具 ➕ 添加Công cụ mới
</button> </button>
</div> </div>
</div> </div>
@ -286,11 +286,11 @@
<div id="mcpErrorContainer"></div> <div id="mcpErrorContainer"></div>
<form id="mcpToolForm"> <form id="mcpToolForm">
<div class="input-group"> <div class="input-group">
<label for="mcpToolName">工具名称 *</label> <label for="mcpToolName">Tên công cụ *</label>
<input type="text" id="mcpToolName" placeholder="例如: self.get_device_status" required> <input type="text" id="mcpToolName" placeholder="例如: self.get_device_status" required>
</div> </div>
<div class="input-group"> <div class="input-group">
<label for="mcpToolDescription">工具描述 *</label> <label for="mcpToolDescription">Mô tả công cụ *</label>
<textarea id="mcpToolDescription" placeholder="详细描述工具的功能和使用场景..." required></textarea> <textarea id="mcpToolDescription" placeholder="详细描述工具的功能和使用场景..." required></textarea>
</div> </div>
<div class="input-group"> <div class="input-group">

View file

@ -48,13 +48,13 @@ class App {
startWakewordBridgeListener(); startWakewordBridgeListener();
// 检查麦克风可用性 // 检查麦克风可用性
await this.checkMicrophoneAvailability(); await this.checkMicrophoneAvailability();
// 检查摄像头可用性 // 检查Camera可用性
this.checkCameraAvailability(); this.checkCameraAvailability();
// 初始化Live2D // 初始化Live2D
await this.initLive2D(); await this.initLive2D();
// 初始化摄像头 // 初始化Camera
this.initCamera(); this.initCamera();
// 关闭加载loading // Tắt加载loading
this.setModelLoadingStatus(false); this.setModelLoadingStatus(false);
log('应用初始化完成', 'success'); log('应用初始化完成', 'success');
} }
@ -121,13 +121,13 @@ class App {
} }
} }
// 检查摄像头可用性 // 检查Camera可用性
checkCameraAvailability() { checkCameraAvailability() {
window.cameraAvailable = true; window.cameraAvailable = true;
log('摄像头可用性检查完成: 默认已绑定验证码', 'success'); log('Camera可用性检查完成: 默认已绑定验证码', 'success');
} }
// 初始化摄像头 // 初始化Camera
async initCamera() { async initCamera() {
const cameraContainer = document.getElementById('cameraContainer'); const cameraContainer = document.getElementById('cameraContainer');
const cameraVideo = document.getElementById('cameraVideo'); const cameraVideo = document.getElementById('cameraVideo');
@ -136,7 +136,7 @@ class App {
const dialBtn = document.getElementById('dialBtn'); const dialBtn = document.getElementById('dialBtn');
if (!cameraContainer || !cameraVideo) { if (!cameraContainer || !cameraVideo) {
log('摄像头元素未找到,跳过初始化', 'warning'); log('Camera元素未找到,跳过初始化', 'warning');
return Promise.resolve(false); return Promise.resolve(false);
} }
@ -190,10 +190,10 @@ class App {
window.startCamera = async () => { window.startCamera = async () => {
try { try {
if (!navigator.mediaDevices || !navigator.mediaDevices.getUserMedia) { if (!navigator.mediaDevices || !navigator.mediaDevices.getUserMedia) {
log('浏览器不支持摄像头API', 'warning'); log('浏览器不支持CameraAPI', 'warning');
return false; return false;
} }
log('正在请求摄像头权限...', 'info'); log('正在请求Camera权限...', 'info');
this.cameraStream = await navigator.mediaDevices.getUserMedia({ this.cameraStream = await navigator.mediaDevices.getUserMedia({
video: { width: 180, height: 240, facingMode: this.currentFacingMode }, video: { width: 180, height: 240, facingMode: this.currentFacingMode },
audio: false audio: false
@ -206,23 +206,23 @@ class App {
} }
cameraContainer.classList.add('active'); cameraContainer.classList.add('active');
// 切换时挂断情况 // 切换时Ngắt kết nối情况
const hasActive = dialBtn.classList.contains('dial-active'); const hasActive = dialBtn.classList.contains('dial-active');
if (!hasActive) { if (!hasActive) {
cameraContainer.classList.remove('active'); cameraContainer.classList.remove('active');
cameraSwitch.classList.remove('active'); cameraSwitch.classList.remove('active');
window.stopCamera(); window.stopCamera();
} }
log('摄像头已启动', 'success'); log('Camera已启动', 'success');
return true; return true;
} catch (error) { } catch (error) {
log(`启动摄像头失败: ${error.name} - ${error.message}`, 'error'); log(`启动Camera失败: ${error.name} - ${error.message}`, 'error');
if (error.name === 'NotAllowedError') { if (error.name === 'NotAllowedError') {
log('摄像头权限被拒绝,请检查浏览器设置', 'warning'); log('Camera权限被拒绝,请检查浏览器设置', 'warning');
} else if (error.name === 'NotFoundError') { } else if (error.name === 'NotFoundError') {
log('未找到摄像头设备', 'warning'); log('未找到Camera设备', 'warning');
} else if (error.name === 'NotReadableError') { } else if (error.name === 'NotReadableError') {
log('摄像头已被其他程序占用', 'warning'); log('Camera已被其他程序占用', 'warning');
} }
return false; return false;
} }
@ -233,7 +233,7 @@ class App {
this.cameraStream.getTracks().forEach(track => track.stop()); this.cameraStream.getTracks().forEach(track => track.stop());
this.cameraStream = null; this.cameraStream = null;
cameraVideo.srcObject = null; cameraVideo.srcObject = null;
log('摄像头已关闭', 'info'); log('Camera đã tắt', 'info');
} }
}; };
@ -269,10 +269,10 @@ class App {
const video = cameraVideo; const video = cameraVideo;
if (!video || video.readyState !== video.HAVE_ENOUGH_DATA) { if (!video || video.readyState !== video.HAVE_ENOUGH_DATA) {
log('无法拍照:摄像头未就绪', 'warning'); log('无法拍照:Camera未就绪', 'warning');
resolve({ resolve({
success: false, success: false,
error: '摄像头未就绪,请确保已连接且摄像头已启动' error: 'Camera未就绪,请确保Đã kết nối且Camera已启动'
}); });
return; return;
} }
@ -356,7 +356,7 @@ class App {
}); });
}; };
log('摄像头初始化完成', 'success'); log('Camera初始化完成', 'success');
resolve(true); resolve(true);
}); });
} }

View file

@ -204,7 +204,7 @@ export class AudioRecorder {
if (this.isRecording) return false; if (this.isRecording) return false;
try { try {
if (!this.initEncoder()) { if (!this.initEncoder()) {
log('无法开始录音: Opus编码器初始化失败', 'error'); log('无法开始Ghi âm: Opus编码器初始化失败', 'error');
return false; return false;
} }
log('请至少录制1-2秒音频以确保收集足够的数据', 'info'); log('请至少录制1-2秒音频以确保收集足够的数据', 'info');
@ -234,7 +234,7 @@ export class AudioRecorder {
} }
// Send listening start message // Send listening start message
if (this.websocket && this.websocket.readyState === WebSocket.OPEN) { if (this.websocket && this.websocket.readyState === WebSocket.OPEN) {
log(`已发送录音开始消息`, 'info'); log(`已发送Ghi âm开始消息`, 'info');
} else { } else {
log('WebSocket未连接,无法发送开始消息', 'error'); log('WebSocket未连接,无法发送开始消息', 'error');
return false; return false;
@ -256,10 +256,10 @@ export class AudioRecorder {
this.onRecordingStart(recordingSeconds); this.onRecordingStart(recordingSeconds);
} }
}, 100); }, 100);
log('已开始PCM直接录音', 'success'); log('已开始PCM直接Ghi âm', 'success');
return true; return true;
} catch (error) { } catch (error) {
log(`直接录音启动错误: ${error.message}`, 'error'); log(`直接Ghi âm启动错误: ${error.message}`, 'error');
this.isRecording = false; this.isRecording = false;
return false; return false;
} }
@ -308,15 +308,15 @@ export class AudioRecorder {
if (this.websocket && this.websocket.readyState === WebSocket.OPEN) { if (this.websocket && this.websocket.readyState === WebSocket.OPEN) {
const emptyOpusFrame = new Uint8Array(0); const emptyOpusFrame = new Uint8Array(0);
this.websocket.send(emptyOpusFrame); this.websocket.send(emptyOpusFrame);
log('已发送录音停止信号', 'info'); log('已发送Ghi âm停止信号', 'info');
} }
if (this.onRecordingStop) { if (this.onRecordingStop) {
this.onRecordingStop(); this.onRecordingStop();
} }
log('已停止PCM直接录音', 'success'); log('已停止PCM直接Ghi âm', 'success');
return true; return true;
} catch (error) { } catch (error) {
log(`直接录音停止错误: ${error.message}`, 'error'); log(`直接Ghi âm停止错误: ${error.message}`, 'error');
return false; return false;
} }
} }
@ -355,7 +355,7 @@ export async function checkMicrophoneAvailability() {
log('麦克风可用性检查成功', 'success'); log('麦克风可用性检查成功', 'success');
return true; return true;
} catch (error) { } catch (error) {
log(`麦克风不可用: ${error.message}`, 'warning'); log(`Micro không khả dụng: ${error.message}`, 'warning');
return false; return false;
} }
} }

View file

@ -30,7 +30,7 @@ export async function initMcpTools() {
const parsedTools = JSON.parse(savedTools); const parsedTools = JSON.parse(savedTools);
// 合并默认工具和用户保存的工具,保留用户自定义的工具 // 合并默认工具和用户保存的工具,保留用户自定义的工具
const defaultToolNames = new Set(defaultMcpTools.map(t => t.name)); const defaultToolNames = new Set(defaultMcpTools.map(t => t.name));
// 添加默认工具中不存在的新工具 // 添加默认工具中不存在的Công cụ mới
parsedTools.forEach(tool => { parsedTools.forEach(tool => {
if (!defaultToolNames.has(tool.name)) { if (!defaultToolNames.has(tool.name)) {
defaultMcpTools.push(tool); defaultMcpTools.push(tool);
@ -61,7 +61,7 @@ function renderMcpTools() {
countSpan.textContent = `${mcpTools.length} 个工具`; countSpan.textContent = `${mcpTools.length} 个工具`;
} }
if (mcpTools.length === 0) { if (mcpTools.length === 0) {
container.innerHTML = '<div style="text-align: center; padding: 30px; color: #999;">暂无工具,点击下方按钮添加新工具</div>'; container.innerHTML = '<div style="text-align: center; padding: 30px; color: #999;">暂无工具,点击下方按钮添加Công cụ mới</div>';
return; return;
} }
container.innerHTML = mcpTools.map((tool, index) => { container.innerHTML = mcpTools.map((tool, index) => {
@ -77,7 +77,7 @@ function renderMcpTools() {
✏️ 编辑 ✏️ 编辑
</button> </button>
<button class="mcp-delete-btn" onclick="window.mcpModule.deleteMcpTool(${index})"> <button class="mcp-delete-btn" onclick="window.mcpModule.deleteMcpTool(${index})">
🗑️ 删除 🗑️ Xóa
</button> </button>
</div> </div>
</div> </div>
@ -131,7 +131,7 @@ function renderMcpProperties() {
<span class="mcp-property-value">${prop.description || '-'}</span> <span class="mcp-property-value">${prop.description || '-'}</span>
</div> </div>
<div class="mcp-property-row-action"> <div class="mcp-property-row-action">
<button class="mcp-property-delete-btn" onclick="event.stopPropagation(); window.mcpModule.deleteMcpProperty(${index})">删除</button> <button class="mcp-property-delete-btn" onclick="event.stopPropagation(); window.mcpModule.deleteMcpProperty(${index})">Xóa</button>
</div> </div>
</div> </div>
`).join(''); `).join('');
@ -199,7 +199,7 @@ function openPropertyModal(index = null) {
} }
/** /**
* 关闭参数编辑模态框 * Tắt参数编辑模态框
*/ */
function closePropertyModal() { function closePropertyModal() {
document.getElementById('mcpPropertyModal').style.display = 'none'; document.getElementById('mcpPropertyModal').style.display = 'none';
@ -266,7 +266,7 @@ function handlePropertySubmit(e) {
} }
/** /**
* 删除参数 * Xóa参数
*/ */
function deleteMcpProperty(index) { function deleteMcpProperty(index) {
mcpProperties.splice(index, 1); mcpProperties.splice(index, 1);
@ -317,7 +317,7 @@ function setupMcpEventListeners() {
function openMcpModal(index = null) { function openMcpModal(index = null) {
const isConnected = websocket && websocket.readyState === WebSocket.OPEN; const isConnected = websocket && websocket.readyState === WebSocket.OPEN;
if (isConnected) { if (isConnected) {
alert('WebSocket 已连接,无法编辑工具'); alert('WebSocket Đã kết nối,无法编辑工具');
return; return;
} }
mcpEditingIndex = index; mcpEditingIndex = index;
@ -354,7 +354,7 @@ function openMcpModal(index = null) {
} }
/** /**
* 关闭模态框 * Tắt模态框
*/ */
function closeMcpModal() { function closeMcpModal() {
document.getElementById('mcpToolModal').style.display = 'none'; document.getElementById('mcpToolModal').style.display = 'none';
@ -377,7 +377,7 @@ function handleMcpSubmit(e) {
// 检查名称重复 // 检查名称重复
const isDuplicate = mcpTools.some((tool, index) => tool.name === name && index !== mcpEditingIndex); const isDuplicate = mcpTools.some((tool, index) => tool.name === name && index !== mcpEditingIndex);
if (isDuplicate) { if (isDuplicate) {
showMcpError('工具名称已存在,请使用不同的名称'); showMcpError('Tên công cụ已存在,请使用不同的名称');
return; return;
} }
// 解析模拟返回结果 // 解析模拟返回结果
@ -416,7 +416,7 @@ function handleMcpSubmit(e) {
const tool = { name, description, inputSchema, mockResponse }; const tool = { name, description, inputSchema, mockResponse };
if (mcpEditingIndex !== null) { if (mcpEditingIndex !== null) {
mcpTools[mcpEditingIndex] = tool; mcpTools[mcpEditingIndex] = tool;
log(`已更新工具: ${name}`, 'success'); log(`已更Công cụ mới: ${name}`, 'success');
} else { } else {
mcpTools.push(tool); mcpTools.push(tool);
log(`已添加工具: ${name}`, 'success'); log(`已添加工具: ${name}`, 'success');
@ -442,20 +442,20 @@ function editMcpTool(index) {
} }
/** /**
* 删除工具 * Xóa工具
*/ */
function deleteMcpTool(index) { function deleteMcpTool(index) {
const isConnected = websocket && websocket.readyState === WebSocket.OPEN; const isConnected = websocket && websocket.readyState === WebSocket.OPEN;
if (isConnected) { if (isConnected) {
alert('WebSocket 已连接,无法编辑工具'); alert('WebSocket Đã kết nối,无法编辑工具');
return; return;
} }
if (confirm(`确定要删除工具 "${mcpTools[index].name}" 吗?`)) { if (confirm(`确定要Xóa工具 "${mcpTools[index].name}" 吗?`)) {
const toolName = mcpTools[index].name; const toolName = mcpTools[index].name;
mcpTools.splice(index, 1); mcpTools.splice(index, 1);
saveMcpTools(); saveMcpTools();
renderMcpTools(); renderMcpTools();
log(`已删除工具: ${toolName}`, 'info'); log(`已Xóa工具: ${toolName}`, 'info');
} }
} }
@ -492,7 +492,7 @@ export async function executeMcpTool(toolName, toolArgs) {
return result; return result;
} else { } else {
log('拍照功能不可用', 'warning'); log('拍照功能不可用', 'warning');
return { success: false, error: '摄像头未启动或不支持拍照功能' }; return { success: false, error: 'Camera未启动或不支持拍照功能' };
} }
} }

View file

@ -28,7 +28,7 @@ function tryConnect() {
wakewordSocket = new WebSocket(bridgeUrl); wakewordSocket = new WebSocket(bridgeUrl);
wakewordSocket.onopen = () => { wakewordSocket.onopen = () => {
reconnectAttempts = 0; reconnectAttempts = 0;
log(`本地唤醒事件桥已连接: ${bridgeUrl}`, 'success'); log(`本地唤醒事件桥Đã kết nối: ${bridgeUrl}`, 'success');
// 连接成功后自动保存地址,刷新后仍能记住 // 连接成功后自动保存地址,刷新后仍能记住
localStorage.setItem('xz_tester_wakewordWsUrl', bridgeUrl); localStorage.setItem('xz_tester_wakewordWsUrl', bridgeUrl);
const urlInput = document.getElementById('wakewordWsUrl'); const urlInput = document.getElementById('wakewordWsUrl');
@ -36,7 +36,7 @@ function tryConnect() {
}; };
wakewordSocket.onerror = () => { wakewordSocket.onerror = () => {
log(`本地唤醒事件桥连接失败: ${bridgeUrl}`, 'error'); log(`本地唤醒事件桥Kết nối thất bại: ${bridgeUrl}`, 'error');
}; };
wakewordSocket.onmessage = async (event) => { wakewordSocket.onmessage = async (event) => {

View file

@ -98,7 +98,7 @@ export class WebSocketHandler {
if (message.type === 'hello') { if (message.type === 'hello') {
log(`服务器回应:${JSON.stringify(message, null, 2)}`, 'success'); log(`服务器回应:${JSON.stringify(message, null, 2)}`, 'success');
window.cameraAvailable = true; window.cameraAvailable = true;
log('连接成功,摄像头已可用', 'success'); log('连接成功,Camera已可用', 'success');
uiController.updateDialButton(true); uiController.updateDialButton(true);
this._sendWakeupMessages(message.session_id); this._sendWakeupMessages(message.session_id);
@ -112,19 +112,19 @@ export class WebSocketHandler {
log(`识别结果: ${message.text}`, 'info'); log(`识别结果: ${message.text}`, 'info');
// 检查是否需要绑定设备 // 检查是否需要绑定设备
if (message.text && (message.text.includes('绑定') || message.text.includes('bind'))) { if (message.text && (message.text.includes('绑定') || message.text.includes('bind'))) {
log('收到设备绑定提示,更新摄像头状态', 'warning'); log('收到设备绑定提示,更新Camera状态', 'warning');
window.cameraAvailable = false; window.cameraAvailable = false;
// 关闭摄像头 // TắtCamera
if (typeof window.stopCamera === 'function') { if (typeof window.stopCamera === 'function') {
window.stopCamera(); window.stopCamera();
} }
// 更新摄像头按钮状态 // 更新Camera按钮状态
const cameraBtn = document.getElementById('cameraBtn'); const cameraBtn = document.getElementById('cameraBtn');
if (cameraBtn) { if (cameraBtn) {
cameraBtn.classList.remove('camera-active'); cameraBtn.classList.remove('camera-active');
cameraBtn.querySelector('.btn-text').textContent = '摄像头'; cameraBtn.querySelector('.btn-text').textContent = 'Camera';
cameraBtn.disabled = true; cameraBtn.disabled = true;
cameraBtn.title = '请先绑定验证码'; cameraBtn.title = 'Vui lòng liên kết mã xác minh trước';
} }
} }
// 使用新的聊天消息回调显示STT消息 // 使用新的聊天消息回调显示STT消息
@ -256,7 +256,7 @@ export class WebSocketHandler {
if (live2dManager) { if (live2dManager) {
// 初始化音频分析器(使用音频播放器的上下文) // 初始化音频分析器(使用音频播放器的上下文)
if (live2dManager.initializeAudioAnalyzer()) { if (live2dManager.initializeAudioAnalyzer()) {
log('Live2D音频分析器初始化完成,已连接到音频播放器', 'success'); log('Live2D音频分析器初始化完成,Đã kết nối到音频播放器', 'success');
} else { } else {
log('Live2D音频分析器初始化失败,将使用模拟动画', 'warning'); log('Live2D音频分析器初始化失败,将使用模拟动画', 'warning');
} }
@ -413,7 +413,7 @@ export class WebSocketHandler {
// 设置 MCP 模块的 WebSocket 实例 // 设置 MCP 模块的 WebSocket 实例
setMcpWebSocket(this.websocket); setMcpWebSocket(this.websocket);
// 设置录音器的WebSocket // 设置Ghi âm器的WebSocket
const audioRecorder = getAudioRecorder(); const audioRecorder = getAudioRecorder();
audioRecorder.setWebSocket(this.websocket); audioRecorder.setWebSocket(this.websocket);
@ -433,7 +433,7 @@ export class WebSocketHandler {
setupEventHandlers() { setupEventHandlers() {
this.websocket.onopen = async () => { this.websocket.onopen = async () => {
const url = document.getElementById('serverUrl').value; const url = document.getElementById('serverUrl').value;
log(`已连接到服务器: ${url}`, 'success'); log(`Đã kết nối到服务器: ${url}`, 'success');
if (this.onConnectionStateChange) { if (this.onConnectionStateChange) {
this.onConnectionStateChange(true); this.onConnectionStateChange(true);
@ -461,12 +461,12 @@ export class WebSocketHandler {
const audioRecorder = getAudioRecorder(); const audioRecorder = getAudioRecorder();
audioRecorder.stop(); audioRecorder.stop();
// 关闭摄像头 // TắtCamera
if (typeof window.stopCamera === 'function') { if (typeof window.stopCamera === 'function') {
window.stopCamera(); window.stopCamera();
} }
// 隐藏摄像头显示区域 // 隐藏Camera显示区域
const cameraContainer = document.getElementById('cameraContainer'); const cameraContainer = document.getElementById('cameraContainer');
if (cameraContainer) { if (cameraContainer) {
cameraContainer.classList.remove('active'); cameraContainer.classList.remove('active');
@ -505,12 +505,12 @@ export class WebSocketHandler {
const audioRecorder = getAudioRecorder(); const audioRecorder = getAudioRecorder();
audioRecorder.stop(); audioRecorder.stop();
// 关闭摄像头 // TắtCamera
if (typeof window.stopCamera === 'function') { if (typeof window.stopCamera === 'function') {
window.stopCamera(); window.stopCamera();
} }
// 隐藏摄像头显示区域 // 隐藏Camera显示区域
const cameraContainer = document.getElementById('cameraContainer'); const cameraContainer = document.getElementById('cameraContainer');
if (cameraContainer) { if (cameraContainer) {
cameraContainer.classList.remove('active'); cameraContainer.classList.remove('active');
@ -574,7 +574,7 @@ export class WebSocketHandler {
return this.websocket; return this.websocket;
} }
// 检查是否已连接 // 检查是否Đã kết nối
isConnected() { isConnected() {
return this.websocket && this.websocket.readyState === WebSocket.OPEN; return this.websocket && this.websocket.readyState === WebSocket.OPEN;
} }

View file

@ -135,7 +135,7 @@ class UIController {
wsHandler.disconnect(); wsHandler.disconnect();
this.updateDialButton(false); this.updateDialButton(false);
if (cameraSwitch) cameraSwitch.classList.remove('active'); if (cameraSwitch) cameraSwitch.classList.remove('active');
this.addChatMessage('Disconnected, see you next time~😊', false); this.addChatMessage('Đã ngắt kết nối, hẹn gặp lại nhé 😊', false);
} else { } else {
// Check if OTA URL is filled // Check if OTA URL is filled
const otaUrlInput = document.getElementById('otaUrl'); const otaUrlInput = document.getElementById('otaUrl');
@ -143,7 +143,7 @@ class UIController {
// If OTA URL is not filled, show settings modal and switch to device tab // If OTA URL is not filled, show settings modal and switch to device tab
this.showModal('settingsModal'); this.showModal('settingsModal');
this.switchTab('device'); this.switchTab('device');
this.addChatMessage('Please fill in OTA server URL', false); this.addChatMessage('Vui lòng nhập địa chỉ máy chủ OTA', false);
return; return;
} }
@ -165,36 +165,36 @@ class UIController {
cameraTimer = setTimeout(() => { cameraTimer = setTimeout(() => {
const cameraContainer = document.getElementById('cameraContainer'); const cameraContainer = document.getElementById('cameraContainer');
if (!cameraContainer) { if (!cameraContainer) {
log('摄像头容器不存在', 'warning'); log('Không tìm thấy vùng hiển thị camera', 'warning');
return; return;
} }
const isActive = cameraContainer.classList.contains('active'); const isActive = cameraContainer.classList.contains('active');
if (isActive) { if (isActive) {
// 关闭摄像头 // TắtCamera
if (typeof window.stopCamera === 'function') { if (typeof window.stopCamera === 'function') {
if (cameraSwitch) cameraSwitch.classList.remove('active'); if (cameraSwitch) cameraSwitch.classList.remove('active');
window.stopCamera(); window.stopCamera();
} }
cameraContainer.classList.remove('active'); cameraContainer.classList.remove('active');
cameraBtn.classList.remove('camera-active'); cameraBtn.classList.remove('camera-active');
cameraBtn.querySelector('.btn-text').textContent = '摄像头'; cameraBtn.querySelector('.btn-text').textContent = 'Camera';
log('摄像头已关闭', 'info'); log('Camera đã tắt', 'info');
} else { } else {
// 打开摄像头 // 打开Camera
if (typeof window.startCamera === 'function') { if (typeof window.startCamera === 'function') {
window.startCamera().then(success => { window.startCamera().then(success => {
if (success) { if (success) {
cameraBtn.classList.add('camera-active'); cameraBtn.classList.add('camera-active');
cameraBtn.querySelector('.btn-text').textContent = '关闭'; cameraBtn.querySelector('.btn-text').textContent = 'Tắt';
} else { } else {
this.addChatMessage('⚠️ 摄像头启动失败,请检查浏览器权限', false); this.addChatMessage('⚠️ Camera启动失败,请检查浏览器权限', false);
} }
}).catch(error => { }).catch(error => {
log(`启动摄像头异常: ${error.message}`, 'error'); log(`启动Camera异常: ${error.message}`, 'error');
}); });
} else { } else {
log('startCamera函数未定义', 'warning'); log('Hàm startCamera chưa được định nghĩa', 'warning');
} }
} }
}, 300); }, 300);
@ -216,11 +216,11 @@ class UIController {
audioRecorder.stop(); audioRecorder.stop();
// Restore record button to normal state // Restore record button to normal state
recordBtn.classList.remove('recording'); recordBtn.classList.remove('recording');
recordBtn.querySelector('.btn-text').textContent = '录音'; recordBtn.querySelector('.btn-text').textContent = 'Ghi âm';
} else { } else {
// Update button state to recording // Update button state to recording
recordBtn.classList.add('recording'); recordBtn.classList.add('recording');
recordBtn.querySelector('.btn-text').textContent = '录音中'; recordBtn.querySelector('.btn-text').textContent = 'Đang ghi âm';
// Start recording, update button state after delay // Start recording, update button state after delay
setTimeout(() => { setTimeout(() => {
@ -274,15 +274,15 @@ class UIController {
applyWakewordBtn.addEventListener('click', this.handleApplyWakeword); applyWakewordBtn.addEventListener('click', this.handleApplyWakeword);
} }
// 点击模态框背景关闭(仅对特定模态框禁用此功能) // 点击模态框背景Tắt(仅对特定模态框禁用此功能)
const modals = document.querySelectorAll('.modal'); const modals = document.querySelectorAll('.modal');
modals.forEach(modal => { modals.forEach(modal => {
modal.addEventListener('click', (e) => { modal.addEventListener('click', (e) => {
if (e.target === modal) { if (e.target === modal) {
// settingsModal、mcpToolModal、mcpPropertyModal 只能通过点击X关闭 // settingsModal、mcpToolModal、mcpPropertyModal 只能通过点击XTắt
const nonClosableModals = ['settingsModal', 'mcpToolModal', 'mcpPropertyModal']; const nonClosableModals = ['settingsModal', 'mcpToolModal', 'mcpPropertyModal'];
if (nonClosableModals.includes(modal.id)) { if (nonClosableModals.includes(modal.id)) {
return; // 禁止点击背景关闭 return; // 禁止点击背景Tắt
} }
this.hideModal(modal.id); this.hideModal(modal.id);
} }
@ -308,12 +308,12 @@ class UIController {
if (connectionStatus) { if (connectionStatus) {
if (isConnected) { if (isConnected) {
connectionStatus.textContent = '已连接'; connectionStatus.textContent = 'Đã kết nối';
if (statusDot) { if (statusDot) {
statusDot.className = 'status-dot status-connected'; statusDot.className = 'status-dot status-connected';
} }
} else { } else {
connectionStatus.textContent = '离线'; connectionStatus.textContent = 'Ngoại tuyến';
if (statusDot) { if (statusDot) {
statusDot.className = 'status-dot status-disconnected'; statusDot.className = 'status-dot status-disconnected';
} }
@ -330,14 +330,14 @@ class UIController {
if (dialBtn) { if (dialBtn) {
if (isConnected) { if (isConnected) {
dialBtn.classList.add('dial-active'); dialBtn.classList.add('dial-active');
dialBtn.querySelector('.btn-text').textContent = '挂断'; dialBtn.querySelector('.btn-text').textContent = 'Ngắt kết nối';
// Update dial button icon to hang up icon // Update dial button icon to hang up icon
dialBtn.querySelector('svg').innerHTML = ` dialBtn.querySelector('svg').innerHTML = `
<path d="M12,9C10.4,9 9,10.4 9,12C9,13.6 10.4,15 12,15C13.6,15 15,13.6 15,12C15,10.4 13.6,9 12,9M12,17C9.2,17 7,14.8 7,12C7,9.2 9.2,7 12,7C14.8,7 17,9.2 17,12C17,14.8 14.8,17 12,17M12,4.5C7,4.5 2.7,7.6 1,12C2.7,16.4 7,19.5 12,19.5C17,19.5 21.3,16.4 23,12C21.3,7.6 17,4.5 12,4.5Z"/> <path d="M12,9C10.4,9 9,10.4 9,12C9,13.6 10.4,15 12,15C13.6,15 15,13.6 15,12C15,10.4 13.6,9 12,9M12,17C9.2,17 7,14.8 7,12C7,9.2 9.2,7 12,7C14.8,7 17,9.2 17,12C17,14.8 14.8,17 12,17M12,4.5C7,4.5 2.7,7.6 1,12C2.7,16.4 7,19.5 12,19.5C17,19.5 21.3,16.4 23,12C21.3,7.6 17,4.5 12,4.5Z"/>
`; `;
} else { } else {
dialBtn.classList.remove('dial-active'); dialBtn.classList.remove('dial-active');
dialBtn.querySelector('.btn-text').textContent = '拨号'; dialBtn.querySelector('.btn-text').textContent = 'Kết nối';
// Restore dial button icon // Restore dial button icon
dialBtn.querySelector('svg').innerHTML = ` dialBtn.querySelector('svg').innerHTML = `
<path d="M6.62,10.79C8.06,13.62 10.38,15.94 13.21,17.38L15.41,15.18C15.69,14.9 16.08,14.82 16.43,14.93C17.55,15.3 18.75,15.5 20,15.5A1,1 0 0,1 21,16.5V20A1,1 0 0,1 20,21A17,17 0 0,1 3,4A1,1 0 0,1 4,3H7.5A1,1 0 0,1 8.5,4C8.5,5.25 8.7,6.45 9.07,7.57C9.18,7.92 9.1,8.31 8.82,8.59L6.62,10.79Z"/> <path d="M6.62,10.79C8.06,13.62 10.38,15.94 13.21,17.38L15.41,15.18C15.69,14.9 16.08,14.82 16.43,14.93C17.55,15.3 18.75,15.5 20,15.5A1,1 0 0,1 21,16.5V20A1,1 0 0,1 20,21A17,17 0 0,1 3,4A1,1 0 0,1 4,3H7.5A1,1 0 0,1 8.5,4C8.5,5.25 8.7,6.45 9.07,7.57C9.18,7.92 9.1,8.31 8.82,8.59L6.62,10.79Z"/>
@ -352,10 +352,10 @@ class UIController {
cameraContainer.classList.remove('active'); cameraContainer.classList.remove('active');
} }
cameraBtn.classList.remove('camera-active'); cameraBtn.classList.remove('camera-active');
cameraBtn.querySelector('.btn-text').textContent = '摄像头'; cameraBtn.querySelector('.btn-text').textContent = 'Camera';
cameraBtn.disabled = true; cameraBtn.disabled = true;
cameraBtn.title = '请先连接服务器'; cameraBtn.title = 'Vui lòng kết nối máy chủ trước';
// 关闭摄像头 // TắtCamera
if (typeof window.stopCamera === 'function') { if (typeof window.stopCamera === 'function') {
window.stopCamera(); window.stopCamera();
} }
@ -365,10 +365,10 @@ class UIController {
if (cameraBtn && isConnected) { if (cameraBtn && isConnected) {
if (window.cameraAvailable) { if (window.cameraAvailable) {
cameraBtn.disabled = false; cameraBtn.disabled = false;
cameraBtn.title = '打开/关闭摄像头'; cameraBtn.title = '打开/TắtCamera';
} else { } else {
cameraBtn.disabled = true; cameraBtn.disabled = true;
cameraBtn.title = '请先绑定验证码'; cameraBtn.title = 'Vui lòng liên kết mã xác minh trước';
} }
} }
@ -377,19 +377,19 @@ class UIController {
const microphoneAvailable = window.microphoneAvailable !== false; const microphoneAvailable = window.microphoneAvailable !== false;
if (isConnected && microphoneAvailable) { if (isConnected && microphoneAvailable) {
recordBtn.disabled = false; recordBtn.disabled = false;
recordBtn.title = '开始录音'; recordBtn.title = '开始Ghi âm';
// Restore record button to normal state // Restore record button to normal state
recordBtn.querySelector('.btn-text').textContent = '录音'; recordBtn.querySelector('.btn-text').textContent = 'Ghi âm';
recordBtn.classList.remove('recording'); recordBtn.classList.remove('recording');
} else { } else {
recordBtn.disabled = true; recordBtn.disabled = true;
if (!microphoneAvailable) { if (!microphoneAvailable) {
recordBtn.title = window.isHttpNonLocalhost ? '当前由于是http访问,无法录音,只能用文字交互' : '麦克风不可用'; recordBtn.title = window.isHttpNonLocalhost ? '当前由于是http访问,无法Ghi âm,只能用文字交互' : 'Micro không khả dụng';
} else { } else {
recordBtn.title = '请先连接服务器'; recordBtn.title = 'Vui lòng kết nối máy chủ trước';
} }
// Restore record button to normal state // Restore record button to normal state
recordBtn.querySelector('.btn-text').textContent = '录音'; recordBtn.querySelector('.btn-text').textContent = 'Ghi âm';
recordBtn.classList.remove('recording'); recordBtn.classList.remove('recording');
} }
} }
@ -400,10 +400,10 @@ class UIController {
const recordBtn = document.getElementById('recordBtn'); const recordBtn = document.getElementById('recordBtn');
if (recordBtn) { if (recordBtn) {
if (isRecording) { if (isRecording) {
recordBtn.querySelector('.btn-text').textContent = `录音中`; recordBtn.querySelector('.btn-text').textContent = `Đang ghi âm`;
recordBtn.classList.add('recording'); recordBtn.classList.add('recording');
} else { } else {
recordBtn.querySelector('.btn-text').textContent = '录音'; recordBtn.querySelector('.btn-text').textContent = 'Ghi âm';
recordBtn.classList.remove('recording'); recordBtn.classList.remove('recording');
} }
// Only enable button when microphone is available // Only enable button when microphone is available
@ -423,15 +423,15 @@ class UIController {
// Disable record button // Disable record button
recordBtn.disabled = true; recordBtn.disabled = true;
// Update button text and title // Update button text and title
recordBtn.querySelector('.btn-text').textContent = '录音'; recordBtn.querySelector('.btn-text').textContent = 'Ghi âm';
recordBtn.title = isHttpNonLocalhost ? '当前由于是http访问,无法录音,只能用文字交互' : '麦克风不可用'; recordBtn.title = isHttpNonLocalhost ? '当前由于是http访问,无法Ghi âm,只能用文字交互' : 'Micro không khả dụng';
} else { } else {
// If connected, enable record button // If connected, enable record button
const wsHandler = getWebSocketHandler(); const wsHandler = getWebSocketHandler();
if (wsHandler && wsHandler.isConnected()) { if (wsHandler && wsHandler.isConnected()) {
recordBtn.disabled = false; recordBtn.disabled = false;
recordBtn.title = '开始录音'; recordBtn.title = '开始Ghi âm';
} }
} }
} }
@ -464,7 +464,7 @@ class UIController {
switchLive2DModel() { switchLive2DModel() {
const modelSelect = document.getElementById('live2dModelSelect'); const modelSelect = document.getElementById('live2dModelSelect');
if (!modelSelect) { if (!modelSelect) {
console.error('模型选择下拉框不存在'); console.error('Không tìm thấy danh sách chọn mô hình');
return; return;
} }
@ -475,17 +475,17 @@ class UIController {
app.live2dManager.switchModel(selectedModel) app.live2dManager.switchModel(selectedModel)
.then(success => { .then(success => {
if (success) { if (success) {
this.addChatMessage(`已切换到模型: ${selectedModel}`, false); this.addChatMessage(`Đã chuyển sang mô hình: ${selectedModel}`, false);
} else { } else {
this.addChatMessage('模型切换失败', false); this.addChatMessage('Chuyển mô hình thất bại', false);
} }
}) })
.catch(error => { .catch(error => {
console.error('模型切换错误:', error); console.error('Lỗi khi chuyển mô hình:', error);
this.addChatMessage('模型切换出错', false); this.addChatMessage('Có lỗi khi chuyển mô hình', false);
}); });
} else { } else {
this.addChatMessage('Live2D管理器未初始化', false); this.addChatMessage('Trình quản lý Live2D chưa được khởi tạo', false);
} }
} }
@ -561,14 +561,14 @@ class UIController {
}; };
if (payload.enabled && payload.wakeWords.length === 0) { if (payload.enabled && payload.wakeWords.length === 0) {
this.addChatMessage('启用唤醒词时,至少需要填写一个唤醒词。', false); this.addChatMessage('Khi bật từ khóa đánh thức, cần nhập ít nhất một từ khóa.', false);
return; return;
} }
const applyWakewordBtn = document.getElementById('applyWakewordBtn'); const applyWakewordBtn = document.getElementById('applyWakewordBtn');
if (applyWakewordBtn) { if (applyWakewordBtn) {
applyWakewordBtn.disabled = true; applyWakewordBtn.disabled = true;
applyWakewordBtn.textContent = '应用中...'; applyWakewordBtn.textContent = 'Đang áp dụng...';
} }
try { try {
@ -584,11 +584,11 @@ class UIController {
if (urlChanged) { if (urlChanged) {
// 地址变了,先确认 // 地址变了,先确认
const shouldRestart = window.confirm('地址已变更,是否继续?(将断开旧连接并重新连接)'); const shouldRestart = window.confirm('Địa chỉ đã thay đổi, bạn có muốn tiếp tục không? Kết nối cũ sẽ bị ngắt và kết nối lại.');
if (!shouldRestart) { if (!shouldRestart) {
// 恢复 localStorage 里的旧地址 // 恢复 localStorage 里的旧地址
localStorage.setItem('xz_tester_wakewordWsUrl', currentWsUrl); localStorage.setItem('xz_tester_wakewordWsUrl', currentWsUrl);
this.addChatMessage('已取消地址变更。', false); this.addChatMessage('Đã hủy thay đổi địa chỉ.', false);
return; return;
} }
@ -601,7 +601,7 @@ class UIController {
// 等 bridge_connected // 等 bridge_connected
await new Promise((resolve, reject) => { await new Promise((resolve, reject) => {
const timeout = setTimeout(() => { const timeout = setTimeout(() => {
reject(new Error('连接新服务器超时')); reject(new Error('Kết nối tới máy chủ mới bị quá thời gian'));
}, 5000); }, 5000);
onNextBridgeConnected(() => { onNextBridgeConnected(() => {
@ -614,40 +614,40 @@ class UIController {
await requestWakewordBridge('set_wakeword_config', payload); await requestWakewordBridge('set_wakeword_config', payload);
this.applyWakewordConfig(payload); this.applyWakewordConfig(payload);
await requestWakewordBridge('restart_wakeword_service'); await requestWakewordBridge('restart_wakeword_service');
this.addChatMessage('唤醒词配置已保存,唤醒词服务正在重启。', false); this.addChatMessage('Đã lưu cấu hình từ khóa đánh thức, dịch vụ đang khởi động lại.', false);
} else { } else {
// 地址没变:直接在当前连接操作 // 地址没变:直接在当前连接操作
const response = await requestWakewordBridge('set_wakeword_config', payload); const response = await requestWakewordBridge('set_wakeword_config', payload);
this.applyWakewordConfig(response.payload || payload); this.applyWakewordConfig(response.payload || payload);
const shouldRestart = window.confirm('唤醒词已保存。是否现在重启唤醒词服务以立即生效?'); const shouldRestart = window.confirm('Đã lưu từ khóa đánh thức. Bạn có muốn khởi động lại dịch vụ ngay để áp dụng không?');
if (!shouldRestart) { if (!shouldRestart) {
this.addChatMessage('唤醒词配置已保存,可稍后手动重启服务后生效。', false); this.addChatMessage('Đã lưu cấu hình từ khóa đánh thức. Có thể khởi động lại dịch vụ sau để áp dụng.', false);
return; return;
} }
await requestWakewordBridge('restart_wakeword_service'); await requestWakewordBridge('restart_wakeword_service');
this.addChatMessage('唤醒词配置已保存,唤醒词服务正在重启。', false); this.addChatMessage('Đã lưu cấu hình từ khóa đánh thức, dịch vụ đang khởi động lại.', false);
} }
} catch (error) { } catch (error) {
this.addChatMessage(`应用唤醒词失败: ${error.message}`, false); this.addChatMessage(`Áp dụng từ khóa đánh thức thất bại: ${error.message}`, false);
} finally { } finally {
if (applyWakewordBtn) { if (applyWakewordBtn) {
applyWakewordBtn.disabled = false; applyWakewordBtn.disabled = false;
applyWakewordBtn.textContent = '应用唤醒词'; applyWakewordBtn.textContent = 'Áp dụng từ khóa đánh thức';
} }
} }
} }
// Start AI chat session after connection // Start AI chat session after connection
startAIChatSession() { startAIChatSession() {
this.addChatMessage('连接成功,开始聊天吧~😊', false); this.addChatMessage('Kết nối thành công, bắt đầu trò chuyện nhé! 😊', false);
// Check microphone availability and show error messages if needed // Check microphone availability and show error messages if needed
if (!window.microphoneAvailable) { if (!window.microphoneAvailable) {
if (window.isHttpNonLocalhost) { if (window.isHttpNonLocalhost) {
this.addChatMessage('⚠️ 当前由于是http访问,无法录音,只能用文字交互', false); this.addChatMessage('⚠️ 当前由于是http访问,无法Ghi âm,只能用文字交互', false);
} else { } else {
this.addChatMessage('⚠️ 麦克风不可用,请检查权限设置,只能用文字交互', false); this.addChatMessage('⚠️ Micro không khả dụng,请检查权限设置,只能用文字交互', false);
} }
} }
// Start recording only if microphone is available // Start recording only if microphone is available
@ -664,13 +664,13 @@ class UIController {
const cameraBtn = document.getElementById('cameraBtn'); const cameraBtn = document.getElementById('cameraBtn');
if (cameraBtn) { if (cameraBtn) {
cameraBtn.classList.add('camera-active'); cameraBtn.classList.add('camera-active');
cameraBtn.querySelector('.btn-text').textContent = '关闭'; cameraBtn.querySelector('.btn-text').textContent = 'Tắt';
} }
} else { } else {
this.addChatMessage('⚠️ 摄像头启动失败,可能被浏览器拒绝', false); this.addChatMessage('⚠️ Camera启动失败,可能被浏览器拒绝', false);
} }
}).catch(error => { }).catch(error => {
log(`启动摄像头异常: ${error.message}`, 'error'); log(`启动Camera异常: ${error.message}`, 'error');
}); });
} }
} }
@ -679,7 +679,7 @@ class UIController {
async handleConnect() { async handleConnect() {
const wsHandler = getWebSocketHandler(); const wsHandler = getWebSocketHandler();
if (this.isConnecting || (wsHandler && wsHandler.isConnected())) { if (this.isConnecting || (wsHandler && wsHandler.isConnected())) {
log('连接已存在或正在进行,忽略本次拨号请求', 'info'); log('连接已存在或正在进行,忽略本次Kết nối请求', 'info');
return; return;
} }
@ -698,7 +698,7 @@ class UIController {
console.log('otaUrl element:', otaUrlInput); console.log('otaUrl element:', otaUrlInput);
if (!otaUrlInput || !otaUrlInput.value) { if (!otaUrlInput || !otaUrlInput.value) {
this.addChatMessage('请输入OTA服务器地址', false); this.addChatMessage('Vui lòng nhập địa chỉ máy chủ OTA', false);
return; return;
} }
@ -709,12 +709,12 @@ class UIController {
const dialBtn = document.getElementById('dialBtn'); const dialBtn = document.getElementById('dialBtn');
if (dialBtn) { if (dialBtn) {
dialBtn.classList.add('dial-active'); dialBtn.classList.add('dial-active');
dialBtn.querySelector('.btn-text').textContent = '连接中...'; dialBtn.querySelector('.btn-text').textContent = 'Đang kết nối...';
dialBtn.disabled = true; dialBtn.disabled = true;
} }
// Show connecting message // Show connecting message
this.addChatMessage('正在连接服务器...', false); this.addChatMessage('Đang kết nối tới máy chủ...', false);
const chatIpt = document.getElementById('chatIpt'); const chatIpt = document.getElementById('chatIpt');
if (chatIpt) { if (chatIpt) {
@ -739,10 +739,10 @@ class UIController {
if (recordBtn) { if (recordBtn) {
if (isRecording) { if (isRecording) {
recordBtn.classList.add('recording'); recordBtn.classList.add('recording');
recordBtn.querySelector('.btn-text').textContent = '录音中'; recordBtn.querySelector('.btn-text').textContent = 'Đang ghi âm';
} else { } else {
recordBtn.classList.remove('recording'); recordBtn.classList.remove('recording');
recordBtn.querySelector('.btn-text').textContent = '录音'; recordBtn.querySelector('.btn-text').textContent = 'Ghi âm';
} }
} }
}; };
@ -757,7 +757,7 @@ class UIController {
if (!micAvailable) { if (!micAvailable) {
const isHttp = window.isHttpNonLocalhost; const isHttp = window.isHttpNonLocalhost;
if (isHttp) { if (isHttp) {
this.addChatMessage('⚠️ 当前由于是http访问,无法录音,只能用文字交互', false); this.addChatMessage('⚠️ 当前由于是http访问,无法Ghi âm,只能用文字交互', false);
} }
// Update global state // Update global state
window.microphoneAvailable = false; window.microphoneAvailable = false;
@ -769,13 +769,13 @@ class UIController {
if (!this.dialBtnDisabled) { if (!this.dialBtnDisabled) {
dialBtn.disabled = false; dialBtn.disabled = false;
} }
dialBtn.querySelector('.btn-text').textContent = '挂断'; dialBtn.querySelector('.btn-text').textContent = 'Ngắt kết nối';
dialBtn.classList.add('dial-active'); dialBtn.classList.add('dial-active');
} }
this.hideModal('settingsModal'); this.hideModal('settingsModal');
} else { } else {
throw new Error('OTA连接失败'); throw new Error('OTAKết nối thất bại');
} }
} catch (error) { } catch (error) {
console.error('Connection error details:', { console.error('Connection error details:', {
@ -786,8 +786,8 @@ class UIController {
// Show error message // Show error message
const errorMessage = error.message.includes('Cannot set properties of null') const errorMessage = error.message.includes('Cannot set properties of null')
? '连接失败:请检查设备连接' ? 'Kết nối thất bại: vui lòng kiểm tra thiết bị'
: `连接失败: ${error.message}`; : `Kết nối thất bại: ${error.message}`;
this.addChatMessage(errorMessage, false); this.addChatMessage(errorMessage, false);
@ -797,7 +797,7 @@ class UIController {
if (!this.dialBtnDisabled) { if (!this.dialBtnDisabled) {
dialBtn.disabled = false; dialBtn.disabled = false;
} }
dialBtn.querySelector('.btn-text').textContent = '拨号'; dialBtn.querySelector('.btn-text').textContent = 'Kết nối';
dialBtn.classList.remove('dial-active'); dialBtn.classList.remove('dial-active');
console.log('Dial button state restored successfully'); console.log('Dial button state restored successfully');
} }
@ -811,22 +811,22 @@ class UIController {
const now = Date.now(); const now = Date.now();
if (wsHandler && wsHandler.isConnected()) { if (wsHandler && wsHandler.isConnected()) {
log('页面已连接,忽略自动拨号', 'info'); log('页面Đã kết nối,忽略自动Kết nối', 'info');
return false; return false;
} }
if (this.isConnecting || this.dialBtnDisabled) { if (this.isConnecting || this.dialBtnDisabled) {
log('页面正在连接中,忽略重复唤醒', 'info'); log('Trang đang kết nối, bỏ qua đánh thức lặp lại', 'info');
return false; return false;
} }
if (now - this.lastWakewordDialTime < 3000) { if (now - this.lastWakewordDialTime < 3000) {
log('唤醒触发过于频繁,忽略本次自动拨号', 'warning'); log('唤醒触发过于频繁,忽略本次自动Kết nối', 'warning');
return false; return false;
} }
this.lastWakewordDialTime = now; this.lastWakewordDialTime = now;
this.addChatMessage(`检测到唤醒词“${wakeWord}”,准备连接服务器...`, false); this.addChatMessage(`Đã phát hiện từ khóa đánh thức“${wakeWord}”,Đang chuẩn bị kết nối máy chủ...`, false);
await this.handleConnect(); await this.handleConnect();
return true; return true;
} }
@ -841,9 +841,9 @@ class UIController {
toolDiv.className = 'properties-container'; toolDiv.className = 'properties-container';
toolDiv.innerHTML = ` toolDiv.innerHTML = `
<div class="property-item"> <div class="property-item">
<input type="text" placeholder="工具名称" value="新工具"> <input type="text" placeholder="Tên công cụ" value="Công cụ mới">
<input type="text" placeholder="工具描述" value="工具描述"> <input type="text" placeholder="Mô tả công cụ" value="Mô tả công cụ">
<button class="remove-property" onclick="uiController.removeMCPTool('${toolId}')">删除</button> <button class="remove-property" onclick="uiController.removeMCPTool('${toolId}')">Xóa</button>
</div> </div>
`; `;

View file

@ -0,0 +1,81 @@
from pathlib import Path
root = Path(__file__).parent
replacements = {
"正在连接服务器...": "Đang kết nối tới máy chủ...",
"连接成功,开始聊天吧~😊": "Kết nối thành công, bắt đầu trò chuyện nhé! 😊",
"Disconnected, see you next time~😊": "Đã ngắt kết nối, hẹn gặp lại nhé 😊",
"Please fill in OTA server URL": "Vui lòng nhập địa chỉ máy chủ OTA",
"摄像头容器不存在": "Không tìm thấy vùng hiển thị camera",
"摄像头已关闭": "Camera đã tắt",
"摄像头": "Camera",
"关闭": "Tắt",
"摄像头启动失败,请检查浏览器权限": "Không thể khởi động camera, vui lòng kiểm tra quyền trình duyệt",
"摄像头启动失败,可能被浏览器拒绝": "Không thể khởi động camera, có thể trình duyệt đã từ chối quyền",
"启动摄像头异常": "Lỗi khi khởi động camera",
"startCamera函数未定义": "Hàm startCamera chưa được định nghĩa",
"录音中": "Đang ghi âm",
"录音": "Ghi âm",
"已连接": "Đã kết nối",
"离线": "Ngoại tuyến",
"挂断": "Ngắt kết nối",
"拨号": "Kết nối",
"请先连接服务器": "Vui lòng kết nối máy chủ trước",
"打开/关闭摄像头": "Bật/tắt camera",
"请先绑定验证码": "Vui lòng liên kết mã xác minh trước",
"开始录音": "Bắt đầu ghi âm",
"当前由于是http访问,无法录音,只能用文字交互": "Hiện đang truy cập bằng HTTP nên không thể ghi âm, chỉ có thể nhập văn bản",
"麦克风不可用": "Micro không khả dụng",
"模型选择下拉框不存在": "Không tìm thấy danh sách chọn mô hình",
"已切换到模型": "Đã chuyển sang mô hình",
"模型切换失败": "Chuyển mô hình thất bại",
"模型切换错误": "Lỗi khi chuyển mô hình",
"模型切换出错": "Có lỗi khi chuyển mô hình",
"Live2D管理器未初始化": "Trình quản lý Live2D chưa được khởi tạo",
"启用唤醒词时,至少需要填写一个唤醒词。": "Khi bật từ khóa đánh thức, cần nhập ít nhất một từ khóa.",
"应用中...": "Đang áp dụng...",
"地址已变更,是否继续?(将断开旧连接并重新连接)": "Địa chỉ đã thay đổi, bạn có muốn tiếp tục không? Kết nối cũ sẽ bị ngắt và kết nối lại.",
"已取消地址变更。": "Đã hủy thay đổi địa chỉ.",
"连接新服务器超时": "Kết nối tới máy chủ mới bị quá thời gian",
"唤醒词配置已保存,唤醒词服务正在重启。": "Đã lưu cấu hình từ khóa đánh thức, dịch vụ đang khởi động lại.",
"唤醒词已保存。是否现在重启唤醒词服务以立即生效?": "Đã lưu từ khóa đánh thức. Bạn có muốn khởi động lại dịch vụ ngay để áp dụng không?",
"唤醒词配置已保存,可稍后手动重启服务后生效。": "Đã lưu cấu hình từ khóa đánh thức. Có thể khởi động lại dịch vụ sau để áp dụng.",
"应用唤醒词失败": "Áp dụng từ khóa đánh thức thất bại",
"应用唤醒词": "Áp dụng từ khóa đánh thức",
"请输入OTA服务器地址": "Vui lòng nhập địa chỉ máy chủ OTA",
"连接中...": "Đang kết nối...",
"连接失败:请检查设备连接": "Kết nối thất bại: vui lòng kiểm tra thiết bị",
"连接失败": "Kết nối thất bại",
"OTA连接失败": "Kết nối OTA thất bại",
"连接已存在或正在进行,忽略本次拨号请求": "Kết nối đã tồn tại hoặc đang thực hiện, bỏ qua yêu cầu này",
"页面已连接,忽略自动拨号": "Trang đã kết nối, bỏ qua tự động kết nối",
"页面正在连接中,忽略重复唤醒": "Trang đang kết nối, bỏ qua đánh thức lặp lại",
"唤醒触发过于频繁,忽略本次自动拨号": "Kích hoạt đánh thức quá thường xuyên, bỏ qua lần này",
"检测到唤醒词": "Đã phát hiện từ khóa đánh thức",
"准备连接服务器": "Đang chuẩn bị kết nối máy chủ",
"工具名称": "Tên công cụ",
"新工具": "Công cụ mới",
"工具描述": "Mô tả công cụ",
"删除": "Xóa",
"⚠️ 麦克风不可用,请检查权限设置,只能用文字交互": "⚠️ Không thể sử dụng micro, vui lòng kiểm tra quyền truy cập. Chỉ có thể nhập văn bản.",
"⚠️ 当前由于是http访问,无法录音,只能用文字交互": "⚠️ Đang truy cập bằng HTTP nên không thể ghi âm, chỉ có thể nhập văn bản.",
}
exts = {".js", ".html", ".css"}
changed = []
for path in root.rglob("*"):
if path.is_file() and path.suffix.lower() in exts:
text = path.read_text(encoding="utf-8", errors="ignore")
old = text
for a, b in replacements.items():
text = text.replace(a, b)
if text != old:
path.write_text(text, encoding="utf-8")
changed.append(str(path.relative_to(root)))
print("Đã Việt hóa các file:")
for f in changed:
print(" -", f)
print("Xong.")

View file

@ -765,7 +765,11 @@ VLLM:
# 开通应用地址:https://console.xfyun.cn/app/myapp # 开通应用地址:https://console.xfyun.cn/app/myapp
# 有免费额度,但也要开通服务,才能获取api_key # 有免费额度,但也要开通服务,才能获取api_key
# 每一个模型都需要单独开通,每一个模型的 api_key 都不同,例如 Lite 模型在 https://console.xfyun.cn/services/cbm 开通 # 每一个模型都需要单独开通,每一个模型的 api_key 都不同,例如 Lite 模型在 https://console.xfyun.cn/services/cbm 开通
base_url: https://ark.cn-beijing.volces.com/api/v3 # 讯飞星火的 OpenAI 兼容端点,可用模型名(lite / 4.0Ultra 等)见
# https://www.xfyun.cn/doc/spark/HTTP调用文档.html
# 注意 base_url 必须指向讯飞自己的域名。这里曾误填成火山方舟的
# ark.cn-beijing.volces.com,会把讯飞的 api_key 发给火山引擎。
base_url: https://spark-api-open.xf-yun.com/v1
model_name: lite model_name: lite
api_key: 你的api_key api_key: 你的api_key
TTS: TTS:

View file

@ -0,0 +1,81 @@
"""供应器默认端点自检:防止不同 provider 的 base_url 被复制粘贴串台。
背景:``config.yaml`` 里每个 provider 的 ``base_url`` / ``url`` 都是照抄对应
厂商文档填的,很容易从相邻的 provider 直接复制粘贴。真实案例:``VLLM``
段的 ``XunfeiSparkLLM`` 抄了上面 ``LLM.DoubaoLLM`` 的火山方舟地址
(ark.cn-beijing.volces.com),选它做视觉模型时会把讯飞的 api_key 发给
火山引擎,而 ``model_name: lite`` 在那个端点上并不存在。
这里用一张「配置块 -> 端点主机名」的对照表把这类串台钉死。新增 provider
时顺手往表里加一行即可。
注意:本用例读的是仓库里**出厂的** ``config.yaml``,不是用户
``data/.config.yaml`` 合并后的结果 —— 要守的就是这份出厂默认值。
"""
from __future__ import annotations
from urllib.parse import urlparse
import pytest
from config.config_loader import get_project_dir, read_config
# (模块段, provider 名, 端点主机名里必须出现的片段)
PROVIDER_ENDPOINT_HOSTS = [
("LLM", "AliLLM", "dashscope.aliyuncs.com"),
("LLM", "AliAppLLM", "dashscope.aliyuncs.com"),
("LLM", "ChatGLMLLM", "bigmodel.cn"),
("LLM", "DeepSeekLLM", "deepseek.com"),
("LLM", "DifyLLM", "dify.ai"),
("LLM", "DoubaoLLM", "volces.com"),
("LLM", "VolcesAiGatewayLLM", "volces.com"),
("VLLM", "ChatGLMVLLM", "bigmodel.cn"),
("VLLM", "QwenVLVLLM", "dashscope.aliyuncs.com"),
("VLLM", "XunfeiSparkLLM", "xf-yun.com"),
("ASR", "OpenaiASR", "api.openai.com"),
("ASR", "GroqASR", "api.groq.com"),
("ASR", "Qwen3ASRFlash", "dashscope.aliyuncs.com"),
("TTS", "OpenAITTS", "api.openai.com"),
("TTS", "DoubaoTTS", "bytedance.com"),
("TTS", "TTS302AI", "302ai.cn"),
("TTS", "VolcesAiGatewayTTS", "volces.com"),
]
@pytest.fixture(scope="module")
def default_config():
"""仓库里出厂的默认配置(未经用户 data/.config.yaml 覆盖)。"""
return read_config(get_project_dir() + "config.yaml")
def _endpoint_of(block: dict) -> str:
"""取 provider 配置块里生效的端点。
顺序与运行时一致:``core/providers/vllm/openai.py`` 和
``core/providers/llm/openai/openai.py`` 都是 ``base_url`` 优先、
``url`` 兜底;部分 TTS 用 ``api_url``。
"""
return block.get("base_url") or block.get("url") or block.get("api_url") or ""
@pytest.mark.parametrize(
"module,provider,expected_host",
PROVIDER_ENDPOINT_HOSTS,
ids=[f"{m}.{p}" for m, p, _ in PROVIDER_ENDPOINT_HOSTS],
)
def test_provider_endpoint_matches_platform(
default_config, module, provider, expected_host
):
"""provider 的端点必须落在它自己那家厂商的域名下。"""
block = default_config.get(module, {}).get(provider)
assert block is not None, f"config.yaml 里找不到 {module}.{provider} 配置块"
endpoint = _endpoint_of(block)
assert endpoint, f"{module}.{provider} 没有配置 base_url / url / api_url"
host = urlparse(endpoint).netloc
assert expected_host in host, (
f"{module}.{provider} 的端点 {endpoint!r} 解析出的主机是 {host!r},"
f"与平台不符(期望包含 {expected_host!r})—— 疑似从别的 provider 复制粘贴时带串了"
)