# lucascala28/voice_assistant architecture

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

- Interactive diagram: https://gitdiagram.com/lucascala28/voice_assistant
- Repository: https://github.com/lucascala28/voice_assistant

## Overview

This repository implements a local voice assistant: microphone audio is gated by a wake word and voice-activity detection, transcribed, sent to a tool-capable language model, and answered with speech. Model-selected tools can control configured smart plugs or retrieve weather. The main orchestration and those tool integrations are visible in excerpts; no README is present, and unsampled files limit evidence for additional capabilities and runtime wiring.

Main entry points: [`mic/req_to_res.py`](https://github.com/lucascala28/voice_assistant/blob/master/mic/req_to_res.py) (Model and tools), [`mic/vad.py`](https://github.com/lucascala28/voice_assistant/blob/master/mic/vad.py) (Speech segmentation), [`mic/smart_home.py`](https://github.com/lucascala28/voice_assistant/blob/master/mic/smart_home.py) (Smart plug control), [`mic/init.py`](https://github.com/lucascala28/voice_assistant/blob/master/mic/init.py) (Assistant runtime)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_audio_in["Audio input"]
  node_microphone["Microphone stream<br/>[mic_connect.py]"]
  node_wake["Wake detection"]
  node_vad["Speech segmentation<br/>[vad.py]"]
  node_transcription["Speech transcription<br/>[transcribe.py]"]
end

subgraph group_assistant["Assistant conversation"]
  node_runtime["Assistant runtime<br/>[init.py]"]
  node_model_router["Model and tools<br/>[req_to_res.py]"]
end

subgraph group_tools["Assistant tools"]
  node_smart_home["Smart plug control<br/>[smart_home.py]"]
  node_device_config["Device configuration"]
  node_weather["Weather lookup<br/>[weather.py]"]
  node_user_database[("User information database<br/>[userinfo.db]")]
end

subgraph group_speech_out["Speech output"]
  node_tts["Speech synthesis<br/>[tts.py]"]
  node_completion_audio["Task completion sound<br/>[task-complete.mp3]"]
end

node_user(("Voice user"))
node_language_model["Language model service"]
node_plug_services["Tuya / Kasa plugs"]
node_weather_service["Weather and geocoding APIs"]

node_user -->|"speaks into"| node_microphone
node_vad -->|"reads frames"| node_microphone
node_vad -->|"checks wake word"| node_wake
node_vad -->|"yields speech audio"| node_transcription
node_runtime -->|"collects transcripts"| node_transcription
node_runtime -->|"submits transcript"| node_model_router
node_model_router -->|"requests response"| node_language_model
node_model_router -->|"dispatches device tool"| node_smart_home
node_model_router -->|"dispatches weather tool"| node_weather
node_smart_home -->|"loads devices"| node_device_config
node_smart_home -->|"controls plugs"| node_plug_services
node_weather -->|"requests forecasts"| node_weather_service
node_model_router -->|"speaks response"| node_tts
node_model_router -->|"plays completion sound"| node_completion_audio
node_model_router -.-> node_user_database

click node_microphone "https://github.com/lucascala28/voice_assistant/blob/master/mic/mic_connect.py"
click node_wake "https://github.com/lucascala28/voice_assistant/blob/master/mic/wake_word_detect.py"
click node_vad "https://github.com/lucascala28/voice_assistant/blob/master/mic/vad.py"
click node_transcription "https://github.com/lucascala28/voice_assistant/blob/master/mic/transcribe.py"
click node_runtime "https://github.com/lucascala28/voice_assistant/blob/master/mic/init.py"
click node_model_router "https://github.com/lucascala28/voice_assistant/blob/master/mic/req_to_res.py"
click node_tts "https://github.com/lucascala28/voice_assistant/blob/master/mic/tts.py"
click node_smart_home "https://github.com/lucascala28/voice_assistant/blob/master/mic/smart_home.py"
click node_weather "https://github.com/lucascala28/voice_assistant/blob/master/mic/weather.py"
click node_completion_audio "https://github.com/lucascala28/voice_assistant/blob/master/mic/task-complete.mp3"
click node_user_database "https://github.com/lucascala28/voice_assistant/blob/master/data/userinfo.db"

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_microphone,node_wake,node_vad,node_transcription,node_user toneBlue
class node_runtime,node_model_router toneAmber
class node_smart_home,node_device_config,node_weather,node_user_database,node_weather_service toneMint
class node_tts,node_completion_audio toneRose
class node_language_model,node_plug_services toneIndigo
```

## Components

### Audio input

- [Microphone stream](https://github.com/lucascala28/voice_assistant/blob/master/mic/mic_connect.py): `mic/mic_connect.py`
- [Wake detection](https://github.com/lucascala28/voice_assistant/blob/master/mic/wake_word_detect.py): `mic/wake_word_detect.py`
- [Speech segmentation](https://github.com/lucascala28/voice_assistant/blob/master/mic/vad.py): `mic/vad.py`
- [Speech transcription](https://github.com/lucascala28/voice_assistant/blob/master/mic/transcribe.py): `mic/transcribe.py`

### Assistant conversation

- [Assistant runtime](https://github.com/lucascala28/voice_assistant/blob/master/mic/init.py): `mic/init.py`
- [Model and tools](https://github.com/lucascala28/voice_assistant/blob/master/mic/req_to_res.py): `mic/req_to_res.py`

### Assistant tools

- [Smart plug control](https://github.com/lucascala28/voice_assistant/blob/master/mic/smart_home.py): `mic/smart_home.py`
- **Device configuration**
- [Weather lookup](https://github.com/lucascala28/voice_assistant/blob/master/mic/weather.py): `mic/weather.py`
- [User information database](https://github.com/lucascala28/voice_assistant/blob/master/data/userinfo.db): `data/userinfo.db`

### Speech output

- [Speech synthesis](https://github.com/lucascala28/voice_assistant/blob/master/mic/tts.py): `mic/tts.py`
- [Task completion sound](https://github.com/lucascala28/voice_assistant/blob/master/mic/task-complete.mp3): `mic/task-complete.mp3`

### Other components

- **Voice user**
- **Language model service**
- **Tuya / Kasa plugs**
- **Weather and geocoding APIs**

## Connections

- Voice user → Microphone stream: speaks into (evidence: `mic/mic_connect.py`)
- Speech segmentation → Microphone stream: reads frames (evidence: `mic/vad.py`)
- Speech segmentation → Wake detection: checks wake word (evidence: `mic/vad.py`)
- Speech segmentation → Speech transcription: yields speech audio (evidence: `mic/transcribe.py`)
- Assistant runtime → Speech transcription: collects transcripts (evidence: `mic/init.py`)
- Assistant runtime → Model and tools: submits transcript (evidence: `mic/init.py`)
- Model and tools → Language model service: requests response (evidence: `mic/req_to_res.py`)
- Model and tools → Smart plug control: dispatches device tool (evidence: `mic/req_to_res.py`)
- Model and tools → Weather lookup: dispatches weather tool (evidence: `mic/req_to_res.py`)
- Smart plug control → Device configuration: loads devices (evidence: `mic/smart_home.py`)
- Smart plug control → Tuya / Kasa plugs: controls plugs (evidence: `mic/smart_home.py`)
- Weather lookup → Weather and geocoding APIs: requests forecasts (evidence: `mic/weather.py`)
- Model and tools → Speech synthesis: speaks response (evidence: `mic/req_to_res.py`)
- Model and tools → Task completion sound: plays completion sound (evidence: `mic/req_to_res.py`)
- Model and tools → User information database
