Get your voice agent up and running in just a few simple steps. This guide will help you build a voice assistant that teaches Pakistan history in Urdu.

Complete Demo Code

Get all files from GitHub

Quick Download

git clone https://github.com/uplift-initiative/livekit-demo
cd livekit-demo

Prerequisites

Step 1: Install Everything

Run this single command to install all dependencies:
pip install livekit-agents==1.2.5 livekit==1.0.12 livekit-plugins-openai==1.2.5 livekit-plugins-noise-cancellation==0.2.5 livekit-plugins-turn-detector==1.2.5 python-socketio[asyncio]>=5.11.0 aiohttp>=3.9.0 python-dotenv>=1.0.0 loguru>=0.7.0 openai>=1.84.0

Step 2: Set Up Environment Variables

Create a .env file in your project folder:
OPENAI_API_KEY=your_openai_api_key_here
UPLIFTAI_API_KEY=your_uplift_api_key_here
Replace your_openai_api_key_here and your_uplift_api_key_here with your actual API keys.

Step 3: Create the Uplift TTS Plugin

You have two options:
# For Mac/Linux:
curl -O https://raw.githubusercontent.com/uplift-initiative/livekit-demo/main/uplift_tts.py

# For Windows (PowerShell):
Invoke-WebRequest -Uri https://raw.githubusercontent.com/uplift-initiative/livekit-demo/main/uplift_tts.py -OutFile uplift_tts.py

Option B: Copy and Paste

Step 4: Create Your Voice Agent

Create a file named agent.py with this code:
from dotenv import load_dotenv
load_dotenv()

from livekit import agents
from livekit.agents import AgentSession, Agent, RoomInputOptions
from livekit.plugins import openai, silero
from livekit.plugins.turn_detector.multilingual import MultilingualModel

# Import the Uplift TTS plugin
from uplift_tts import TTS

class PakistanHistoryAssistant(Agent):
    def __init__(self) -> None:
        super().__init__(instructions="""
# Pakistan History Voice Assistant

## Core Identity
You are a knowledgeable Pakistani history teacher who speaks in conversational Urdu. 
You help people learn about Pakistan's rich history - from the Indus Valley Civilization to modern times.

## Language Rules
- Use Pakistani Urdu only (proper Urdu script, no Roman Urdu)
- Female perspective (میں بتاتی ہوں، سناتی ہوں، میری رائے میں)
- Simple, conversational language that anyone can understand
- Avoid English except for widely known terms (British Raj, Congress, Muslim League)

## Topics You Can Discuss
- Ancient civilizations (Indus Valley, Gandhara)
- Mughal Empire and its legacy
- British colonial period
- Pakistan Movement and creation (1947)
- Key figures like Quaid-e-Azam, Allama Iqbal
- Modern Pakistan's development

## Response Style
- Tell history like stories, not dry facts
- Keep responses concise (2-3 sentences unless asked for detail)
- Use vivid descriptions to make history come alive
- Be balanced and factual about sensitive topics
- Write as continuous oral narration - no symbols or bullet points
- For dates: "انیس سو سینتالیس" not "1947"
""")

async def entrypoint(ctx: agents.JobContext):
    # Initialize TTS with Urdu voice
    tts = TTS(
        voice_id="v_meklc281",  # Urdu female voice
        output_format="MP3_22050_32",
    )
    
    # Create agent session
    session = AgentSession(
        stt=openai.STT(model="gpt-4o-transcribe", language="ur"),
        llm=openai.LLM(model="gpt-4o-mini"),
        tts=tts,
        vad=silero.VAD.load(),
        turn_detection=MultilingualModel(),
    )

    # Start the session
    await session.start(
        room=ctx.room,
        agent=PakistanHistoryAssistant(),
    )

    # Greet the user
    await session.generate_reply(
        instructions="Greet the user warmly in Urdu and offer to teach them about Pakistan's history."
    )

if __name__ == "__main__":
    agents.cli.run_app(agents.WorkerOptions(
        entrypoint_fnc=entrypoint,
        initialize_process_timeout=60,
    ))

Step 5: Verify Your Setup

Before proceeding, make sure your project directory looks like this:
your-project-folder/
├── .env                 # Your API keys
├── agent.py             # The voice agent code
└── uplift_tts.py        # The Uplift TTS plugin
All three files should be in the same folder!

Step 6: Download Required Files

Run this command to download necessary model files:
python agent.py download-files

Step 7: Run Your Agent!

You have two ways to test your agent:

Option A: Console Mode (Talk Directly)

python agent.py console
This lets you talk to your agent directly in the terminal!

Option B: Web Interface

python agent.py dev
Then open your browser to the URL shown in the terminal.
For the web interface, you’ll need LiveKit credentials. You can get free test credentials at livekit.io.

That’s It!

Your Pakistan History voice assistant is now running! Try asking questions like:
  • “قائد اعظم کے بارے میں بتائیں”
  • “پاکستان کب بنا تھا؟”
  • “موہنجو داڑو کیا ہے؟“

Additional Resources

Troubleshooting


Get Complete Demo

View the full working example with all files on GitHub