voicematic
A phone voice agent, assembled from independent parts: a telephony transport brings the call in (Genesys Cloud AudioHook out of the box), a voice engine hears and speaks, a brain with tools does the thinking, and call control hands the call back to the platform for a transfer. Each AI role picks its vendor: OpenAI, Anthropic and Mistral are built in, and any vendor that speaks the OpenAI or Anthropic protocol, or has a LangChain integration, is configuration.
pip install "voicematic[openai]" # or [anthropic], [mistral], [langchain], [settings], [mcp], [genesys], [testing], [all]
The core is standard library only. Each vendor's SDK is an extra and loads only when that provider is used.
from fastapi import FastAPI, WebSocket
from voicematic import DUTCH, AgentProfile, VoiceAgent
from voicematic.telephony import StarletteWebSocket
from voicematic.telephony.genesys import AudioHookTransport
from voicematic.voice import EchoEngine
agent = VoiceAgent(
AgentProfile(
name="Voorbeeld",
persona="Je bent de telefonische assistent van Voorbeeld BV.",
instructions="Beantwoord vragen kort en eerlijk.",
greeting="Goedendag, waarmee kan ik u helpen?",
language=DUTCH,
),
engine=EchoEngine,
)
app = FastAPI()
@app.websocket("/audiohook")
async def audiohook(ws: WebSocket) -> None:
await ws.accept()
await agent.handle(AudioHookTransport(StarletteWebSocket(ws), languages=[agent.profile.language.tag]))
EchoEngine needs no model: two tones, then the caller's own audio back. Swap
it for a speech-to-speech engine (voicematic.providers.openai.GPTLiveEngine)
or a PipelineEngine of ears, brain and mouth from any vendor.
Swappable components
Every part is an interface with built-in implementations. Your own subclass, or an adapter around a system you already have, slots in the same way:
| Part | Interface | Built in | Bring your own |
|---|---|---|---|
| Telephony | TransportABC, CallControlABC |
Genesys AudioHook, Architect flow and Platform API transfers | subclass |
| Voice engine | VoiceEngineABC |
PipelineEngine, GPT-Live, gpt-realtime, EchoEngine |
subclass, or adapters.voicebot for an existing voice bot |
| Turn detection | TurnDetectorABC |
EnergyTurnDetector |
subclass (a VAD, a semantic end-of-turn model) |
| Brain | ReasonerABC |
ToolLoopReasoner, CallableReasoner |
subclass, an async function, or adapters.langchain for an existing agent |
| Chat model | ChatModelABC |
OpenAI, OpenAI-compatible, Anthropic, Mistral; LangChain as the fallback for any other vendor | subclass, or adapters.langchain for any LangChain model |
| Ears, mouth | SpeechToTextABC, TextToSpeechABC |
OpenAI, Mistral | subclass |
| Tools | Tool, ToolRegistry |
MCP, the transfer tool | a Tool, or LangChain tools via from_langchain_tools |
| Prompts | PromptsABC |
DefaultPrompts |
subclass |
A LangChain agent you already have, with its own tools and memory, as the brain:
from langgraph.prebuilt import create_react_agent
from voicematic import VoiceAgent
from voicematic.adapters.langchain import LangChainAgentReasoner
brain = LangChainAgentReasoner(
# Called once per call with that call's tools, the transfer tool included.
lambda tools: create_react_agent(model, [*my_tools, *tools], checkpointer=memory),
history="latest", # the agent remembers the call itself, keyed by the call id
stream=True, # speak sentence by sentence as the agent writes
)
agent = VoiceAgent.pipeline(profile, stt=ears, brain=brain, tts=mouth)
Just a LangChain model, with voicematic's prompt, tools and tool loop:
brain=LangChainChatModel(ChatAnthropic(...)).
A voice bot you already have, behind the telephony (pacing, format conversion, transfers, hand-back timing, drain on deploy):
import websockets
from voicematic import VoiceAgent
from voicematic.adapters.voicebot import JsonBotProtocol, VoiceBotEngine, WebSocketVoiceBot
async def connect(session):
return await websockets.connect("wss://bot.example.com/call")
agent = VoiceAgent(profile, engine=VoiceBotEngine.factory(lambda: WebSocketVoiceBot(connect, JsonBotProtocol())))
A bot with a wire protocol of its own subclasses BotProtocolABC, and one that
is not a websocket implements VoiceBotABC. The bot reaches the agent's tools,
the transfer tool included, through tool-call events.
Packages
| Package | What it holds |
|---|---|
voicematic |
VoiceAgent (.pipeline, .echo), CallSession, AgentProfile, Tool, drain_on_signals |
voicematic.telephony |
TransportABC, CallControlABC; genesys/ for AudioHook, Architect flow and Platform API transfers |
voicematic.voice |
VoiceEngineABC, PipelineEngine, EchoEngine, TurnDetectorABC, EnergyTurnDetector |
voicematic.reasoning |
ReasonerABC, ToolLoopReasoner, CallableReasoner, as_reasoner |
voicematic.llm / speech |
ChatModelABC, SpeechToTextABC, TextToSpeechABC and the neutral conversation types |
voicematic.providers |
the PROVIDERS registry; openai/, anthropic/, mistral/, and langchain as the fallback brain |
voicematic.adapters |
existing systems: langchain/ (models, agents, tools), voicebot/ (a voice bot of your own) |
voicematic.tools |
tool registry, parallel tool calls, the transfer tool, MCP |
voicematic.prompts |
AgentProfile, Language, PromptsABC, DefaultPrompts |
voicematic.audio |
formats, G.711, resampling, WAV |
voicematic.settings |
VoicematicSettings: the voice layer from environment variables (extra) |
voicematic.testing |
an AudioHook simulator (python -m voicematic.testing) and a browser test phone |
Settings
voicematic[settings] adds VoicematicSettings, a pydantic BaseSettings
with only what it takes to build the voice engine from the environment:
VOICE_ENGINE, the vendor behind each role (REASONING_*, STT_*, TTS_*,
VOICE_*), the vendor keys and pipeline turn-taking. It checks all of them at
startup. A project subclasses it with its own settings:
from pydantic_settings import SettingsConfigDict
from voicematic import VoiceAgent
from voicematic.settings import VoicematicSettings
class Settings(VoicematicSettings):
model_config = SettingsConfigDict(env_file=".env")
audiohook_api_key: str | None = None
settings = Settings()
agent = VoiceAgent(profile, engine=settings.engine_factory())
Outside voicematic.settings, which the core never imports, the library reads
no environment and knows no application: profile and tools come from the
project. tests/test_boundary.py enforces that, and
that each vendor SDK or framework is imported only in its own providers/<vendor>/ or
adapters/<name>/.
A complete application, with settings, a Dutch profile, tools, MCP, transfers,
Docker images and the full documentation, is in ../project.
Development
./test.sh # ruff, mypy and pytest in .venv, with voicematic[dev] installed editable
./publish.sh # the checks, a build, and an upload to PyPI (PYPI_API_KEY in .env)
Metadata
Release files for voicematic 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| voicematic-0.2.0.tar.gz | 122.0 kB | Without provenance | Details for voicematic-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| voicematic-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for voicematic-0.2.0-py3-none-any.whl |
Total release size: 236.0 kB
Release files / voicematic-0.2.0.tar.gz
| Download URL | voicematic-0.2.0.tar.gz |
|---|---|
| Size | 122.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2e47a377f09bcd15ba02918a443cf0fa86e1a466dbb1d6c912aadb731ede40a1
|
|
BLAKE2b-256 checksum How to use checksums |
cba10bd412f08e3a5f0e39c2bc0c18781f3b999bffd75ce3e10ed6d98949c639
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.3
|
Release files / voicematic-0.2.0-py3-none-any.whl
| Download URL | voicematic-0.2.0-py3-none-any.whl |
|---|---|
| Size | 114.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
cf1f7aa903edb6086451ef07af7dd31399a62f13b5d861804c1782f26e0d4040
|
|
BLAKE2b-256 checksum How to use checksums |
e8b8300329c471cc489437ba4139025f9140458f54a494289af80a7683c994a6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.3
|
Security for voicematic 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.