DaVoice Integration Guides
Step-by-step guides to integrate wake word detection into your applications across all major platforms
New to voice activation? Read what a wake word is and how wake word detection works before choosing an integration path.
iOS (Swift) Integration Guide
📦 Repository
GitHub: https://github.com/frymanofer/IOSNativeSwiftWakeWordDetection
Native iOS SDK with CoreML optimization for on-device wake word detection.
Step 1: Installation via CocoaPods
Add to your Podfile:
platform :ios, '13.0' target 'YourApp' do use_frameworks! pod 'DaVoiceSDK', '~> 1.0' end
Then run:
pod install
Step 2: Configure Permissions
Add to Info.plist:
<key>NSMicrophoneUsageDescription</key>
<string>We need access to your microphone for voice activation</string>
<key>UIBackgroundModes</key>
<array>
<string>audio</string>
</array>Step 3: Swift Implementation
import UIKit
import DaVoiceSDK
import AVFoundation
class ViewController: UIViewController {
private var wakeWordDetector: DaVoiceDetector?
private var isListening = false
override func viewDidLoad() {
super.viewDidLoad()
setupWakeWordDetection()
}
private func setupWakeWordDetection() {
// Request microphone permission
AVAudioSession.sharedInstance().requestRecordPermission { [weak self] allowed in
guard allowed else {
print("Microphone permission denied")
return
}
DispatchQueue.main.async {
self?.initializeDetector()
}
}
}
private func initializeDetector() {
let config = DaVoiceConfig(
modelPath: Bundle.main.path(forResource: "hey_siri", ofType: "onnx")!,
threshold: 0.97,
bufferCount: 3,
enableNoiseReduction: true
)
do {
wakeWordDetector = try DaVoiceDetector(config: config)
wakeWordDetector?.delegate = self
} catch {
print("Failed to initialize detector: \(error)")
}
}
@IBAction func toggleListening(_ sender: UIButton) {
if isListening {
stopListening()
} else {
startListening()
}
}
private func startListening() {
do {
try wakeWordDetector?.start()
isListening = true
print("Started listening for wake word")
} catch {
print("Failed to start listening: \(error)")
}
}
private func stopListening() {
wakeWordDetector?.stop()
isListening = false
print("Stopped listening")
}
}
// MARK: - DaVoiceDetectorDelegate
extension ViewController: DaVoiceDetectorDelegate {
func detectorDidDetectWakeWord(_ detector: DaVoiceDetector,
confidence: Float,
timestamp: Date) {
DispatchQueue.main.async {
print("Wake word detected! Confidence: \(confidence)")
// Handle wake word detection
// e.g., present voice command screen
self.presentVoiceCommandScreen()
}
}
func detector(_ detector: DaVoiceDetector,
didFailWithError error: Error) {
print("Detection error: \(error.localizedDescription)")
}
private func presentVoiceCommandScreen() {
// Navigate to voice command interface
let alert = UIAlertController(
title: "Wake Word Detected",
message: "Listening for your command...",
preferredStyle: .alert
)
present(alert, animated: true)
}
}Step 4: Background Mode Support
Configure audio session for background detection:
func configureAudioSession() {
let audioSession = AVAudioSession.sharedInstance()
do {
try audioSession.setCategory(.playAndRecord,
mode: .voiceChat,
options: [.defaultToSpeaker, .allowBluetooth])
try audioSession.setActive(true)
} catch {
print("Failed to configure audio session: \(error)")
}
}✅ Optimization Tips
- • Use CoreML models for A-series chip optimization
- • Implement proper audio session management
- • Handle interruptions (phone calls, alarms)
- • Test battery usage over extended periods
Need Help Getting Started?
Our team provides free integration support and custom wake word training for all platforms.
Free Development Support • Code Examples • Community Discord • 1-2 Week Custom Model Turnaround