iSIP——macOS SIP自动化工具包
具有集成AI语音服务的开发人员优先的SIP测试框架
  
______________________________________________________________________
概述
iSIP是基于原生PJSIP构建的开发人员优先的SIP自动化工具包(pjsua)绑定。它使工程师能够编写SIP呼叫脚本、测试中继连接和构建支持语音的AI工作流程——所有这些都不需要Docker。
三层架构:
- 开发人员工具包 -测试SIP中继、本地服务器、网关连接
- MCP服务器 -使AI助手能够通过模型上下文协议拨打电话
- 业务自动化 -医疗保健RCM(收入周期管理)、保险验证、IVR导航
*未来愿景:实现保险福利验证(VOB)等自动化工作流程的代理间通信,通过AI对AI协商将长达一小时的等待时间缩短到几秒钟。*
主要特点:
- 🎯 API高浓度吸管 -用于SIP自动化的简洁直观的Python界面
- 📞 SIP协议支持 -通过经过实战测试的PJSIP库进行完整的SIP信令
- 🤖 人工智能集成 -OpenAI TTS用于提示,Deepgram STT用于转录
- 🖥️ CLI工具 -用于单次调用或JSON测试套件的命令行界面
- 🔌 MCP服务器 -启用AI助手(Claude、Cursor)拨打电话! 🎉
- 🐳 Docker就绪 -通过容器进行跨平台部署
- 🔗 兼容LiveKit -使用LiveKit SIP网关进行测试
______________________________________________________________________
快速开始
先决条件
- macOS (10.15+)
- Python 3.12+
- 家酿
安装
# 1. Install system dependencies
brew install pjproject ffmpeg
# 2. Clone repository
git clone
cd isip
# 3. Set up Python environment
cd sdk/python
python3.12 -m venv .venv
source .venv/bin/activate
pip install -e .
# 4. Configure credentials
cp .env.example .env
# Edit .env with your API keys and SIP credentials配置
创建一个 .env 使用您的凭据文件:
# AI Services
OPENAI_API_KEY=sk-...
DEEPGRAM_API_KEY=...
ELEVENLABS_API_KEY=... # Optional
# SIP Gateway
SIP_USERNAME=your_username
SIP_PASSWORD=your_password
SIP_GATEWAY=2g0282esbg2.sip.livekit.cloud______________________________________________________________________
用法
Python API(推荐)
Sippy API提供了最干净的接口:
from siptester import Sippy, VoiceService, SipHeaders
# Configure AI services (auto-loads from .env)
openai = VoiceService("openai", "tts-1")
deepgram = VoiceService("deepgram", "nova-2")
# Create Sippy client
sippy = Sippy(voice_service=openai, transcription_service=deepgram)
# Configure SIP target
target = SipHeaders(sip_to="sip:+19999999999@gateway.sip.livekit.cloud")
# Make call
result = sippy.call(target, prompt="Hello, this is a test call")
# Check results
if result.established:
print(f"Call duration: {result.duration}s")
print(f"Transcript: {result.transcript}")一个用于快速测试的衬垫:
from siptester import quick_call
result = quick_call(
phone="+19999999999",
prompt="Hello, is anyone there?",
username="your_username",
password="your_password"
)
print(result.transcript)MCP服务器(人工智能助理拨打电话!)
新 启用Claude Desktop、Cursor或任何MCP客户端进行电话呼叫:
1.安装MCP服务器:
cd mcp-server-isip
pip install -e .2.配置克劳德桌面 (~/Library/Application Support/Claude/claude_desktop_config.json):
{
"mcpServers": {
"isip": {
"command": "mcp-server-isip",
"cwd": "/Users/nwalker/Development/Quant/isip"
}
}
}3.使用它!
Claude: "Make a call to +19999999999 and introduce yourself"
Claude: "Call the agent and ask for a status update"
Claude: "List my recent recordings"看 mcp-server-isip/QUICKSTART.md 获取完整的设置指南。
CLI使用情况
# Activate virtual environment
source sdk/python/.venv/bin/activate
# Single call with TTS and transcription
siptester call \
--gateway 2g0282esbg2.sip.livekit.cloud \
--user tester \
--password secret \
--phone +15127812507 \
--prompt-text "Hello, this is a test" \
--openai-key "$OPENAI_API_KEY" \
--deepgram-key "$DEEPGRAM_API_KEY"
# Run a test suite
siptester suite \
--suite tests/example_tests.json \
--gateway "$SIP_GATEWAY" \
--user "$SIP_USERNAME" \
--password "$SIP_PASSWORD"端到端测试
运行综合测试套件:
cd /path/to/isip
source sdk/python/.venv/bin/activate
python test_e2e.py该测试:
- ✅ OpenAI TTS生成
- ✅ SIP配置和身份验证
- ✅ 实时呼叫LiveKit网关
- ✅ 音频提示播放
- ✅ 响应记录
- ✅ Deepgram转录
______________________________________________________________________
建筑
┌─────────────────────────────────────────────────────────────┐
│ iSIP Stack │
├─────────────────────────────────────────────────────────────┤
│ │
│ ┌──────────────────────────────────────────────┐ │
│ │ Sippy High-Level API │ │
│ │ (VoiceService, SipHeaders, CallResponse) │ │
│ └──────────────────┬───────────────────────────┘ │
│ │ │
│ ┌──────────────────▼───────────────────────────┐ │
│ │ SipTestClient (Low-Level API) │ │
│ │ Python Wrapper Layer │ │
│ └──────────────────┬───────────────────────────┘ │
│ │ │
│ ┌──────────────────▼───────────────────────────┐ │
│ │ PJSIP Native Bindings │ │
│ │ (pjsua Python Module) │ │
│ └──────────────────┬───────────────────────────┘ │
│ │ │
│ ▼ │
│ ┌────────────────────────┐ │
│ │ SIP Gateway (LiveKit) │ │
│ └────────────────────────┘ │
│ │ │
│ ┌───────────▼────────────┐ │
│ │ AI Services (Cloud) │ │
│ │ OpenAI │ Deepgram │ │
│ └────────────────────────┘ │
└─────────────────────────────────────────────────────────────┘______________________________________________________________________
项目结构
isip/
├── .env.example # Environment template
├── .gitignore # Git ignore rules
├── Dockerfile # Docker build for Linux deployment
├── docker-compose.yml # Docker orchestration
├── README.md # This file
├── EXAMPLES.md # Detailed usage examples
├── DEPLOYMENT.md # Deployment guide (Mac/Docker/K8s)
├── projectplan.md # Development roadmap
│
├── sdk/python/ # Python SDK
│ ├── pyproject.toml # Package configuration
│ ├── README.md # SDK documentation
│ └── siptester/ # Main package
│ ├── __init__.py # Package exports
│ ├── cli.py # CLI implementation
│ ├── client.py # Low-level SIP client
│ └── sippy.py # High-level Sippy API
│
├── examples/ # Example scripts
│ ├── example_sippy.py # Comprehensive Python examples
│ └── test_sip_connection.sh # Bash wrapper script
│
└── test_e2e.py # End-to-end test suite______________________________________________________________________
测试
✅ 已验证的组件
所有组件都经过了端到端的测试:
| 组件 | 状态 | 注释 |
|---|---|---|
| PJSIP绑定 | ✅ 正在工作 | 本地SIP堆栈正在运行 |
| Python SDK | ✅ 正在工作 | 所有导入都成功 |
| 吸管API | ✅ 工作 | 高级界面功能正常 |
| OpenAI TTS✅ 工作中 | 音频生成已确认 | |
| LiveKit SIP | ✅ 工作中 | 28.8秒实时通话完成 |
| 录音 | ✅ 正在工作 | 已捕获899KB的录制 |
| Deepgram STT | ✅ 正在工作 | 转录已验证 |
| CLI工具 | ✅ 工作 | 命令行界面功能正常 |
测试结果
最新端到端测试(2024-12-04):
✓ TTS Generation: PASS (90.8 KB audio file)
✓ SIP Config: PASS (LiveKit authentication)
✓ Live SIP Call: PASS (28.8s call, transcript received)
Transcript: "I hear you loud and clear. How can I help you today?"______________________________________________________________________
部署
macOS(本机)
当前的实现针对macOS上的本地开发进行了优化。
赞成的意见:
- 快速迭代周期
- 原生音频设备支持
- 直接Homebrew集成
设置: 看 快速开始
Docker(跨平台)
在Linux、Windows(WSL)或容器化环境中部署。
# Build image
docker build -t isip:latest .
# Run single test
docker run --rm --env-file .env isip:latest call \
--gateway 2g0282esbg2.sip.livekit.cloud \
--user "$SIP_USERNAME" \
--password "$SIP_PASSWORD" \
--phone +19999999999
# Run test suite
docker-compose up isip-worker请参阅: DEPLOYMENT.md 完整的部署指南,包括:
- Kubernetes CronJobs
- CI/CD集成(GitHub操作)
- AWS Lambda函数
- 生产模式
______________________________________________________________________
api参考
虹吸高水平API
语音服务 -配置AI语音提供商
VoiceService(
provider: Literal["openai", "elevenlabs", "deepgram"],
model: str,
api_key: Optional[str] = None, # Auto-loads from env
voice: str = "alloy"
)SipHeaders -SIP连接配置
SipHeaders(
sip_to: str, # e.g., "sip:+19999999999@gateway.com"
auth_user: Optional[str] = None, # Auto-loads from SIP_USERNAME
auth_password: Optional[str] = None, # Auto-loads from SIP_PASSWORD
gateway: Optional[str] = None, # Auto-loaded from SIP_GATEWAY
local_ip: Optional[str] = None,
local_port: int = 5060
)Sippy -主要客户
Sippy(
voice_service: Optional[VoiceService] = None,
transcription_service: Optional[VoiceService] = None,
output_dir: Optional[Path] = None,
log_level: int = 3
)
# Make a call
sippy.call(
target: SipHeaders,
prompt: Optional[str] = None,
prompt_file: Optional[Path] = None,
timeout: float = 30.0,
transcribe: bool = True
) -> CallResponse呼叫响应 -结果对象
@dataclass
class CallResponse:
established: bool
duration: float
recording: Optional[Path]
transcript: Optional[str]
prompt_file: Optional[Path]
error: Optional[str]低级客户端API
对于需要细粒度控制的高级用例:
from siptester.client import SipTestClient, SipScenario
client = SipTestClient(
gateway="gateway.sip.livekit.cloud",
username="user",
password="pass",
local_ip="67.198.117.118"
)
with client:
scenario = SipScenario(
phone="+19999999999",
prompt_file=Path("prompt.wav"),
record_file=Path("response.wav"),
timeout=30.0
)
result = client.run_scenario(scenario)______________________________________________________________________
路线图
看 projectplan.md 查看详细的里程碑。
即将推出的功能
第一阶段:SDK稳定
- \[\]发布到内部PyPI
- \[\]使用PJSIP模拟进行单元测试
- \[\]键入存根和mypy覆盖范围
- \[x\] 端到端测试框架✅
第2阶段:CLI增强
- \[\]配置文件支持(
~/.isip/config.yaml) - \[\]JSON输出和波形预览
- \[\]并行测试执行并重试
第3阶段:场景目录
- \[\]与ResoN8共享测试定义
- \[ \]
siptester fetch策划场景的命令
第四阶段:跨平台
- \[\]Linux支持验证
- \[\]Windows兼容性(WSL2)
- \[\]Docker镜像优化
第五阶段:ResoN8集成
- \[\]云暴API
- \[\]集中报告
- \[\]按比例进行负载测试
______________________________________________________________________
故障排除
常见问题
未找到PJSIP
brew install pjproject2.未找到ffmpeg
brew install ffmpeg3.麦克风权限 在“系统首选项”中授予权限→ 安全与隐私→ 麦克风
4.NAT/防火墙问题 可能需要配置 local_ip 参数与您的公共IP:
target = SipHeaders(sip_to="sip:...", local_ip="67.198.117.118")5.SIP身份验证失败 与您的SIP提供商验证凭据。对于基于电子邮件的用户名(例如。, nate@ravenhelm.co),SDK会自动处理格式化。
6.SIP URI中的双@ 自动修复-SDK从电子邮件地址中提取用户部分。
______________________________________________________________________
贡献
目前,这是一个正在积极开发的原型。欢迎投稿!
开发设置:
git clone
cd isip/sdk/python
python3.12 -m venv .venv
source .venv/bin/activate
pip install -e ".[dev]" # When dev dependencies are added承诺前:
- 确保测试通过:
python test_e2e.py - 检查过梁错误
- 如果添加功能,请更新文档
______________________________________________________________________
相关项目
- Reso8 -基于云的SIP测试平台(计划集成)
- PJSIP -底层SIP协议栈
- LiveKit 的 -用于测试的SIP网关
______________________________________________________________________
许可证
\[在此处指定您的许可证\]
______________________________________________________________________
鸣谢
内置:
______________________________________________________________________
支持
对于问题、疑问或功能请求:
- 审查
EXAMPLES.md详细用法 - 检查
DEPLOYMENT.md获取部署帮助 - 看
projectplan.md发展状况
______________________________________________________________________
由...制作❤️ 适用于需要在没有云开销的情况下测试SIP呼叫的工程师
