AiolaStreamingApp is an iOS application that enables real-time audio streaming and playback using Aiola's Live Streaming API. It provides a seamless experience for users to interact with audio streams, including text-to-speech (TTS) integration and audio player functionalities.
- Live audio streaming to Aiola's backend
- Text-to-speech (TTS) conversion and playback
- Audio player for streamed content
- Swift-based architecture optimized for performance
- macOS with Xcode installed
- iOS device or Simulator running iOS 14+
- Active Aiola API credentials
- Clone the repository:
git clone https://github.com/aiola-lab/aiola-swift-app.git cd AiolaStreamingApp
- Open the project in Xcode:
open AiolaStreamingApp.xcodeproj
- Install the Aiola Swift SDK:
git clone https://github.com/aiola-lab/aiola-swift-sdk.git swift package add https://github.com/aiola-lab/aiola-swift-sdk
- Configure API keys and backend URL in
AudioStreamingManager.swift
- Build and run the app on a Simulator or iOS device
- Launch the Aiola Streaming App on your iOS device.
- Navigate to the Live Streaming section to start an audio stream.
- Use the TTS View to convert text to speech.
- Access the Audio Player to play back stored streams.
Modify AudioStreamingManager.swift
to configure API endpoints and authentication:
import AiolaSwiftSDK
let bearerToken = "<your-bearer-token>" \\ The Bearer token, obtained upon registration with Aiola
let config = StreamingConfig(
endpoint: "<your-base-url>, \\ The URL of the Aiola server
authType: "Bearer",
authCredentials: ["token": bearerToken],
flowId: "<your-flow-id>", \\ One of the IDs from the flows created for the user
executionId: "1009",
langCode: "en_US",
timeZone: "UTC",
namespace: "/events", \\ Namespace for subscription: /transcript (for transcription) or /events (for transcription + LLM solution)
transports: "websocket" \\Communication method: 'websocket' for L4 or 'polling' for L7
)
...
// ✅ Update UI when socket connects
func onConnect() {
DispatchQueue.main.async {
self.isConnected = true
}
print("✅ Connection established")
// Add your code
}
// ✅ Update UI when socket disconnects
func onDisconnect(connectionDuration: TimeInterval, totalAudioSentDuration: TimeInterval) {
DispatchQueue.main.async {
self.isConnected = false
}
print("❌ Connection closed. Duration: \(connectionDuration)ms, Total audio: \(totalAudioSentDuration)ms")
// Add your code
}
func onTranscript(data: Any) {
if let transcriptArray = data as? [[String: String]],
let transcript = transcriptArray.first?["transcript"] {
let newEvent = AudioEvent(type: "📝 Transcript",
content: transcript)
DispatchQueue.main.async {
self.addEvent(newEvent)
}
// Add your code
}
}
func onEvents(data: Any) {
if let eventArray = data as? [[String: Any]],
let results = eventArray.first?["results"] as? [String: Any],
let maskedQuery = results["masked_query"] as? String {
let newEvent = AudioEvent(type: "📢 Event",
content: maskedQuery)
DispatchQueue.main.async {
self.addEvent(newEvent)
}
// Add your code
}
}
func onError(error: String) {
print("⚠️ Error occurred: \(error)")
// Add your code
}
Modify TTSView.swift
to configure API endpoints and authentication:
import AiolaSwiftSDK
private let ttsClient = AiolaTTSClient(baseUrl: "<your-base-url>/api/tts", bearerToken: "<your-bearer-token>")