# LiveKit Installation Guide for Windows

## Required Software

- Git
- Python (version 3.11.9 recommended)
- Poetry (Python package manager)
- LiveKit server for Windows
- FFmpeg

## Installation Steps

### 1. Python Installation

Install Python 3.11.9 (latest version < 3.12) using the binary installer.

### 2. Poetry Installation

Poetry installation on Windows can be challenging. If you encounter SSL certificate verification issues, try this workaround:

1. Download the installation script from [https://install.python-poetry.org/](https://install.python-poetry.org/) and save it as `install-poetry.py`.
2. Modify the `get(self, url):` method in the script to disable certificate verification:

   ```python
   def get(self, url):
       import ssl
       import certifi
       request = Request(url)
       context = ssl.create_default_context(cafile=certifi.where())
       context.check_hostname = False
       context.verify_mode = ssl.CERT_NONE
       with closing(urlopen(request, context=context)) as r:
           return r.read()
   ```

3. Run the modified script to install Poetry.
4. Add Poetry's bin directory to your PATH:
   - Path: `C:\Users\[USERNAME]\AppData\Roaming\Python\Scripts`
   - Follow the guide at: [https://www.java.com/en/download/help/path.html](https://www.java.com/en/download/help/path.html)

### 3. LiveKit Server Installation

1. Download the latest release of LiveKit server for Windows (e.g., `livekit_1.7.2_windows_amd64.zip`).
2. Extract the `livekit-server.exe` file to your `/software` directory.

### 4. FFmpeg Installation

1. Download the FFmpeg Windows build from: [https://github.com/BtbN/FFmpeg-Builds/releases](https://github.com/BtbN/FFmpeg-Builds/releases)
   - Choose the `ffmpeg-master-latest-win64-gpl.zip` (non-shared suffix) version.
2. Extract the compressed zip and add the FFmpeg bin directory to your PATH.

### 5. Final Setup

1. Run `poetry install`. If you encounter an error about Microsoft Visual C++, install "Microsoft C++ Build Tools":
   - Download from: [https://visualstudio.microsoft.com/visual-cpp-build-tools/](https://visualstudio.microsoft.com/visual-cpp-build-tools/)
   - In the installation popup, select "Desktop Development with C++" with preselected components.

2. Set up your Anthropic API key:
   ```
   setx ANTHROPIC_API_KEY [your_api_key]
   ```

3. Modify `main.py` to correctly locate and run the LiveKit server:
   - Set the LiveKit path:
     ```python
     livekit_path = "path/to/your/01/software/livekit-server"
     ```
   - Modify the server command for Windows:
     ```python
     f"{livekit_path} --dev --bind {server_host} --port {server_port}"
     ```
   > Note: Remove the `> /dev/null 2>&1` section from the command as it's not compatible with Windows.

## Troubleshooting

- If you encounter "ffmpeg not found" errors or issues when sending messages, ensure FFmpeg is correctly installed and added to your PATH.
- For any SSL certificate issues during installation, refer to the Poetry installation workaround provided above.