Features
- Real-time voice conversations with AI
- Support for both Outspeed and OpenAI providers
- WebRTC-based audio streaming
- Customizable voice and model selection
- ElevenLabs Conversational AI compatibility
Installation
-
Open Your Project in Xcode
-
Go to
File > Add Packages...
-
Enter Repository URL:
https://github.com/outspeed-ai/OutspeedSwift
-
Import the SDK
Ensure NSMicrophoneUsageDescription is added to your Info.plist to explain microphone access.
Requirements
- iOS 15.2 or later
- Swift 6.1+
Basic Usage
Here’s the minimal code to get a voice conversation working:
import OutspeedSDK
// Create a session configuration
let config = OutspeedSDK.SessionConfig()
// Create callbacks to handle events
let callbacks = OutspeedSDK.Callbacks()
callbacks.onMessage = { message, role in
print("Received message from \(role.rawValue): \(message)")
}
callbacks.onError = { message, error in
print("Error: \(message)")
}
callbacks.onStatusChange = { status in
print("Status changed to: \(status.rawValue)")
}
// Start the conversation
Task {
do {
let conversation = try await OutspeedSDK.Conversation.startSession(
config: config,
callbacks: callbacks,
apiKey: "<YOUR_OUTSPEED_API_KEY>"
)
// When done with the conversation
conversation.endSession()
} catch {
print("Failed to start conversation: \(error)")
}
}
Customization
System Prompt and First Message
let agentConfig = OutspeedSDK.AgentConfig(
prompt: "You are a helpful assistant with a witty personality.",
firstMessage: "Hey there, how can I help you with Outspeed today?"
)
let config = OutspeedSDK.SessionConfig(
overrides: OutspeedSDK.ConversationConfigOverride(agent: agentConfig)
)
Voice Selection
let ttsConfig = OutspeedSDK.TTSConfig(voiceId: OutspeedSDK.Voice.david.rawValue)
let config = OutspeedSDK.SessionConfig(
overrides: OutspeedSDK.ConversationConfigOverride(tts: ttsConfig)
)
Complete Example
See a full iOS voice bot application example at our Examples Repository.