├── README.md ├── api.py ├── main.py ├── requirements.txt └── sample.env /README.md: -------------------------------------------------------------------------------- 1 | # LiveKit-AI-Voice-Assitant 2 | 3 | # 💻 Launch Your Software Development Career Today! 4 | 5 | 🎓 **No degree? No problem!** My program equips you with everything you need to break into tech and land an entry-level software development role. 6 | 7 | 🚀 **Why Join?** 8 | - 💼 **$70k+ starting salary potential** 9 | - 🕐 **Self-paced:** Complete on your own time 10 | - 🤑 **Affordable:** Low risk compared to expensive bootcamps or degrees 11 | - 🎯 **45,000+ job openings** in the market 12 | 13 | 👉 **[Start your journey today!](https://techwithtim.net/dev)** 14 | No experience needed—just your determination. Future-proof your career and unlock six-figure potential like many of our students have! 15 | -------------------------------------------------------------------------------- /api.py: -------------------------------------------------------------------------------- 1 | import enum 2 | from typing import Annotated 3 | from livekit.agents import llm 4 | import logging 5 | 6 | logger = logging.getLogger("temperature-control") 7 | logger.setLevel(logging.INFO) 8 | 9 | 10 | class Zone(enum.Enum): 11 | LIVING_ROOM = "living_room" 12 | BEDROOM = "bedroom" 13 | KITCHEN = "kitchen" 14 | BATHROOM = "bathroom" 15 | OFFICE = "office" 16 | 17 | 18 | class AssistantFnc(llm.FunctionContext): 19 | def __init__(self) -> None: 20 | super().__init__() 21 | 22 | self._temperature = { 23 | Zone.LIVING_ROOM: 22, 24 | Zone.BEDROOM: 20, 25 | Zone.KITCHEN: 24, 26 | Zone.BATHROOM: 23, 27 | Zone.OFFICE: 21, 28 | } 29 | 30 | @llm.ai_callable(description="get the temperature in a specific room") 31 | def get_temperature( 32 | self, zone: Annotated[Zone, llm.TypeInfo(description="The specific zone")] 33 | ): 34 | logger.info("get temp - zone %s", zone) 35 | temp = self._temperature[Zone(zone)] 36 | return f"The temperature in the {zone} is {temp}C" 37 | 38 | @llm.ai_callable(description="set the temperature in a specific room") 39 | def set_temperature( 40 | self, 41 | zone: Annotated[Zone, llm.TypeInfo(description="The specific zone")], 42 | temp: Annotated[int, llm.TypeInfo(description="The temperature to set")], 43 | ): 44 | logger.info("set temo - zone %s, temp: %s", zone, temp) 45 | self._temperature[Zone(zone)] = temp 46 | return f"The temperature in the {zone} is now {temp}C" 47 | -------------------------------------------------------------------------------- /main.py: -------------------------------------------------------------------------------- 1 | import asyncio 2 | 3 | from dotenv import load_dotenv 4 | from livekit.agents import AutoSubscribe, JobContext, WorkerOptions, cli, llm 5 | from livekit.agents.voice_assistant import VoiceAssistant 6 | from livekit.plugins import openai, silero 7 | from api import AssistantFnc 8 | 9 | load_dotenv() 10 | 11 | 12 | async def entrypoint(ctx: JobContext): 13 | initial_ctx = llm.ChatContext().append( 14 | role="system", 15 | text=( 16 | "You are a voice assistant created by LiveKit. Your interface with users will be voice. " 17 | "You should use short and concise responses, and avoiding usage of unpronouncable punctuation." 18 | ), 19 | ) 20 | await ctx.connect(auto_subscribe=AutoSubscribe.AUDIO_ONLY) 21 | fnc_ctx = AssistantFnc() 22 | 23 | assitant = VoiceAssistant( 24 | vad=silero.VAD.load(), 25 | stt=openai.STT(), 26 | llm=openai.LLM(), 27 | tts=openai.TTS(), 28 | chat_ctx=initial_ctx, 29 | fnc_ctx=fnc_ctx, 30 | ) 31 | assitant.start(ctx.room) 32 | 33 | await asyncio.sleep(1) 34 | await assitant.say("Hey, how can I help you today!", allow_interruptions=True) 35 | 36 | 37 | if __name__ == "__main__": 38 | cli.run_app(WorkerOptions(entrypoint_fnc=entrypoint)) 39 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | livekit-agents>=0.8.7 2 | livekit-plugins-openai>=0.8.1 3 | livekit-plugins-silero>=0.6.4 4 | python-dotenv~=1.0 -------------------------------------------------------------------------------- /sample.env: -------------------------------------------------------------------------------- 1 | LIVEKIT_URL="" 2 | LIVEKIT_API_SECRET="" 3 | LIVEKIT_API_KEY="" 4 | OPENAI_API_KEY="" --------------------------------------------------------------------------------