# tianyupaipai-cmd/pai-voice architecture

> Architecture diagram of the GitHub repository tianyupaipai-cmd/pai-voice, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/tianyupaipai-cmd/pai-voice
- Repository: https://github.com/tianyupaipai-cmd/pai-voice

## Overview

PaiVoice is a self-hostable real-time voice/video calling layer with a replaceable browser client, ASR, reply adapter, and TTS. The main workflow captures microphone audio, sends it to the WebSocket core for transcription, obtains a reply through an HTTP adapter, and returns text/audio for playback. Video and screen-sharing form a parallel vision path; call events also reach the chosen adapter. The README documents additional integration options, but only the tmux and file adapters are present in this tree. Relationships are limited to excerpted code and README statements.

Main entry points: [`packages/realtime-core/server.py`](https://github.com/tianyupaipai-cmd/pai-voice/blob/main/packages/realtime-core/server.py) (Call and turn core), [`packages/web-client/voice-call.js`](https://github.com/tianyupaipai-cmd/pai-voice/blob/main/packages/web-client/voice-call.js) (Voice client), [`packages/adapters/tmux/reply.js`](https://github.com/tianyupaipai-cmd/pai-voice/blob/main/packages/adapters/tmux/reply.js) (Reply helper), [`packages/adapters/file/server.js`](https://github.com/tianyupaipai-cmd/pai-voice/blob/main/packages/adapters/file/server.js) (File adapter)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Browser calling"]
  node_web["Voice client<br/>[voice-call.js]"]
end

subgraph group_core["Realtime core"]
  node_core_server["Call and turn core<br/>[server.py]"]
  node_asr{{"ASR provider"}}
  node_tts{{"TTS provider"}}
  node_vision_core["Vision call handling<br/>[server.py]"]
end

subgraph group_vision["Visual processing"]
  node_eyes["Vision model chain<br/>[vision.py]"]
  node_vision_service{{"Vision API"}}
end

subgraph group_adapters["Reply adapters"]
  node_adapter_protocol["Adapter HTTP endpoint<br/>[server.py]"]
  node_tmux_adapter["tmux adapter<br/>[server.js]"]
  node_tmux_session["User tmux session"]
  node_file_adapter["File adapter<br/>[server.js]"]
  node_inbox[("Inbox JSONL")]
  node_reply_helper["Reply helper<br/>[reply.js]"]
end

node_caller(("Caller"))
node_agent(("Terminal agent"))

node_caller -->|"speaks and views"| node_web
node_web -->|"sends call events"| node_core_server
node_core_server -->|"transcribes audio"| node_asr
node_core_server -->|"requests reply"| node_adapter_protocol
node_adapter_protocol -.->|"routes HTTP"| node_tmux_adapter
node_adapter_protocol -.->|"routes HTTP"| node_file_adapter
node_tmux_adapter -->|"injects turn and events"| node_tmux_session
node_agent -->|"submits reply"| node_reply_helper
node_reply_helper -->|"posts reply"| node_tmux_adapter
node_file_adapter -->|"appends records"| node_inbox
node_agent -->|"submits reply"| node_reply_helper
node_core_server -->|"synthesizes reply"| node_tts
node_core_server -->|"streams response audio"| node_web
node_web -->|"sends video frames"| node_vision_core
node_vision_core -->|"requests descriptions"| node_eyes
node_eyes -->|"sends images"| node_vision_service
node_vision_core -->|"notifies visual events"| node_adapter_protocol
node_core_server -->|"forwards call events"| node_adapter_protocol
node_file_adapter -->|"offers reply command"| node_reply_helper

click node_web "https://github.com/tianyupaipai-cmd/pai-voice/blob/main/packages/web-client/voice-call.js"
click node_core_server "https://github.com/tianyupaipai-cmd/pai-voice/blob/main/packages/realtime-core/server.py"
click node_vision_core "https://github.com/tianyupaipai-cmd/pai-voice/blob/main/packages/realtime-core/server.py"
click node_eyes "https://github.com/tianyupaipai-cmd/pai-voice/blob/main/packages/realtime-core/vision.py"
click node_adapter_protocol "https://github.com/tianyupaipai-cmd/pai-voice/blob/main/packages/realtime-core/server.py"
click node_tmux_adapter "https://github.com/tianyupaipai-cmd/pai-voice/blob/main/packages/adapters/tmux/server.js"
click node_file_adapter "https://github.com/tianyupaipai-cmd/pai-voice/blob/main/packages/adapters/file/server.js"
click node_reply_helper "https://github.com/tianyupaipai-cmd/pai-voice/blob/main/packages/adapters/tmux/reply.js"

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_web toneBlue
class node_core_server,node_asr,node_tts,node_vision_core toneAmber
class node_eyes,node_vision_service toneMint
class node_adapter_protocol,node_tmux_adapter,node_tmux_session,node_file_adapter,node_inbox,node_reply_helper toneRose
class node_caller,node_agent toneIndigo
```

## Components

### Browser calling

- [Voice client](https://github.com/tianyupaipai-cmd/pai-voice/blob/main/packages/web-client/voice-call.js): `packages/web-client/voice-call.js`

### Realtime core

- [Call and turn core](https://github.com/tianyupaipai-cmd/pai-voice/blob/main/packages/realtime-core/server.py): `packages/realtime-core/server.py`
- **ASR provider**
- **TTS provider**
- [Vision call handling](https://github.com/tianyupaipai-cmd/pai-voice/blob/main/packages/realtime-core/server.py): `packages/realtime-core/server.py`

### Visual processing

- [Vision model chain](https://github.com/tianyupaipai-cmd/pai-voice/blob/main/packages/realtime-core/vision.py): `packages/realtime-core/vision.py`
- **Vision API**

### Reply adapters

- [Adapter HTTP endpoint](https://github.com/tianyupaipai-cmd/pai-voice/blob/main/packages/realtime-core/server.py): `packages/realtime-core/server.py`
- [tmux adapter](https://github.com/tianyupaipai-cmd/pai-voice/blob/main/packages/adapters/tmux/server.js): `packages/adapters/tmux/server.js`
- **User tmux session**
- [File adapter](https://github.com/tianyupaipai-cmd/pai-voice/blob/main/packages/adapters/file/server.js): `packages/adapters/file/server.js`
- **Inbox JSONL**
- [Reply helper](https://github.com/tianyupaipai-cmd/pai-voice/blob/main/packages/adapters/tmux/reply.js): `packages/adapters/tmux/reply.js`

### Other components

- **Caller**
- **Terminal agent**

## Connections

- Caller → Voice client: speaks and views (evidence: `README.md`)
- Voice client → Call and turn core: sends call events (evidence: `README.md`)
- Call and turn core → ASR provider: transcribes audio (evidence: `packages/realtime-core/server.py`)
- Call and turn core → Adapter HTTP endpoint: requests reply (evidence: `packages/realtime-core/server.py`)
- Adapter HTTP endpoint → tmux adapter: routes HTTP
- Adapter HTTP endpoint → File adapter: routes HTTP
- tmux adapter → User tmux session: injects turn and events (evidence: `packages/adapters/tmux/server.js`)
- Terminal agent → Reply helper: submits reply (evidence: `README.md`)
- Reply helper → tmux adapter: posts reply (evidence: `packages/adapters/tmux/reply.js`)
- File adapter → Inbox JSONL: appends records (evidence: `packages/adapters/file/server.js`)
- Terminal agent → Reply helper: submits reply (evidence: `README.md`)
- Call and turn core → TTS provider: synthesizes reply (evidence: `README.md`)
- Call and turn core → Voice client: streams response audio (evidence: `README.md`)
- Voice client → Vision call handling: sends video frames (evidence: `packages/web-client/voice-call.js`)
- Vision call handling → Vision model chain: requests descriptions (evidence: `packages/realtime-core/server.py`)
- Vision model chain → Vision API: sends images (evidence: `packages/realtime-core/vision.py`)
- Vision call handling → Adapter HTTP endpoint: notifies visual events (evidence: `packages/realtime-core/server.py`)
- Call and turn core → Adapter HTTP endpoint: forwards call events (evidence: `packages/realtime-core/server.py`)
- File adapter → Reply helper: offers reply command (evidence: `packages/adapters/file/server.js`)
