fastrtc-voice-agent
A modular voice agent built on FastRTC
Installation
Recommended: Using uv
uv is the recommended way to manage your Python environment and dependencies.
# Create a virtual environment with Python 3.12+
uv venv --python 3.12
# Activate the environment
source .venv/bin/activate
# Install the package
uv add fastrtc-voice-agent
# Install with optional dependencies (e.g., ollama)
uv add "fastrtc-voice-agent[ollama]"
# Or install all optional dependencies
uv add "fastrtc-voice-agent[all]"
Using pip
pip install fastrtc-voice-agent
# Install your desired STT and LLM with (for example):
pip install "fastrtc-voice-agent[ollama]"
# Or for all optional dependencies:
pip install "fastrtc-voice-agent[all]"
CLI Usage Example
For default config :
fastrtc-voice-agent --run
Please refere to the help for custom config :
fastrtc-voice-agent --help
Python Usage Example
from fastrtc import ReplyOnPause, Stream
from voice_agent import create_agent, AgentConfig, STTConfig, TTSConfig, LLMConfig
config = AgentConfig(
system_prompt="You are a helpful voice assistant.",
stt=STTConfig(backend="faster_whisper", model_size="small"),
tts=TTSConfig(backend="edge", voice="en-US-AvaMultilingualNeural"),
llm=LLMConfig(backend="ollama", model="llama3.2:3b"),
)
agent = create_agent(config)
stream = Stream(
ReplyOnPause(agent.create_fastrtc_handler()),
modality="audio",
mode="send-receive",
)
stream.ui.launch()
Custom Frontend Integration
If you want to use your own frontend (React, Vue, etc.) instead of the built-in Gradio UI, you can run the agent as an API server.
CLI - API Mode
# Install with API support
pip install "fastrtc-voice-agent[api]"
# Run as API server (no Gradio UI)
fastrtc-voice-agent --run --api --port 8000
This exposes WebRTC endpoints:
POST /webrtc/offer- WebRTC signalingWS /websocket/offer- WebSocket alternative
Python - API Server
from voice_agent import create_api_server, AgentConfig, STTConfig, TTSConfig, LLMConfig
# Create a FastAPI app with the voice agent
app = create_api_server(
config=AgentConfig(
system_prompt="You are a helpful assistant.",
stt=STTConfig(backend="faster_whisper"),
tts=TTSConfig(backend="edge"),
llm=LLMConfig(backend="ollama"),
)
)
# Run with: uvicorn main:app --host 0.0.0.0 --port 8000
You can also mount it in an existing FastAPI app:
from fastapi import FastAPI
from voice_agent import create_api_server
main_app = FastAPI()
voice_app = create_api_server()
main_app.mount("/voice", voice_app)
React Example
See the examples/react-client directory for a complete React example with a useVoiceAgent hook.
Quick example:
import { useVoiceAgent } from "./useVoiceAgent";
function App() {
const { isConnected, connect, disconnect } = useVoiceAgent({
serverUrl: "http://localhost:8000",
});
return (
<button onClick={isConnected ? disconnect : connect}>
{isConnected ? "Stop" : "Start"}
</button>
);
}
Note
To use Anthropic API (may be OpenAI or else later) please copy .env.example as .env file and fill it with your API KEY and the desired model
Metadata
Release files for fastrtc-voice-agent 0.2.1
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 |
|---|---|---|---|---|
| fastrtc_voice_agent-0.2.1.tar.gz | 12.9 kB | Without provenance | Details for fastrtc_voice_agent-0.2.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| fastrtc_voice_agent-0.2.1-py3-none-any.whl | Python 3 | none | any | Details for fastrtc_voice_agent-0.2.1-py3-none-any.whl |
Total release size: 31.3 kB
Release files / fastrtc_voice_agent-0.2.1.tar.gz
| Download URL | fastrtc_voice_agent-0.2.1.tar.gz |
|---|---|
| Size | 12.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6926cafe39dea0872bde3b01ca55dbfd47cd5ae7c8ba47790a5afb8799ef9e8f
|
|
BLAKE2b-256 checksum How to use checksums |
0c0246b9b8b33d97205a967d4f97d49ba985dd48bd0509d515bbbbae5d281446
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.8.14
|
Release files / fastrtc_voice_agent-0.2.1-py3-none-any.whl
| Download URL | fastrtc_voice_agent-0.2.1-py3-none-any.whl |
|---|---|
| Size | 18.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4d478a3969cc0e279e34a79f116b75e948fd5fd48b75b1b1ae2264d59393ca43
|
|
BLAKE2b-256 checksum How to use checksums |
696f5055ef7968c1eca91713c81556fc833d129236aeadbf9b01a5e8f39e299d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.8.14
|
Security for fastrtc-voice-agent 0.2.1
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.