Context Switch is a Rust-based framework for building real-time conversational applications with support for multiple modalities (audio and text). It provides a unified interface for interacting with various speech and language services like Azure Speech Services and OpenAI.
- Multi-modal conversation support (audio and text)
- Pluggable service architecture
- Integration with:
- Azure Speech Services (transcription, translation, synthesis)
- OpenAI dialog services
- Asynchronous processing using Tokio
core/
: Core functionality and interfacesservices/
: Implementation of various service integrationsazure/
: Azure Speech Services integrationgoogle-transcribe/
: Google Speech-to-Text integration (WIP)openai-dialog/
: OpenAI conversational services integration
audio-knife/
: WebSocket server that implements the mod_audio_fork protocol for real-time audio streaming from telephony systems via FreeSWITCH. Provides a bridge between audio sources and the Context Switch framework.examples/
: Example applications showcasing different features
- Rust
- API keys for the services you intend to use:
- OpenAI API key
- Azure Speech Services subscription key
- Google Cloud API key (for Google transcription)
-
Clone the repository:
git clone https://github.com/pragmatrix/context-switch.git cd context-switch
-
Initialize submodules:
git submodule update --init --recursive
-
Create a
.env
file with your API keys (see.env.example
for reference)
The project includes several examples showcasing different functionalities:
# Run OpenAI dialog example
cargo run --example openai-dialog
# Run Azure transcribe example
cargo run --example azure-transcribe
# Run Azure synthesize example
cargo run --example azure-synthesize
Audio Knife is a WebSocket server that implements the mod_audio_fork protocol, allowing real-time audio streaming from telephony systems like FreeSWITCH or Asterisk. It acts as a bridge between audio sources and the Context Switch framework.
To run the Audio Knife server:
cargo run -p audio-knife
By default, it listens on 127.0.0.1:8123
. You can customize the address by setting the AUDIO_KNIFE_ADDRESS
environment variable.
Configure the services by setting the appropriate environment variables in your .env
file:
# OpenAI Configuration
OPENAI_API_KEY=your_openai_key
OPENAI_REALTIME_API_MODEL=gpt-4o-mini-realtime-preview
# Azure Configuration
AZURE_SUBSCRIPTION_KEY=your_azure_key
AZURE_REGION=your_azure_region
# Audio Knife Configuration
AUDIO_KNIFE_ADDRESS=127.0.0.1:8123