A conversational voice companion bot framework for Python. Plug in any LLM and voice tools to create your own assistant.
Project description
Voice Agent Core
A flexible, conversational voice companion bot framework for Python. Easily build your own AI assistant by plugging in any LLM (OpenAI, Gemini, etc.) and using built-in voice tools. Great for personal productivity, home automation, or just having a friendly AI to talk to!
Features
- Conversational AI: Integrate any LLM (OpenAI, Gemini, etc.) for smart, natural conversations.
- Speech Recognition: Uses Whisper and SpeechRecognition for accurate voice input.
- Text-to-Speech: Responds with high-quality voice using TTS APIs and local fallback.
- Extensible Tools: Add your own Python functions as tools (play music, check weather, control apps, etc.).
- Easy API: Just provide an LLM handler and start your bot!
Requirements
- Python 3.8+
- System dependencies for audio:
- Linux:
sudo apt-get install portaudio19-dev ffmpeg - macOS:
brew install portaudio ffmpeg - Windows: Install FFmpeg and ensure it's in your PATH.
- Linux:
Installation
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
pip install voice-agent-core
Quick Start: Your Own Companion Bot
Create a Python file (e.g., my_bot.py):
from voice_agent_core import VoiceCompanionBot
import datetime
def my_llm_handler(text):
if "date" in text or "time" in text:
now = datetime.datetime.now()
return {"type": "text_response", "content": f"The current date and time is: {now}"}
else:
return {"type": "text_response", "content": "I am your companion bot! You said: " + text}
bot = VoiceCompanionBot(llm_handler=my_llm_handler)
bot.listen_and_respond()
Run it:
python my_bot.py
Speak to your bot! It will respond with the date/time or echo your message.
Advanced: Use Any LLM (OpenAI Example)
from voice_agent_core import VoiceCompanionBot
import openai
def openai_llm_handler(text):
response = openai.ChatCompletion.create(
model="gpt-4",
messages=[{"role": "system", "content": "You are a helpful, friendly voice companion."},
{"role": "user", "content": text}]
)
return {"type": "text_response", "content": response.choices[0].message['content']}
bot = VoiceCompanionBot(llm_handler=openai_llm_handler)
bot.listen_and_respond()
Adding Custom Tools
You can add your own Python functions as tools. For example:
def get_weather(location):
# Your weather API logic here
return f"Weather in {location}: Sunny!"
tools = {"get_weather": get_weather}
bot = VoiceCompanionBot(llm_handler=my_llm_handler, tools=tools)
Your LLM handler should return:
{"type": "function_call", "call": {"name": "get_weather", "args": {"location": "London"}}}
The bot will call your tool and speak the result.
API Overview
VoiceCompanionBot(llm_handler, tools=None, speak_func=None, listen_func=None)llm_handler(text): function that takes user speech and returns a dict:{ "type": "function_call", "call": {"name": ..., "args": {...}} }{ "type": "text_response", "content": ... }
tools: dict of tool name to function (optional)speak_func: custom TTS function (optional)listen_func: custom speech recognition function (optional)
bot.listen_and_respond(): starts the main loop
License
MIT
For more details, see the API reference and examples above. Enjoy building your own AI companion!
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file voice_agent_core-1.2.2.tar.gz.
File metadata
- Download URL: voice_agent_core-1.2.2.tar.gz
- Upload date:
- Size: 10.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5a1d72d02f0ea48acd39e4be30325e8855d6d841c718e8e0c0877faafbc38fcf
|
|
| MD5 |
1476de739099c7d7bea135eeac88608e
|
|
| BLAKE2b-256 |
d951ea72e7c53541fdc7aa20099245c7bed78ecd967f54aeb5c5abf81afd8ae1
|
File details
Details for the file voice_agent_core-1.2.2-py3-none-any.whl.
File metadata
- Download URL: voice_agent_core-1.2.2-py3-none-any.whl
- Upload date:
- Size: 10.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
862042a56e4e3db75933442d81d3c16de2584444f4ae8789832ca569bfea8b19
|
|
| MD5 |
a2f0d3edf6d05407b043482764e921d1
|
|
| BLAKE2b-256 |
c5004d0feebbd2e4d3f80ef916f406fe8c9bbbdd235f760391e243035a7788f6
|