Skip to content

loreste/siprec

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

88 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

SIPREC Server

Go Version License Documentation Build Status NAT Support TCP Optimized

A high-performance, enterprise-grade SIP recording (SIPREC) server that implements RFC 7865/7866 with custom TCP-optimized transport, advanced real-time transcription capabilities, and comprehensive NAT support for cloud deployments.

✨ Key Features

Core SIPREC Capabilities

  • πŸ“ž RFC Compliance - Complete RFC 7865/7866 implementation for SIP session recording
  • πŸ”„ Session Management - Advanced session lifecycle management with failover support
  • ⏸️ Pause/Resume Control - Real-time pause and resume of recording and transcription via REST API
  • 🎯 NAT Traversal - Comprehensive NAT support with STUN integration for cloud deployments
  • πŸ”— SIP Integration - Custom SIP server implementation optimized for TCP transport and large metadata

Transcription & Processing

  • πŸŽ™οΈ Real-time Streaming Transcription - Enhanced multi-provider STT with full WebSocket streaming support (Google, Deepgram, OpenAI, Azure, Amazon)
  • ⚑ Streaming Response Support - Real-time callback-based transcription with interim and final results
  • πŸ‘₯ Speaker Diarization - Multi-speaker identification and word-level speaker tagging
  • πŸ›‘οΈ PII Detection & Redaction - Automatic detection and redaction of SSNs, credit cards, and other sensitive data from transcriptions and audio
  • 🎡 Audio Processing - Advanced VAD, noise reduction, and multi-channel mixing
  • 🌐 WebSocket Streaming - Real-time transcription delivery with circuit breaker patterns
  • πŸ“Š Quality Metrics - Audio quality monitoring and adaptive processing with performance optimization
  • πŸ”„ Provider Interface Standardization - Unified callback interface across all STT providers

Enterprise Features

  • πŸ” Security - End-to-end encryption with TLS/SRTP and configurable key rotation
  • πŸ“¨ Message Queue - AMQP integration with delivery guarantees and circuit breakers
  • πŸ“ˆ Monitoring - Comprehensive metrics, health checks, and operational visibility
  • ☁️ Cloud Ready - Optimized for GCP, AWS, Azure with automatic configuration

πŸš€ Quick Start

Cloud Deployment (Recommended)

Google Cloud Platform

# One-command deployment
./deploy-quick.sh

# Or with Terraform
terraform init
terraform apply -var="project_id=YOUR_PROJECT_ID"

Manual Linux Installation

# Download and run deployment script
wget https://raw.githubusercontent.com/loreste/siprec/main/deploy_gcp_linux.sh
chmod +x deploy_gcp_linux.sh
sudo ./deploy_gcp_linux.sh

Docker Deployment

# Production deployment
docker run -d \
  --name siprec-server \
  --restart unless-stopped \
  -p 5060:5060/udp \
  -p 5060:5060/tcp \
  -p 5061:5061/udp \
  -p 8080:8080 \
  -v $(pwd)/recordings:/var/lib/siprec/recordings \
  -v $(pwd)/config:/etc/siprec \
  -e BEHIND_NAT=true \
  -e EXTERNAL_IP=auto \
  ghcr.io/loreste/siprec:latest

Development Setup

# Clone repository
git clone https://github.com/loreste/siprec.git
cd siprec

# Build from source
go build -o siprec ./cmd/siprec

# Run with default configuration
./siprec

βš™οΈ Configuration

Environment Variables

The server can be configured via environment variables or a .env file:

# Network Configuration (NAT Optimized)
BEHIND_NAT=true                    # Enable NAT support
EXTERNAL_IP=auto                   # Auto-detect external IP
INTERNAL_IP=auto                   # Auto-detect internal IP
PORTS=5060,5061                    # SIP listening ports
RTP_PORT_MIN=16384                 # RTP port range start
RTP_PORT_MAX=32768                 # RTP port range end

# STUN Configuration
STUN_SERVER=stun:stun.l.google.com:19302

# Security
ENABLE_TLS=true                    # Enable TLS for SIP
TLS_CERT_PATH=/path/to/cert.pem    # TLS certificate
TLS_KEY_PATH=/path/to/key.pem      # TLS private key
ENABLE_SRTP=true                   # Enable SRTP for media

# Transcription
STT_DEFAULT_VENDOR=google          # STT provider
GOOGLE_APPLICATION_CREDENTIALS=/path/to/service-account.json

# Recording
RECORDING_DIR=/var/lib/siprec/recordings
RECORDING_MAX_DURATION=4h
ENABLE_RECORDING_ENCRYPTION=false

# STT Provider
STT_PROVIDERS=google-enhanced  # Enhanced providers: google-enhanced, deepgram-enhanced, openai, azure, amazon
STT_ENABLE_DIARIZATION=true    # Enable speaker diarization
STT_ENABLE_WORD_TIMESTAMPS=true # Enable word-level timestamps
STT_ENABLE_STREAMING=true      # Enable real-time streaming transcription

# Audio Processing
VAD_ENABLED=true
NOISE_REDUCTION_ENABLED=true

# Pause/Resume Control API
PAUSE_RESUME_ENABLED=true          # Enable pause/resume API
PAUSE_RESUME_REQUIRE_AUTH=true     # Require API key authentication
PAUSE_RESUME_API_KEY=your-api-key  # API key for authentication
PAUSE_RESUME_PER_SESSION=true      # Allow per-session control

# PII Detection & Redaction
PII_DETECTION_ENABLED=true         # Enable PII detection
PII_ENABLED_TYPES=ssn,credit_card  # Types to detect: ssn, credit_card, phone, email
PII_REDACTION_CHAR=*               # Character used for redaction
PII_APPLY_TO_TRANSCRIPTIONS=true   # Apply PII filtering to transcriptions
PII_APPLY_TO_RECORDINGS=true       # Apply PII marking to audio recordings
PII_PRESERVE_FORMAT=true           # Preserve original format when redacting
PII_CONTEXT_LENGTH=10              # Context characters around detected PII

For detailed configuration, see Configuration Guide.

πŸ“– Documentation

Comprehensive documentation is available in the docs directory:

πŸ—οΈ Architecture

SIPREC Server is built with a modular architecture:

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   SIP/RTP   │────▢│   Audio     │────▢│     STT     β”‚
β”‚   Handler   β”‚     β”‚ Processing  β”‚     β”‚  Provider   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                            β”‚                    β”‚
                            β–Ό                    β–Ό
                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                    β”‚  Recording  β”‚     β”‚ WebSocket/  β”‚
                    β”‚   Storage   β”‚     β”‚    AMQP     β”‚
                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ”Œ API Endpoints

HTTP API

  • GET /health - Health check endpoint
  • GET /health/live - Kubernetes liveness probe
  • GET /health/ready - Kubernetes readiness probe
  • GET /metrics - Prometheus metrics
  • GET /api/sessions - Active sessions
  • GET /api/sessions/stats - Session statistics

Pause/Resume Control API

  • POST /api/sessions/{id}/pause - Pause recording/transcription for specific session
  • POST /api/sessions/{id}/resume - Resume recording/transcription for specific session
  • GET /api/sessions/{id}/pause-status - Get pause status for specific session
  • POST /api/sessions/pause-all - Pause all active sessions
  • POST /api/sessions/resume-all - Resume all paused sessions
  • GET /api/sessions/pause-status - Get pause status for all sessions

Example Usage

# Pause recording for a specific session
curl -X POST http://localhost:8080/api/sessions/session-123/pause \
  -H "Content-Type: application/json" \
  -H "X-API-Key: your-api-key" \
  -d '{"pause_recording": true, "pause_transcription": false}'

# Resume a session
curl -X POST http://localhost:8080/api/sessions/session-123/resume \
  -H "X-API-Key: your-api-key"

# Get pause status
curl -H "X-API-Key: your-api-key" \
  http://localhost:8080/api/sessions/session-123/pause-status

# Pause all sessions
curl -X POST http://localhost:8080/api/sessions/pause-all \
  -H "Content-Type: application/json" \
  -H "X-API-Key: your-api-key" \
  -d '{"pause_recording": true, "pause_transcription": true}'

WebSocket

  • WS /ws/transcriptions - Real-time transcription stream

πŸ§ͺ Testing

Validate Installation

# Check service status
systemctl status siprec-server

# Test health endpoint
curl http://localhost:8080/health

# Test SIP response
echo -e "OPTIONS sip:test@localhost SIP/2.0\r\nVia: SIP/2.0/UDP test:5070\r\nFrom: sip:test@test\r\nTo: sip:test@localhost\r\nCall-ID: test\r\nCSeq: 1 OPTIONS\r\nContent-Length: 0\r\n\r\n" | nc -u localhost 5060

NAT Configuration Test

# Run comprehensive NAT testing
./test_nat_config.sh

# Check NAT detection
curl -H "Metadata-Flavor: Google" http://metadata.google.internal/computeMetadata/v1/instance/network-interfaces/0/external-ip

Load Testing

# Run test suite
go test -v ./...

# Run E2E tests
./run_test.sh

# SIPREC simulation
./test/e2e/siprec_simulation_test.go

🏒 Production Deployment

System Requirements

  • OS: Ubuntu 20.04+, Debian 11+, CentOS 8+, RHEL 8+
  • Memory: 4GB RAM minimum, 8GB recommended
  • CPU: 2 cores minimum, 4 cores recommended
  • Storage: 50GB minimum for recordings
  • Network: Public IP for external access

Performance Characteristics

  • Concurrent Sessions: 100+ simultaneous recordings
  • Audio Quality: PCM/G.711/G.722 codec support
  • Latency: <100ms for real-time streaming transcription
  • Throughput: 1000+ RTP packets/second per session
  • Streaming Support: Real-time interim and final transcription results
  • Provider Agnostic: Unified interface across all STT vendors

High Availability Setup

# Multiple instances with load balancer
# Session state stored in external database
# Shared storage for recordings
# AMQP clustering for message reliability

Monitoring & Alerting

# Prometheus metrics
curl http://localhost:8080/metrics

# Key metrics to monitor:
# - siprec_active_calls
# - siprec_rtp_packets_received
# - siprec_transcription_errors
# - siprec_session_duration

πŸ”§ Administration

Service Management

# SystemD commands
sudo systemctl start siprec-server
sudo systemctl stop siprec-server
sudo systemctl restart siprec-server
sudo systemctl status siprec-server

# View logs
sudo journalctl -u siprec-server -f

# Configuration reload
sudo systemctl reload siprec-server

Troubleshooting

# Check configuration
./siprec envcheck

# Test connectivity
netstat -tulpn | grep 5060

# Debug NAT issues
./test_nat_config.sh

# View detailed logs
tail -f /var/log/siprec/siprec.log

🌟 Use Cases

Contact Centers

  • Call Recording: Automatic SIPREC-compliant call recording
  • Quality Assurance: Real-time transcription for agent monitoring
  • Compliance: Regulatory compliance with complete audit trails

Enterprise Communications

  • Meeting Recording: Conference call recording and transcription
  • Training: Call analysis and training material generation
  • Analytics: Voice analytics and sentiment analysis

Telecommunications

  • Service Provider: SIPREC recording for telecom operators
  • Legal Compliance: Lawful intercept and recording capabilities
  • Network Analysis: Call quality and performance monitoring

πŸ“Š Comparison

Feature SIPREC Server Commercial Solutions Open Source Alternatives
RFC Compliance βœ… Full RFC 7865/7866 βœ… Yes ⚠️ Limited
Real-time Transcription βœ… Multi-provider βœ… Yes ❌ No
NAT Support βœ… Advanced βœ… Yes ⚠️ Basic
Cloud Ready βœ… Optimized βœ… Yes ⚠️ Manual
Cost βœ… Open Source ❌ Expensive βœ… Free
Customization βœ… Full Control ❌ Limited βœ… Yes

🀝 Contributing

We welcome contributions from the community! Please see our Contributing Guide for details.

Development Setup

# Clone and setup
git clone https://github.com/loreste/siprec.git
cd siprec

# Install dependencies
go mod download

# Run tests
go test -v ./...

# Build
go build -o siprec ./cmd/siprec

Coding Standards

  • Follow Go best practices and idioms
  • Write comprehensive tests for new features
  • Update documentation for user-facing changes
  • Use conventional commit messages

πŸ“„ License

This project is licensed under the GNU General Public License v3.0 - see the LICENSE file for details.

πŸ†˜ Support

Documentation

Community Support

Professional Support

For enterprise support, custom development, or consulting services, please contact us through the repository.


Built with ❀️ for the VoIP and telecommunications community

About

OpenSource SIPREC server written ing Golang by Lance Oreste

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •