Skip to content

VRSecretary is a production-ready reference implementation for building AI-powered assistants in virtual reality. It combines Unreal Engine 5 (VR), a FastAPI backend, local/cloud LLM backends (Ollama, IBM watsonx.ai), and Chatterbox TTS to drive an interactive VR secretary avatar. The project includes an Unreal plugin, a sample VR demo level

License

Notifications You must be signed in to change notification settings

ruslanmv/VRSecretary

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

43 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

VRSecretary

๐Ÿค– AI-Powered VR Secretary โ€“ Production-ready reference implementation combining Unreal Engine 5 VR, local/cloud LLMs, and high-quality TTS for fully interactive virtual assistants in VR.

License Unreal Engine Python PRs Welcome Code Style

Features โ€ข Quick Start โ€ข Documentation โ€ข Architecture โ€ข Contributing


VRSecretary Demo


๐Ÿ“‘ Table of Contents


โœจ What Is VRSecretary?

VRSecretary is a production-ready, open-source reference architecture for building AI-powered conversational characters in VR. It combines cutting-edge language models with spatial audio and immersive interaction to create a natural, engaging virtual assistant experience.

Core Technologies

  • Frontend: Unreal Engine 5 (VR-native, supports Meta Quest, PCVR, and more)
  • Backend: Python FastAPI (modular, extensible, engine-agnostic)
  • LLM: Flexible backend support:
    • Local: Ollama (llama3, Mistral, Granite, etc.)
    • Cloud: IBM watsonx.ai
    • In-Engine: llama.cpp via Llama-Unreal plugin
  • TTS: Chatterbox (natural-sounding, sentence-aware streaming)

What's Included

โœ… Complete Unreal Engine 5 VR project with sample secretary character
โœ… Production-ready plugin (VRSecretary) with Blueprint support
โœ… FastAPI gateway backend with clean REST API
โœ… Sample 3D avatar (Scifi Girl v.01 - non-commercial demo)
โœ… Comprehensive documentation and integration guides
โœ… Multiple backend modes (Gateway, Direct Ollama, Local Llama.cpp)
โœ… Docker support for easy deployment
โœ… Load testing tools and performance benchmarks


๐ŸŒŸ Key Features

๐Ÿฅฝ VR-Native Experience

  • Full 6DOF interaction with VR controllers
  • 3D spatial audio that follows the character
  • Real-time subtitles floating above the avatar
  • Teleportation and smooth locomotion support
  • Hand presence and gesture recognition ready

๐Ÿง  Flexible AI Backends

Mode Description Use Case
Gateway (Ollama) FastAPI โ†’ Ollama โ†’ TTS โ†’ UE Local development, full features
Gateway (watsonx) FastAPI โ†’ watsonx.ai โ†’ TTS โ†’ UE Cloud deployment, enterprise
Direct Ollama UE โ†’ OpenAI-style API โ†’ UE Text-only, simple integration
Local Llama.cpp UE โ†’ in-engine llama.cpp โ†’ UE Offline, embedded deployment

๐ŸŽ™๏ธ High-Quality Voice Synthesis

  • Sentence-aware streaming for natural pacing
  • Configurable voice parameters (temperature, speed, exaggeration)
  • Multiple voice profiles (female/male, extensible)
  • CUDA/MPS acceleration for real-time generation
  • EOS-safe chunking prevents audio artifacts

๐Ÿ”ง Production-Ready Architecture

  • Engine-agnostic REST API (Unity, Godot, Web can use same backend)
  • Session management with conversation history
  • Comprehensive error handling and logging
  • Configurable via environment variables and Project Settings
  • Dockerized deployment with compose files
  • Load testing scripts included

๐Ÿ“ฆ Modular & Extensible

  • Clean separation of concerns (backend, plugin, assets)
  • Blueprint-friendly components for rapid prototyping
  • C++ API for advanced customization
  • Plugin system for adding new LLM/TTS providers
  • Multiple language support ready

๐Ÿ’ป System Requirements

Minimum Requirements

Component Specification
OS Windows 10/11 (recommended), Linux/macOS (backend only)
CPU Quad-core Intel/AMD, 2.5 GHz+
RAM 16 GB
GPU NVIDIA GTX 1060 or equivalent (for VR)
Storage 30 GB free space (SSD recommended)
VR Headset Meta Quest 2/3, Valve Index, or compatible PCVR

Recommended Requirements

Component Specification
CPU 8-core Intel i7/AMD Ryzen 7, 3.5 GHz+
RAM 32 GB
GPU NVIDIA RTX 3060 or better (CUDA for LLM/TTS acceleration)
Storage 50 GB free space on NVMe SSD

Software Dependencies

Required:

  • Unreal Engine 5.3 or later (with C++ source access)
  • Visual Studio 2022 (Windows) with "Game development with C++" workload
  • Python 3.10 or later
  • Git (for cloning repository)

Optional:

  • Docker Desktop (for containerized backend)
  • Node.js & k6 (for load testing)
  • CUDA Toolkit 11.8+ (for GPU acceleration)

๐Ÿš€ Quick Start Guide

Get from zero to working VR secretary in ~30 minutes.

Step 1: Clone Repository

git clone https://github.com/ruslanmv/VRSecretary.git
cd VRSecretary

Step 2: Start Backend Services

2.1 Install Ollama

Download and install from https://ollama.ai/

# Start Ollama server
ollama serve

# In a new terminal, download a model
ollama pull llama3

Verify:

curl http://localhost:11434/v1/models

2.2 Setup Python Environment

cd backend/gateway

# Create virtual environment
python -m venv .venv

# Activate (Windows PowerShell)
.venv\Scripts\Activate.ps1

# Activate (Linux/macOS)
# source .venv/bin/activate

# Install dependencies
pip install -e .

2.3 Configure Environment

# Copy template
cp ../docker/env.example .env

# Edit .env with your preferred editor

Minimal .env configuration:

MODE=offline_local_ollama

OLLAMA_BASE_URL=http://localhost:11434
OLLAMA_MODEL=llama3
OLLAMA_TIMEOUT=60.0

CHATTERBOX_URL=http://localhost:4123
CHATTERBOX_TIMEOUT=30.0

SESSION_MAX_HISTORY=10

2.4 Start Gateway Server

uvicorn vrsecretary_gateway.main:app --reload --host 0.0.0.0 --port 8000

Verify backend is running:

Step 3: Start TTS Server

In a new terminal (keep gateway running):

# From repo root
cd VRSecretary

# Activate same venv
backend/gateway/.venv/Scripts/Activate.ps1  # Windows
# source backend/gateway/.venv/bin/activate  # Linux/macOS

# Start Chatterbox TTS server
python tools/vr_chatterbox_server.py --host 0.0.0.0 --port 4123

Optional environment variables:

# Force CUDA (default: auto-detect)
export CHATTERBOX_DEVICE=cuda

# Chunk size for streaming (default: 20 words)
export CHATTERBOX_CHUNK_SIZE=20

# Custom voice files (optional)
export CHATTERBOX_FEMALE_VOICE=/path/to/female_voice.wav
export CHATTERBOX_MALE_VOICE=/path/to/male_voice.wav

Test TTS (PowerShell):

Invoke-WebRequest `
  -Uri "http://localhost:4123/v1/audio/speech" `
  -Method POST `
  -ContentType "application/json" `
  -Body '{"input": "Hello from Ailey.", "voice": "female"}' `
  -OutFile "test.wav"

Test TTS (curl):

curl -X POST http://localhost:4123/v1/audio/speech \
  -H "Content-Type: application/json" \
  -d '{"input": "Hello from Ailey.", "voice": "female"}' \
  --output test.wav

Play test.wav to verify audio quality.

Step 4: Verify End-to-End

With all three services running (Ollama, Gateway, TTS):

curl -X POST http://localhost:8000/api/vr_chat \
  -H "Content-Type: application/json" \
  -d '{"session_id": "test-123", "user_text": "Hello Ailey, introduce yourself."}'

Expected response:

{
  "assistant_text": "Hi! I'm Ailey, your VR secretary. I'm here to help...",
  "audio_wav_base64": "UklGRiQAAABXQVZF..."
}

โœ… If you see text and base64 audio, the backend is working!

Step 5: Open Unreal Project

5.1 Generate Project Files

Navigate to:

VRSecretary/samples/unreal-vr-secretary-demo/

Right-click VRSecretaryDemo.uproject โ†’ Generate Visual Studio project files

5.2 Open in Unreal

Double-click VRSecretaryDemo.uproject

Unreal will:

  1. Compile C++ modules (including VRSecretary plugin)
  2. Load the project (first time may take 5-10 minutes)

5.3 Enable Plugin

  1. Edit โ†’ Plugins
  2. Search: VRSecretary
  3. โœ… Check Enabled (should already be checked)
  4. Restart editor if prompted

5.4 Configure Plugin Settings

  1. Edit โ†’ Project Settings
  2. Navigate to: Plugins โ†’ VRSecretary
  3. Set:
    • Gateway URL: http://localhost:8000
    • Backend Mode: Gateway (Ollama)
    • HTTP Timeout: 60.0
    • Language Code: (leave empty for English)

Step 6: Import Avatar

6.1 Locate Avatar File

VRSecretary/assets/avatars/scifi_girl_v01/scifi_girl_v.01.glb

6.2 Import to Unreal

  1. In Content Browser, navigate to: /Game/Characters/ScifiGirl/
  2. Right-click โ†’ Import to /Game/Characters/ScifiGirl/
  3. Select scifi_girl_v.01.glb
  4. Import Settings:
    • โœ… Import Mesh
    • โœ… Import Skeletal Mesh
    • โœ… Import Materials
    • โœ… Import Textures
  5. Click Import All

6.3 Setup Blueprint

Open BP_SecretaryAvatar:

  1. Components panel โ†’ Select Mesh component
  2. Details panel โ†’ Mesh โ†’ Select imported skeletal mesh
  3. Adjust Transform if needed (scale, rotation)
  4. Compile and Save

Step 7: Test in VR

7.1 Connect VR Headset

  • Meta Quest: Enable developer mode, connect via Link/Air Link
  • PCVR: Connect via SteamVR or native runtime

7.2 Launch VR Preview

  1. Click Play dropdown (top toolbar)
  2. Select VR Preview
  3. Put on headset

7.3 Interact with Ailey

Desktop Mode (testing without VR):

  • Press T key โ†’ Opens chat interface
  • Type message โ†’ Press Enter
  • See subtitle above character
  • Hear audio response

VR Mode:

  • Press Right Trigger โ†’ Opens 3D chat panel
  • Point laser at text field โ†’ Click trigger to focus
  • Use VR keyboard or voice input (if configured)
  • Press trigger on Send button

Expected behavior:

  1. Your message appears in chat
  2. Subtitle appears above Ailey's head
  3. Audio plays from character position (3D spatial)
  4. Response text appears in chat history

๐Ÿ—‚๏ธ Repository Structure

VRSecretary/
โ”œโ”€โ”€ ๐Ÿ“ assets/
โ”‚   โ””โ”€โ”€ ๐Ÿ“ avatars/
โ”‚       โ””โ”€โ”€ ๐Ÿ“ scifi_girl_v01/
โ”‚           โ”œโ”€โ”€ scifi_girl_v.01.glb          # Sample avatar (CC BY-NC-SA)
โ”‚           โ”œโ”€โ”€ README.md                    # License & attribution
โ”‚           โ””โ”€โ”€ DOWNLOAD_INSTRUCTIONS.txt
โ”‚
โ”œโ”€โ”€ ๐Ÿ“ backend/
โ”‚   โ”œโ”€โ”€ ๐Ÿ“ gateway/                          # FastAPI backend
โ”‚   โ”‚   โ”œโ”€โ”€ pyproject.toml                   # Python dependencies
โ”‚   โ”‚   โ”œโ”€โ”€ README.md                        # Backend docs
โ”‚   โ”‚   โ””โ”€โ”€ ๐Ÿ“ vrsecretary_gateway/
โ”‚   โ”‚       โ”œโ”€โ”€ main.py                      # FastAPI app entrypoint
โ”‚   โ”‚       โ”œโ”€โ”€ config.py                    # Settings (Pydantic)
โ”‚   โ”‚       โ”œโ”€โ”€ ๐Ÿ“ api/                      # REST endpoints
โ”‚   โ”‚       โ”‚   โ”œโ”€โ”€ health_router.py
โ”‚   โ”‚       โ”‚   โ””โ”€โ”€ vr_chat_router.py
โ”‚   โ”‚       โ”œโ”€โ”€ ๐Ÿ“ llm/                      # LLM clients
โ”‚   โ”‚       โ”‚   โ”œโ”€โ”€ base_client.py
โ”‚   โ”‚       โ”‚   โ”œโ”€โ”€ ollama_client.py
โ”‚   โ”‚       โ”‚   โ””โ”€โ”€ watsonx_client.py
โ”‚   โ”‚       โ”œโ”€โ”€ ๐Ÿ“ tts/                      # TTS integration
โ”‚   โ”‚       โ”‚   โ””โ”€โ”€ chatterbox_client.py
โ”‚   โ”‚       โ””โ”€โ”€ ๐Ÿ“ models/                   # Request/response schemas
โ”‚   โ”‚           โ”œโ”€โ”€ chat_models.py
โ”‚   โ”‚           โ””โ”€โ”€ session_store.py
โ”‚   โ””โ”€โ”€ ๐Ÿ“ docker/
โ”‚       โ”œโ”€โ”€ Dockerfile.gateway
โ”‚       โ”œโ”€โ”€ docker-compose.dev.yml
โ”‚       โ””โ”€โ”€ env.example
โ”‚
โ”œโ”€โ”€ ๐Ÿ“ engine-plugins/
โ”‚   โ””โ”€โ”€ ๐Ÿ“ unreal/
โ”‚       โ””โ”€โ”€ ๐Ÿ“ VRSecretary/                  # Main Unreal plugin
โ”‚           โ”œโ”€โ”€ VRSecretary.uplugin
โ”‚           โ”œโ”€โ”€ README.md                    # Plugin documentation
โ”‚           โ”œโ”€โ”€ ๐Ÿ“ Source/VRSecretary/
โ”‚           โ”‚   โ”œโ”€โ”€ VRSecretary.Build.cs
โ”‚           โ”‚   โ”œโ”€โ”€ ๐Ÿ“ Public/
โ”‚           โ”‚   โ”‚   โ”œโ”€โ”€ VRSecretaryComponent.h       # Main component
โ”‚           โ”‚   โ”‚   โ”œโ”€โ”€ VRSecretarySettings.h        # Project settings
โ”‚           โ”‚   โ”‚   โ”œโ”€โ”€ VRSecretaryChatTypes.h       # Enums, structs
โ”‚           โ”‚   โ”‚   โ””โ”€โ”€ VRSecretaryLog.h
โ”‚           โ”‚   โ””โ”€โ”€ ๐Ÿ“ Private/
โ”‚           โ”‚       โ”œโ”€โ”€ VRSecretaryModule.cpp
โ”‚           โ”‚       โ”œโ”€โ”€ VRSecretaryComponent.cpp
โ”‚           โ”‚       โ”œโ”€โ”€ VRSecretarySettings.cpp
โ”‚           โ”‚       โ””โ”€โ”€ VRSecretaryLog.cpp
โ”‚           โ””โ”€โ”€ ๐Ÿ“ ThirdParty/
โ”‚               โ””โ”€โ”€ ๐Ÿ“ LlamaCpp/                     # Optional llama.cpp
โ”‚
โ”œโ”€โ”€ ๐Ÿ“ samples/
โ”‚   โ”œโ”€โ”€ ๐Ÿ“ unreal-vr-secretary-demo/        # Example UE5 project
โ”‚   โ”‚   โ”œโ”€โ”€ VRSecretaryDemo.uproject
โ”‚   โ”‚   โ”œโ”€โ”€ ๐Ÿ“ Config/
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ DefaultEngine.ini
โ”‚   โ”‚   โ””โ”€โ”€ ๐Ÿ“ Content/
โ”‚   โ”‚       โ”œโ”€โ”€ ๐Ÿ“ Blueprints/               # BP_VRPawn, BP_DesktopPlayer
โ”‚   โ”‚       โ”œโ”€โ”€ ๐Ÿ“ UI/                       # WBP_ChatInterface
โ”‚   โ”‚       โ”œโ”€โ”€ ๐Ÿ“ Characters/               # BP_SecretaryAvatar
โ”‚   โ”‚       โ””โ”€โ”€ ๐Ÿ“ Maps/                     # VRSecretaryLevel
โ”‚   โ””โ”€โ”€ ๐Ÿ“ backend-notebooks/
โ”‚       โ””โ”€โ”€ prototype-calls.ipynb
โ”‚
โ”œโ”€โ”€ ๐Ÿ“ docs/
โ”‚   โ”œโ”€โ”€ overview.md
โ”‚   โ”œโ”€โ”€ architecture.md
โ”‚   โ”œโ”€โ”€ unreal-integration.md                # Step-by-step UE setup
โ”‚   โ”œโ”€โ”€ engine-agnostic-api.md               # REST API reference
โ”‚   โ”œโ”€โ”€ persona-ailey.md                     # Customizing AI behavior
โ”‚   โ””โ”€โ”€ troubleshooting.md
โ”‚
โ”œโ”€โ”€ ๐Ÿ“ tools/
โ”‚   โ”œโ”€โ”€ ๐Ÿ“ scripts/
โ”‚   โ”‚   โ”œโ”€โ”€ start_local_stack.sh
โ”‚   โ”‚   โ””โ”€โ”€ generate_openapi_client.sh
โ”‚   โ”œโ”€โ”€ ๐Ÿ“ perf/
โ”‚   โ”‚   โ”œโ”€โ”€ load_test_vr_chat.k6.js         # k6 load tests
โ”‚   โ”‚   โ””โ”€โ”€ profiling_notes.md
โ”‚   โ””โ”€โ”€ vr_chatterbox_server.py              # Optimized TTS server
โ”‚
โ”œโ”€โ”€ ๐Ÿ“ .github/
โ”‚   โ”œโ”€โ”€ ๐Ÿ“ workflows/                        # CI/CD
โ”‚   โ”‚   โ”œโ”€โ”€ backend-tests.yml
โ”‚   โ”‚   โ””โ”€โ”€ unreal-build.yml
โ”‚   โ””โ”€โ”€ ๐Ÿ“ ISSUE_TEMPLATE/
โ”‚
โ”œโ”€โ”€ LICENSE                                  # Apache 2.0
โ”œโ”€โ”€ CODE_OF_CONDUCT.md
โ”œโ”€โ”€ CONTRIBUTING.md
โ””โ”€โ”€ README.md                                # This file

โš™๏ธ Backend Configuration

Environment Variables (.env)

Located at: backend/gateway/.env

Core Settings

# ===========================================
# CORE MODE
# ===========================================
# Options: offline_local_ollama | online_watsonx
MODE=offline_local_ollama

# ===========================================
# OLLAMA (Local LLM)
# ===========================================
OLLAMA_BASE_URL=http://localhost:11434
OLLAMA_MODEL=llama3
OLLAMA_TIMEOUT=60.0
OLLAMA_TEMPERATURE=0.7
OLLAMA_MAX_TOKENS=256

# ===========================================
# CHATTERBOX (TTS)
# ===========================================
CHATTERBOX_URL=http://localhost:4123
CHATTERBOX_TIMEOUT=30.0

# ===========================================
# WATSONX.AI (Cloud LLM - Optional)
# ===========================================
# Uncomment if MODE=online_watsonx
# WATSONX_URL=https://us-south.ml.cloud.ibm.com
# WATSONX_PROJECT_ID=your-project-id-here
# WATSONX_MODEL_ID=ibm/granite-13b-chat-v2
# WATSONX_API_KEY=your-api-key-here
# WATSONX_TIMEOUT=60.0
# WATSONX_TEMPERATURE=0.7
# WATSONX_MAX_TOKENS=256

# ===========================================
# SESSION MANAGEMENT
# ===========================================
SESSION_MAX_HISTORY=10                      # Max conversation turns to remember

# ===========================================
# LOGGING
# ===========================================
LOG_LEVEL=INFO                              # DEBUG | INFO | WARNING | ERROR

Backend Modes Explained

Mode 1: Gateway (Ollama) - Recommended for Development

Flow: UE5 โ†’ FastAPI โ†’ Ollama โ†’ TTS โ†’ UE5

Pros:

  • โœ… Full features (text + audio)
  • โœ… Easy to debug
  • โœ… Session history management
  • โœ… Flexible persona configuration

Cons:

  • โŒ Requires running 3 services
  • โŒ Not suitable for embedded deployment

Setup:

MODE=offline_local_ollama
OLLAMA_BASE_URL=http://localhost:11434
OLLAMA_MODEL=llama3
CHATTERBOX_URL=http://localhost:4123

Mode 2: Gateway (watsonx.ai) - Enterprise/Cloud

Flow: UE5 โ†’ FastAPI โ†’ watsonx.ai โ†’ TTS โ†’ UE5

Pros:

  • โœ… Cloud-based (no local GPU needed)
  • โœ… Enterprise-grade models
  • โœ… Full features (text + audio)
  • โœ… Scalable

Cons:

  • โŒ Requires API key & internet
  • โŒ Usage costs
  • โŒ Latency depends on connection

Setup:

MODE=online_watsonx
WATSONX_URL=https://us-south.ml.cloud.ibm.com
WATSONX_PROJECT_ID=your-project-id
WATSONX_MODEL_ID=ibm/granite-13b-chat-v2
WATSONX_API_KEY=your-api-key
CHATTERBOX_URL=http://localhost:4123

Mode 3: Direct Ollama - Simplified Integration

Flow: UE5 โ†’ Ollama (OpenAI-compatible API) โ†’ UE5

Pros:

  • โœ… Simplest setup (1 service)
  • โœ… OpenAI-compatible API
  • โœ… No gateway needed

Cons:

  • โŒ Text only (no audio)
  • โŒ No conversation history
  • โŒ No persona customization

UE Settings:

  • Backend Mode: DirectOllama
  • Direct Ollama URL: http://localhost:11434
  • Direct Ollama Model: llama3

Mode 4: Local Llama.cpp - Fully Offline

Flow: UE5 โ†’ In-Engine llama.cpp โ†’ UE5

Pros:

  • โœ… Completely offline
  • โœ… No external services
  • โœ… Embeddable
  • โœ… Low latency

Cons:

  • โŒ Text only (no audio by default)
  • โŒ Requires GGUF model files
  • โŒ More complex setup
  • โŒ GPU/CPU intensive

UE Settings:

  • Backend Mode: LocalLlamaCpp
  • Requires: Llama-Unreal plugin enabled
  • Requires: ULlamaComponent on same actor

๐ŸŽฎ Unreal Plugin Setup

Plugin Installation

Method 1: Use Sample Project (Recommended)

Already included in samples/unreal-vr-secretary-demo/Plugins/VRSecretary/

Method 2: Add to Your Project

# From VRSecretary repo root
mkdir -p /path/to/YourProject/Plugins
cp -r engine-plugins/unreal/VRSecretary /path/to/YourProject/Plugins/

Then:

  1. Right-click YourProject.uproject โ†’ Generate Visual Studio project files
  2. Open in Visual Studio
  3. Build Development Editor | Win64
  4. Open project in Unreal

Project Settings

Edit โ†’ Project Settings โ†’ Plugins โ†’ VRSecretary

Setting Description Example
Gateway URL FastAPI backend URL http://localhost:8000
HTTP Timeout Request timeout (seconds) 60.0
Backend Mode Which backend to use Gateway (Ollama)
Direct Ollama URL For DirectOllama mode http://localhost:11434
Direct Ollama Model Model name llama3
Language Code ISO 639-1 code (empty = English) en or empty

Blueprint Integration

1. Add Component to Actor

In your Player Pawn or VR Manager blueprint:

  1. Components panel โ†’ + Add Component
  2. Search: VRSecretary
  3. Add VRSecretaryComponent

2. Bind Events

Event Graph:

  1. Select VRSecretaryComponent
  2. Details โ†’ Events:
    • + On Assistant Response โ†’ Fires when AI replies
    • + On Error โ†’ Fires on failure

3. Send User Text

Create this logic:

[User Input Event]
    โ†“
[Make VRSecretaryChatConfig]
    - Temperature: 0.7
    - TopP: 0.9
    - MaxTokens: 256
    โ†“
[VRSecretaryComponent โ†’ Send User Text]
    - User Text: (from input)
    - Config: (from Make Config)

4. Handle Response

On Assistant Response:

[Event OnAssistantResponse]
    - AssistantText (String)
    - AudioWavBase64 (String)
    โ†“
[Update Subtitle Text] โ† Display above avatar
    โ†“
[Decode Base64 to Sound Wave]
    โ†“
[Play Audio at Character Position]

On Error:

[Event OnError]
    - ErrorMessage (String)
    โ†“
[Print String] โ† Show to user
    - Text: ErrorMessage
    - Color: Red

Advanced: Per-Component Mode Override

On VRSecretaryComponent:

  • โœ… Check: Override Backend Mode
  • Set: Backend Mode Override to desired mode

This overrides Project Settings for this specific component.


๐Ÿง  AI Persona: Ailey

Default Personality

Ailey is configured via the system prompt in:

backend/gateway/vrsecretary_gateway/api/vr_chat_router.py

Default traits:

  • Professional yet approachable - Executive assistant style
  • Concise - Optimized for spoken responses (60-120 words)
  • Proactive - Offers suggestions and next steps
  • VR-aware - References virtual office context
  • Organized - Good at structuring tasks and planning

Customizing Ailey

Edit the SYSTEM_PROMPT constant:

SYSTEM_PROMPT = """You are Ailey, a highly capable virtual secretary in a VR environment.

Your role:
- Assist the user with tasks, scheduling, and information
- Be professional yet warm and personable
- Keep responses concise (ideal: 2-3 sentences, max 120 words)
- Offer proactive suggestions when appropriate
- Reference the virtual office environment naturally

Tone: Friendly, efficient, and supportive.
"""

Persona Variants

See docs/persona-ailey.md for pre-made variants:

Variant Use Case Tone
Default General assistant Balanced, professional
Formal Executive meetings Corporate, reserved
Casual Creative work Relaxed, friendly
Technical Dev/engineering Precise, detail-oriented
Coach Productivity/wellness Motivational, supportive
Tutor Learning/teaching Patient, explanatory

Multi-Language Support

Set in plugin settings:

  • Language Code: es (Spanish), fr (French), de (German), etc.

Modify system prompt to match:

SYSTEM_PROMPT_ES = """Eres Ailey, una secretaria virtual altamente capaz..."""

๐ŸŽญ Avatar Assets

Included Avatar: Scifi Girl v.01

Location: assets/avatars/scifi_girl_v01/scifi_girl_v.01.glb

Details:

โš ๏ธ Important License Notes

You CANNOT use Scifi Girl v.01 in commercial products!

For commercial use, you must:

  1. Replace with a commercial-licensed avatar:

    • Unreal Marketplace
    • Sketchfab (commercial license)
    • Custom-commissioned model
    • CC0 / Public Domain assets
  2. Obtain permission from original creator (patrix)

  3. Remove the sample avatar entirely

Using Custom Avatars

Requirements

Your avatar should have:

  • โœ… Skeletal mesh with humanoid rig
  • โœ… Materials/textures
  • โœ… LODs (optional but recommended for VR)
  • โœ… Compatible with UE5 skeleton

Import Process

  1. Import to Unreal:

    • Drag FBX/GLB into Content Browser
    • Set import options (skeletal mesh, materials, textures)
  2. Setup in BP_SecretaryAvatar:

    • Open blueprint
    • Select Mesh component
    • Change Skeletal Mesh to your imported asset
  3. Adjust components:

    • VoiceAudio location (head height)
    • SubtitleText location (above head)
  4. Test in editor:

    • Play โ†’ VR Preview
    • Verify positioning and scale

๐Ÿ› ๏ธ Development & Testing

Running Tests

Backend Unit Tests

cd backend/gateway
pytest

# With coverage
pytest --cov=vrsecretary_gateway --cov-report=html

# View coverage report
open htmlcov/index.html  # macOS/Linux
start htmlcov/index.html  # Windows

Load Testing

Requires k6:

cd tools/perf
k6 run load_test_vr_chat.k6.js

# With custom config
k6 run --vus 10 --duration 30s load_test_vr_chat.k6.js

Metrics to watch:

  • http_req_duration (p95 < 2s for good UX)
  • http_req_failed (should be 0%)
  • Concurrent users vs throughput

Docker Development

Build and Run

cd backend/docker
docker-compose -f docker-compose.dev.yml up --build

Services started:

  • Ollama โ†’ http://localhost:11434
  • Gateway โ†’ http://localhost:8000

Note: Chatterbox typically runs on host for GPU access.

Stopping

docker-compose -f docker-compose.dev.yml down

Code Quality

Python (Backend)

# Format code
black backend/gateway/

# Lint
flake8 backend/gateway/

# Type checking
mypy backend/gateway/

C++ (Unreal Plugin)

Follow Unreal Engine coding standards:

  • Naming: PascalCase for classes, bCamelCase for bools
  • Headers: Minimal includes, forward declarations
  • Blueprint Exposure: Use UPROPERTY and UFUNCTION macros

Debugging

Backend Logs

# Set debug level in .env
LOG_LEVEL=DEBUG

# Run gateway with verbose output
uvicorn vrsecretary_gateway.main:app --log-level debug

Unreal Logs

Output Log (Window โ†’ Developer Tools โ†’ Output Log):

  • Filter: LogVRSecretary
  • Shows HTTP requests, responses, errors

Blueprint Debugging:

  • Add Print String nodes
  • Use Breakpoints in Blueprint graph

๐Ÿ—๏ธ Architecture Overview

High-Level Flow

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚   Player    โ”‚
โ”‚  (VR/Desktop)โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”˜
       โ”‚ Speaks/Types
       โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  VRSecretaryComponent (C++/Blueprint)   โ”‚
โ”‚  - Accepts user text                    โ”‚
โ”‚  - Routes to backend based on mode      โ”‚
โ”‚  - Fires events with response           โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
       โ”‚                         โ”‚
       โ”‚ Gateway Mode            โ”‚ Direct/Local Mode
       โ–ผ                         โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”          โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  FastAPI    โ”‚          โ”‚   Ollama     โ”‚
โ”‚  Gateway    โ”‚          โ”‚   Direct     โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”˜          โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
       โ”‚                        โ”‚
       โ–ผ                        โ”‚
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”                 โ”‚
โ”‚   Ollama    โ”‚โ—„โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
โ”‚  or watsonx โ”‚
โ”‚    (LLM)    โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”˜
       โ”‚ Response Text
       โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ Chatterbox  โ”‚
โ”‚    (TTS)    โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”˜
       โ”‚ WAV Audio
       โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  VRSecretaryComponentโ”‚
โ”‚  - Decodes base64    โ”‚
โ”‚  - Plays sound wave  โ”‚
โ”‚  - Updates subtitle  โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Key Components

1. VRSecretaryComponent (C++)

Responsibilities:

  • Expose Blueprint-friendly API
  • HTTP request handling (via FHttpModule)
  • Backend mode routing
  • Event broadcasting
  • Error handling

Public API:

// Send user input to AI
UFUNCTION(BlueprintCallable)
void SendUserText(const FString& UserText, const FVRSecretaryChatConfig& Config);

// Delegates (events)
UPROPERTY(BlueprintAssignable)
FOnAssistantResponse OnAssistantResponse;

UPROPERTY(BlueprintAssignable)
FOnError OnError;

2. FastAPI Gateway

Endpoints:

  • GET /health - Health check
  • POST /api/vr_chat - Main chat endpoint

Request Schema:

{
  "session_id": "string",
  "user_text": "string",
  "language": "string (optional)",
  "temperature": 0.7,
  "top_p": 0.9,
  "max_tokens": 256
}

Response Schema:

{
  "assistant_text": "string",
  "audio_wav_base64": "string (optional)"
}

3. LLM Clients

Base Interface:

class BaseLLMClient(ABC):
    @abstractmethod
    async def generate(
        self,
        messages: List[Dict[str, str]],
        temperature: float,
        max_tokens: int
    ) -> str:
        pass

Implementations:

  • OllamaClient - Local Ollama
  • WatsonxClient - IBM watsonx.ai

4. TTS Server

Endpoints:

  • POST /v1/audio/speech - Non-streaming TTS
  • POST /v1/audio/speech/stream - Streaming TTS

Features:

  • Sentence-aware chunking
  • GPU acceleration
  • Configurable voice parameters
  • EOS-safe generation

Data Flow Examples

Example 1: Gateway Mode (Full)

  1. User presses trigger in VR
  2. VR keyboard input โ†’ "Schedule a meeting"
  3. VRSecretaryComponent.SendUserText() called
  4. HTTP POST to http://localhost:8000/api/vr_chat
  5. Gateway assembles conversation history
  6. Gateway calls Ollama: "You are Ailey..." + history + user text
  7. Ollama responds: "I'd be happy to help schedule that..."
  8. Gateway sends response to Chatterbox
  9. Chatterbox generates WAV audio
  10. Gateway returns: { assistant_text, audio_wav_base64 }
  11. Component fires OnAssistantResponse event
  12. Blueprint logic:
    • Updates subtitle (TextRender component)
    • Decodes base64 to USoundWave
    • Plays audio at character location

Example 2: Direct Ollama Mode (Text Only)

  1. User types: "Hello"
  2. VRSecretaryComponent.SendUserText() called
  3. HTTP POST to http://localhost:11434/v1/chat/completions (OpenAI-style)
  4. Ollama responds with text only
  5. Component fires OnAssistantResponse with empty audio
  6. Blueprint displays text only (no audio playback)

๐Ÿ”ง Troubleshooting

Common Issues

1. "Failed to connect to backend"

Symptoms:

  • Red error in Unreal Output Log
  • OnError event fires
  • No response from AI

Solutions:

โœ… Check backend is running:

curl http://localhost:8000/health

โœ… Check Gateway URL in Project Settings:

  • Should be http://localhost:8000 (no trailing slash)

โœ… Check firewall:

  • Windows: Allow Python through firewall
  • Antivirus: Whitelist backend ports (8000, 11434, 4123)

โœ… Check Output Log:

  • Filter: LogVRSecretary
  • Look for HTTP error codes (404, 500, etc.)

2. "No audio in response"

Symptoms:

  • Text response works
  • audio_wav_base64 is null or empty

Solutions:

โœ… Verify Chatterbox is running:

curl http://localhost:4123/health

โœ… Check backend logs:

  • Look for TTS errors
  • Verify CHATTERBOX_URL in .env

โœ… Test TTS directly:

curl -X POST http://localhost:4123/v1/audio/speech \
  -H "Content-Type: application/json" \
  -d '{"input": "Test", "voice": "female"}' \
  --output test.wav

โœ… Check GPU/CUDA:

  • Chatterbox needs GPU for real-time TTS
  • CPU fallback is very slow

3. "Ollama model not found"

Symptoms:

  • Backend error: "Model llama3 not found"

Solutions:

โœ… Download model:

ollama pull llama3

โœ… List available models:

ollama list

โœ… Update .env:

  • Set OLLAMA_MODEL to exact model name

4. "Compile errors in Unreal"

Symptoms:

  • "Cannot find VRSecretaryComponent.h"
  • Build fails in Visual Studio

Solutions:

โœ… Regenerate project files:

  • Right-click .uproject โ†’ Generate Visual Studio project files

โœ… Check plugin is enabled:

  • Edit โ†’ Plugins โ†’ VRSecretary โ†’ โœ… Enabled

โœ… Clean build:

  • Visual Studio: Build โ†’ Clean Solution
  • Then: Build โ†’ Build Solution

โœ… Verify Unreal version:

  • Project requires UE 5.3 or later

5. "Slow response times"

Symptoms:

  • 10+ second delay
  • Audio takes minutes to generate

Solutions:

โœ… Use GPU acceleration:

  • Ollama: Ensure CUDA is installed
  • Chatterbox: Set CHATTERBOX_DEVICE=cuda

โœ… Use smaller models:

  • llama3:8b instead of llama3:70b

โœ… Reduce max_tokens:

  • Lower to 128 or 200 for faster responses

โœ… Check system resources:

  • Monitor GPU/CPU usage
  • Close other GPU-intensive apps

6. "Avatar not visible in VR"

Symptoms:

  • Chat works but no character
  • Empty space where avatar should be

Solutions:

โœ… Check BP_SecretaryAvatar:

  • Mesh component has valid skeletal mesh assigned

โœ… Check transform/scale:

  • Position: visible in VR space
  • Scale: 1.0 (or appropriate size)

โœ… Check collision:

  • Collision preset allows visibility

โœ… Check layer:

  • Not hidden by visibility settings

Performance Optimization

Backend

Slow LLM responses:

  • Use quantized models (Q4, Q5 instead of FP16)
  • Enable GPU inference
  • Reduce max_tokens

High memory usage:

  • Limit SESSION_MAX_HISTORY
  • Use smaller context window
  • Consider model with smaller params

Unreal

Low FPS in VR:

  • Reduce avatar poly count (use LODs)
  • Optimize materials (use simple shaders)
  • Disable unnecessary features (dynamic shadows)

Audio stuttering:

  • Increase audio buffer size
  • Pre-cache common responses
  • Use audio compression

๐Ÿ“š Documentation

Full Documentation

Document Description
Architecture Detailed system design, data flows
Unreal Integration Step-by-step plugin setup guide
Engine-Agnostic API REST API reference for any engine
Persona: Ailey Customizing AI personality
Troubleshooting Extended problem-solving guide

Quick Links

  • Backend README: backend/gateway/README.md
  • Plugin README: engine-plugins/unreal/VRSecretary/README.md
  • Sample Project: samples/unreal-vr-secretary-demo/README.md

๐Ÿค Contributing

We welcome contributions of all kinds!

Ways to Contribute

  • ๐Ÿ› Report bugs via GitHub Issues
  • ๐Ÿ’ก Suggest features or improvements
  • ๐Ÿ“– Improve documentation
  • ๐Ÿงช Add tests
  • ๐ŸŽจ Create new avatar assets (with compatible licenses)
  • ๐Ÿ”Œ Implement new LLM/TTS backends
  • ๐ŸŽฎ Create Unity/Godot clients

Development Workflow

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/amazing-feature
  3. Commit your changes: git commit -m 'Add amazing feature'
  4. Push to branch: git push origin feature/amazing-feature
  5. Open a Pull Request

Guidelines

Code Style

Python:

C++:

Blueprints:

  • Use clear node naming
  • Add comment blocks
  • Keep graphs organized (left โ†’ right flow)

๐Ÿ“„ License

Code License

Apache License 2.0

  • โœ… Commercial use allowed
  • โœ… Modification allowed
  • โœ… Distribution allowed
  • โœ… Patent use allowed
  • โš ๏ธ Requires: Attribution, License notice, State changes
  • โš ๏ธ Does NOT grant: Trademark rights, Liability protection

See LICENSE for full text.

Asset License (Scifi Girl v.01 Avatar)

Creative Commons Attribution-NonCommercial-ShareAlike 4.0

  • โœ… Non-commercial use only
  • โœ… Adaptation allowed (with same license)
  • โš ๏ธ Requires: Attribution to original creator
  • โŒ Commercial use prohibited without permission

Original Creator: patrix on Sketchfab

Important: Code and assets have separate licenses. For commercial projects, you must replace non-commercial assets.


๐Ÿ™ Acknowledgments

Technologies

Assets

  • Scifi Girl v.01 by patrix - Used under CC BY-NC-SA 4.0

Community

  • Thanks to all contributors and testers
  • Special thanks to the Unreal Engine VR community
  • Thanks to the open-source AI/ML community

๐Ÿ“ž Support & Contact

Getting Help

  1. Documentation: Check docs/ folder
  2. Issues: GitHub Issues
  3. Discussions: GitHub Discussions

Reporting Issues

When reporting bugs, include:

  • OS and versions (Windows/Linux, Unreal version, Python version)
  • Backend configuration (.env settings, no API keys!)
  • Unreal project settings (Backend Mode, Gateway URL)
  • Steps to reproduce
  • Expected vs actual behavior
  • Relevant logs (VRSecretary, HTTP responses)

Feature Requests

For feature requests:

  • Describe the use case
  • Explain why it would be valuable
  • Provide mockups/examples if applicable
  • Tag with enhancement label

๐Ÿ—บ๏ธ Roadmap

Version 1.0 (Current)

  • Core VRSecretary plugin (C++)
  • FastAPI gateway backend
  • Ollama integration
  • watsonx.ai integration
  • Chatterbox TTS integration
  • Sample VR project
  • Documentation
  • Load testing tools

Version 1.1 (Planned)

  • Unity client implementation
  • Improved voice activity detection
  • Multi-language UI
  • RAG (document chat) support
  • Gesture recognition
  • Mobile VR optimization (Quest standalone)

Version 2.0 (Future)

  • Multi-character conversations
  • Emotion/sentiment analysis
  • Lip-sync animation
  • Voice cloning support
  • Cloud deployment templates (AWS, Azure, GCP)
  • Multiplayer/social features

๐ŸŒŸ Show Your Support

If you find VRSecretary useful:

  • โญ Star this repository
  • ๐Ÿ› Report bugs to help improve it
  • ๐Ÿ“ข Share with your network
  • ๐Ÿค Contribute code or documentation
  • ๐Ÿ’ฌ Join discussions and provide feedback

Built with โค๏ธ for the VR and AI communities

โฌ† Back to Top

About

VRSecretary is a production-ready reference implementation for building AI-powered assistants in virtual reality. It combines Unreal Engine 5 (VR), a FastAPI backend, local/cloud LLM backends (Ollama, IBM watsonx.ai), and Chatterbox TTS to drive an interactive VR secretary avatar. The project includes an Unreal plugin, a sample VR demo level

Topics

Resources

License

Code of conduct

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published