# xxushengcchen/littlenavigator architecture

> Architecture diagram of the GitHub repository xxushengcchen/littlenavigator, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-18). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/xxushengcchen/littlenavigator
- Repository: https://github.com/xxushengcchen/littlenavigator

## Overview

小小领航员是面向 iRacing 中文玩家的本地按键语音问答助手，也提供可独立安装的中文 Spotter 语音包。主要流程是用户按住键盘或方向盘按钮提问，助手本地识别并匹配受限意图，读取遥测、生成语音素材序列并离线播放；未识别的问题可记录供后续补充。图中保留了配置、桌面界面及语音包素材合成支线。关系依据 README 与所示源码索引/摘录；未展示的遥测实现细节不展开。

Main entry points: [`voice-assistant/src/engine.py`](https://github.com/xxushengcchen/littlenavigator/blob/main/voice-assistant/src/engine.py) (问答引擎), [`voice-assistant/app/server.py`](https://github.com/xxushengcchen/littlenavigator/blob/main/voice-assistant/app/server.py) (本地服务), [`voice-assistant/src/listener.py`](https://github.com/xxushengcchen/littlenavigator/blob/main/voice-assistant/src/listener.py) (按键监听录音), [`voice-assistant/src/phrase_match.py`](https://github.com/xxushengcchen/littlenavigator/blob/main/voice-assistant/src/phrase_match.py) (短语意图匹配)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["应用入口"]
  node_desktop["桌面窗口<br/>[desktop.py]"]
  node_http["本地服务<br/>[server.py]"]
  node_webui["浏览器界面<br/>[app.js]"]
  node_settings["运行配置<br/>[config.py]"]
end

subgraph group_input["语音输入"]
  node_ptt["按键监听录音<br/>[listener.py]"]
  node_wheel["方向盘输入<br/>[wheel.py]"]
  node_asr["本地语音识别<br/>[asr_models.py]"]
  node_audioio["音频读写<br/>[audio_io.py]"]
end

subgraph group_answer["问答与遥测"]
  node_assistant["问答引擎<br/>[engine.py]"]
  node_matcher["短语意图匹配<br/>[phrase_match.py]"]
  node_forms["问法扩展<br/>[question_forms.py]"]
  node_intents["意图定义<br/>[intents.py]"]
  node_router["回答路由<br/>[router.py]"]
  node_numbers["数值语音拼装<br/>[numbers.py]"]
  node_telemetry["iRacing遥测<br/>[telemetry.py]"]
  node_derived["圈速派生状态"]
  node_logs["问答与未命中记录<br/>[engine.py]"]
end

subgraph group_audio["语音输出与素材"]
  node_voicepack["语音包索引与变体<br/>[voicepack.py]"]
  node_player["音频播放<br/>[player.py]"]
  node_content["语音内容加载<br/>[content_loader.py]"]
  node_tts["语音素材合成<br/>[tts_doubao.py]"]
end

node_driver(("赛车玩家"))
node_iracing(("iRacing模拟器"))
node_doubao(("豆包TTS服务"))

node_driver -->|"提问与设置"| node_desktop
node_desktop -->|"启动服务"| node_http
node_driver -->|"按键提问"| node_webui
node_webui -.->|"调用接口"| node_http
node_http -->|"转交问答"| node_assistant
node_http -->|"加载识别器"| node_asr
node_http -->|"管理监听"| node_ptt
node_http -->|"采集绑定"| node_wheel
node_http -->|"读取配置"| node_settings
node_ptt -->|"检测按钮"| node_wheel
node_ptt -->|"处理录音"| node_audioio
node_ptt -.->|"提交音频"| node_asr
node_assistant -->|"匹配问法"| node_matcher
node_assistant -->|"路由回答"| node_router
node_assistant -->|"读取快照"| node_telemetry
node_assistant -->|"加载素材"| node_voicepack
node_assistant -->|"播放回答"| node_player
node_assistant -->|"记录结果"| node_logs
node_assistant -->|"读取配置"| node_settings
node_matcher -->|"扩展问法"| node_forms
node_matcher -.->|"读取意图短语"| node_intents
node_router -->|"拼装数值"| node_numbers
node_router -->|"查询回答"| node_derived
node_telemetry -->|"读取遥测"| node_iracing
node_assistant -.->|"更新圈速状态"| node_derived
node_content -->|"提供内容"| node_tts
node_tts -->|"请求合成"| node_doubao
node_voicepack -.->|"提供音频变体"| node_player

click node_desktop "https://github.com/xxushengcchen/littlenavigator/blob/main/voice-assistant/app/desktop.py"
click node_http "https://github.com/xxushengcchen/littlenavigator/blob/main/voice-assistant/app/server.py"
click node_webui "https://github.com/xxushengcchen/littlenavigator/blob/main/voice-assistant/app/static/app.js"
click node_settings "https://github.com/xxushengcchen/littlenavigator/blob/main/voice-assistant/src/config.py"
click node_ptt "https://github.com/xxushengcchen/littlenavigator/blob/main/voice-assistant/src/listener.py"
click node_wheel "https://github.com/xxushengcchen/littlenavigator/blob/main/voice-assistant/src/wheel.py"
click node_asr "https://github.com/xxushengcchen/littlenavigator/blob/main/voice-assistant/tools/asr_models.py"
click node_audioio "https://github.com/xxushengcchen/littlenavigator/blob/main/voice-assistant/tools/audio_io.py"
click node_assistant "https://github.com/xxushengcchen/littlenavigator/blob/main/voice-assistant/src/engine.py"
click node_matcher "https://github.com/xxushengcchen/littlenavigator/blob/main/voice-assistant/src/phrase_match.py"
click node_forms "https://github.com/xxushengcchen/littlenavigator/blob/main/voice-assistant/src/question_forms.py"
click node_intents "https://github.com/xxushengcchen/littlenavigator/blob/main/voice-assistant/src/intents.py"
click node_router "https://github.com/xxushengcchen/littlenavigator/blob/main/voice-assistant/src/router.py"
click node_numbers "https://github.com/xxushengcchen/littlenavigator/blob/main/voice-assistant/src/numbers.py"
click node_telemetry "https://github.com/xxushengcchen/littlenavigator/blob/main/voice-assistant/src/telemetry.py"
click node_derived "https://github.com/xxushengcchen/littlenavigator/blob/main/voice-assistant/src/telemetry_answers.py"
click node_logs "https://github.com/xxushengcchen/littlenavigator/blob/main/voice-assistant/src/engine.py"
click node_voicepack "https://github.com/xxushengcchen/littlenavigator/blob/main/voice-assistant/src/voicepack.py"
click node_player "https://github.com/xxushengcchen/littlenavigator/blob/main/voice-assistant/src/player.py"
click node_content "https://github.com/xxushengcchen/littlenavigator/blob/main/scripts/content_loader.py"
click node_tts "https://github.com/xxushengcchen/littlenavigator/blob/main/scripts/tts_doubao.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_desktop,node_http,node_webui,node_settings toneBlue
class node_ptt,node_wheel,node_asr,node_audioio toneAmber
class node_assistant,node_matcher,node_forms,node_intents,node_router,node_numbers,node_telemetry,node_derived,node_logs toneMint
class node_voicepack,node_player,node_content,node_tts toneRose
class node_driver,node_iracing,node_doubao toneIndigo
```

## Components

### 应用入口

- [桌面窗口](https://github.com/xxushengcchen/littlenavigator/blob/main/voice-assistant/app/desktop.py): `voice-assistant/app/desktop.py`
- [本地服务](https://github.com/xxushengcchen/littlenavigator/blob/main/voice-assistant/app/server.py): `voice-assistant/app/server.py`
- [浏览器界面](https://github.com/xxushengcchen/littlenavigator/blob/main/voice-assistant/app/static/app.js): `voice-assistant/app/static/app.js`
- [运行配置](https://github.com/xxushengcchen/littlenavigator/blob/main/voice-assistant/src/config.py): `voice-assistant/src/config.py`

### 语音输入

- [按键监听录音](https://github.com/xxushengcchen/littlenavigator/blob/main/voice-assistant/src/listener.py): `voice-assistant/src/listener.py`
- [方向盘输入](https://github.com/xxushengcchen/littlenavigator/blob/main/voice-assistant/src/wheel.py): `voice-assistant/src/wheel.py`
- [本地语音识别](https://github.com/xxushengcchen/littlenavigator/blob/main/voice-assistant/tools/asr_models.py): `voice-assistant/tools/asr_models.py`
- [音频读写](https://github.com/xxushengcchen/littlenavigator/blob/main/voice-assistant/tools/audio_io.py): `voice-assistant/tools/audio_io.py`

### 问答与遥测

- [问答引擎](https://github.com/xxushengcchen/littlenavigator/blob/main/voice-assistant/src/engine.py): `voice-assistant/src/engine.py`
- [短语意图匹配](https://github.com/xxushengcchen/littlenavigator/blob/main/voice-assistant/src/phrase_match.py): `voice-assistant/src/phrase_match.py`
- [问法扩展](https://github.com/xxushengcchen/littlenavigator/blob/main/voice-assistant/src/question_forms.py): `voice-assistant/src/question_forms.py`
- [意图定义](https://github.com/xxushengcchen/littlenavigator/blob/main/voice-assistant/src/intents.py): `voice-assistant/src/intents.py`
- [回答路由](https://github.com/xxushengcchen/littlenavigator/blob/main/voice-assistant/src/router.py): `voice-assistant/src/router.py`
- [数值语音拼装](https://github.com/xxushengcchen/littlenavigator/blob/main/voice-assistant/src/numbers.py): `voice-assistant/src/numbers.py`
- [iRacing遥测](https://github.com/xxushengcchen/littlenavigator/blob/main/voice-assistant/src/telemetry.py): `voice-assistant/src/telemetry.py`
- [圈速派生状态](https://github.com/xxushengcchen/littlenavigator/blob/main/voice-assistant/src/telemetry_answers.py): `voice-assistant/src/telemetry_answers.py`
- [问答与未命中记录](https://github.com/xxushengcchen/littlenavigator/blob/main/voice-assistant/src/engine.py): `voice-assistant/src/engine.py`

### 语音输出与素材

- [语音包索引与变体](https://github.com/xxushengcchen/littlenavigator/blob/main/voice-assistant/src/voicepack.py): `voice-assistant/src/voicepack.py`
- [音频播放](https://github.com/xxushengcchen/littlenavigator/blob/main/voice-assistant/src/player.py): `voice-assistant/src/player.py`
- [语音内容加载](https://github.com/xxushengcchen/littlenavigator/blob/main/scripts/content_loader.py): `scripts/content_loader.py`
- [语音素材合成](https://github.com/xxushengcchen/littlenavigator/blob/main/scripts/tts_doubao.py): `scripts/tts_doubao.py`

### Other components

- **赛车玩家**
- **iRacing模拟器**
- **豆包TTS服务**

## Connections

- 赛车玩家 → 桌面窗口: 提问与设置
- 桌面窗口 → 本地服务: 启动服务 (evidence: `voice-assistant/app/desktop.py`)
- 赛车玩家 → 浏览器界面: 按键提问
- 浏览器界面 → 本地服务: 调用接口
- 本地服务 → 问答引擎: 转交问答 (evidence: `voice-assistant/app/server.py`)
- 本地服务 → 本地语音识别: 加载识别器 (evidence: `voice-assistant/app/server.py`)
- 本地服务 → 按键监听录音: 管理监听 (evidence: `voice-assistant/app/server.py`)
- 本地服务 → 方向盘输入: 采集绑定 (evidence: `voice-assistant/app/server.py`)
- 本地服务 → 运行配置: 读取配置 (evidence: `voice-assistant/app/server.py`)
- 按键监听录音 → 方向盘输入: 检测按钮 (evidence: `voice-assistant/src/listener.py`)
- 按键监听录音 → 音频读写: 处理录音 (evidence: `voice-assistant/src/listener.py`)
- 按键监听录音 → 本地语音识别: 提交音频
- 问答引擎 → 短语意图匹配: 匹配问法 (evidence: `voice-assistant/src/engine.py`)
- 问答引擎 → 回答路由: 路由回答 (evidence: `voice-assistant/src/engine.py`)
- 问答引擎 → iRacing遥测: 读取快照 (evidence: `voice-assistant/src/engine.py`)
- 问答引擎 → 语音包索引与变体: 加载素材 (evidence: `voice-assistant/src/engine.py`)
- 问答引擎 → 音频播放: 播放回答 (evidence: `voice-assistant/src/engine.py`)
- 问答引擎 → 问答与未命中记录: 记录结果 (evidence: `voice-assistant/src/engine.py`)
- 问答引擎 → 运行配置: 读取配置 (evidence: `voice-assistant/src/engine.py`)
- 短语意图匹配 → 问法扩展: 扩展问法 (evidence: `voice-assistant/src/phrase_match.py`)
- 短语意图匹配 → 意图定义: 读取意图短语
- 回答路由 → 数值语音拼装: 拼装数值 (evidence: `voice-assistant/src/router.py`)
- 回答路由 → 圈速派生状态: 查询回答 (evidence: `voice-assistant/src/router.py`)
- iRacing遥测 → iRacing模拟器: 读取遥测
- 问答引擎 → 圈速派生状态: 更新圈速状态
- 语音内容加载 → 语音素材合成: 提供内容 (evidence: `scripts/tts_doubao.py`)
- 语音素材合成 → 豆包TTS服务: 请求合成 (evidence: `scripts/tts_doubao.py`)
- 语音包索引与变体 → 音频播放: 提供音频变体
