Skip to main content

Simultaneous Interpretation

Start a long-running spoken-language interpretation session and receive incremental source text, translated text, optional TTS audio, events, and a final report.

See AI Session Events for the SimultaneousInterpretationEventType lifecycle used by onEvent.

Animated workflow

Interpretation session lifecycle

Coordinate provider startup, the active audio source, ordered incremental results, interruption handling, and final shutdown.

Host app

Configure Languages

Set compatible source and target languages plus TTS and playback options.

AI service

Start Session

Start the provider-backed simultaneous interpretation service.

Host app

Retain Session

Store the returned session and inspect whether the AIBuds AI SDK records internally.

Host app + device

Provide Audio

When SDK internal recording is disabled, feed external PCM to the session; device recording is one possible source.

AI service → app

Stream Results

Order definite source and target segments and handle optional TTS audio.

incremental results
Host app

Handle Runtime Events

Process events, recoverable exceptions, and interruption-driven stops.

Device

Stop External Audio

If device recording is active, stop it before stopping interpretation.

AI service

Stop Interpretation

Request shutdown of the current simultaneous interpretation session.

Final callback

Finish Session

Consume the optional report and clear the retained active session.

A recoverable onException callback does not automatically mean the session has stopped.

Prerequisites

  • AIBudsAISDK is initialized and a registered provider is selected and authenticated.
  • The provider supports SimultaneousInterpretationServiceAPI.
  • Source and target language identifiers use a hyphenated format and are not the same.
  • When AIBuds AI SDK internal recording is disabled, the host app provides external PCM. If that audio comes from the connected device, it conforms to DeviceAudioRecordingAPI.

Implement with AI Assistance

Build with AI

Implement this workflow with AI

Use the official Implement AIBuds Simultaneous Interpretation skill to adapt this workflow to your app.

Read and follow https://docs-aibuds.github.io/skills/implement-aibuds-simultaneous-interpretation. Use it to implement Implement AIBuds Simultaneous Interpretation in this iOS project and verify the result.
View official skill

API Reference

Framework

AIBudsAI.xcframework

Import

Swift
import AIBuds
import AIBudsAI
import AIBudsAIFoundation

Declaration

Swift
/// Starts a simultaneous interpretation session.
/// - Parameters:
///   - config: The session configuration.
///   - onStartSuccess: Called with the started session.
///   - onStartFailure: Called when the session cannot start.
///   - onStopByInterruption: Called when an interruption stops the session.
///   - onException: Called for a recoverable session exception. The app decides
///     whether the session should stop.
///   - streamResultHandler: Called with incremental interpretation results.
///   - onEvent: Called for session-level events.
///   - onFinish: Called with the optional final report.
public static func startSimultaneousInterpretation(_ config: SimultaneousInterpretationConfig = .default,
                                             onStartSuccess: ((_ session: SimultaneousInterpretationSessionConvertible) -> Void)? = nil,
                                             onStartFailure: ((_ error: NSError) -> Void)? = nil,
                                       onStopByInterruption: ((_ error: NSError?) -> Void)? = nil,
                                                onException: ((_ error: NSError) -> Void)? = nil,
                                        streamResultHandler: ((
                                            _ isFinal: Bool,
                                            _ response: SimultaneousInterpretationDataModel?,
                                            _ error: Error?
                                        ) -> Void)? = nil,
                                                    onEvent: ((_ event: SimultaneousInterpretationEventModel) -> Void)? = nil,
                                                   onFinish: ((_ report: SimultaneousInterpretationReportModel?) -> Void)? = nil)

/// Stops the current simultaneous interpretation session.
public static func stopSimultaneousInterpretation()

See startSimultaneousInterpretation and stopSimultaneousInterpretation.

Configuration

SimultaneousInterpretationConfig exposes:

PropertyDefaultDescription
sourceLanguageApp languageOptional source language; an empty string enables auto-detection.
targetLanguageen-USRequired target language.
enableTTStrueWhether translated speech is synthesized.
enableVoicePlaybacktrueWhether synthesized voice playback is enabled.
usesInternalAudioRecordingtrueWhether the AIBuds AI SDK records audio for the session.
preferSpeakerOutputfalseWhether speaker output is preferred.

When usesInternalAudioRecording is false, the AIBuds AI SDK does not capture audio for the session. The host app must retain the returned session and supply external PCM through appendInt16PCM(_:isFinal:) or appendAudioPCMBuffer(_:isFinal:).

Usage Examples

Swift
let config = SimultaneousInterpretationConfig.default
config.sourceLanguage = "zh-CN"
config.targetLanguage = "en-US"
config.usesInternalAudioRecording = true
config.preferSpeakerOutput = false

AIBudsAISDK.startSimultaneousInterpretation(
    config,
    onStartSuccess: { session in
        currentSession = session
    },
    onStartFailure: { error in
        print("Unable to start: \(error.localizedDescription)")
    },
    onStopByInterruption: { error in
        print(error?.localizedDescription ?? "Session interrupted")
        currentSession = nil
    },
    onException: { error in
        print("Session exception: \(error.localizedDescription)")
    },
    streamResultHandler: { isFinal, response, error in
        if let error {
            print(error.localizedDescription)
            return
        }
        guard let response else { return }

        if response.isSourceTextDefinite {
            print("Source: \(response.sourceText ?? "")")
        }
        if response.isTargetTextDefinite {
            print("Target: \(response.targetText ?? "")")
        }
        if isFinal { print("Final result") }
    },
    onEvent: { event in
        print(event)
    },
    onFinish: { report in
        currentSession = nil
        print(report ?? "No report")
    }
)

When session.isRecordingInternally is false, the host app owns the external audio path. The Demo starts device-side AI recording after onStartSuccess, forwards each decoded PCM batch to session.appendInt16PCM(_:isFinal:), stops device recording first, and then calls AIBudsAISDK.stopSimultaneousInterpretation().

Notes

  • Retain the SimultaneousInterpretationSessionConvertible returned at startup to track the active session and its recording mode.
  • onException does not necessarily stop the session. Decide whether to continue or call stopSimultaneousInterpretation().
  • Use sourceTextSequence and targetTextSequence to order definite segments instead of blindly appending every incremental callback.
  • TTS audio can be exposed as a relative file, full file path, or Base64 PCM data on SimultaneousInterpretationDataModel.