본문으로 건너뛰기

동시통역

장시간 실행되는 음성 동시통역 세션을 시작하고 실시간 원문, 번역문, 선택적 TTS 오디오, 이벤트, 최종 보고서를 받습니다.

SimultaneousInterpretationEventType 수명 주기와 onEvent에서의 사용 방법은 AI 세션 이벤트를 참고하세요.

Animated workflow

동시통역 세션 수명 주기

서비스 제공자 시작, 활성 오디오 입력, 순서가 있는 실시간 결과, 중단 처리, 최종 종료를 함께 관리합니다.

호스트 앱

언어 설정

호환되는 원문 및 번역 언어와 TTS 및 재생 옵션을 설정합니다.

AI 서비스

세션 시작

서비스 제공자가 처리하는 동시통역 서비스를 시작합니다.

호스트 앱

세션 유지

반환된 세션을 보관하고 AIBuds AI SDK가 내부 녹음을 사용하는지 확인합니다.

호스트 앱 + 기기

오디오 제공

SDK 내부 녹음이 꺼져 있으면 외부 PCM을 세션에 전달합니다. 기기 녹음도 입력으로 사용할 수 있습니다.

AI 서비스 → 앱

실시간 결과 처리

확정된 원문과 번역문을 순서대로 정리하고 선택적 TTS 오디오를 처리합니다.

실시간 결과
호스트 앱

실행 이벤트 처리

이벤트, 복구 가능한 예외, 중단으로 인한 종료를 처리합니다.

기기

외부 오디오 중지

기기 녹음 중이면 동시통역을 중지하기 전에 먼저 녹음을 중지합니다.

AI 서비스

동시통역 중지

현재 동시통역 세션 종료를 요청합니다.

최종 콜백

세션 완료

선택적 보고서를 처리하고 보관한 활성 세션을 정리합니다.

복구 가능한 onException 콜백이 발생했다고 해서 세션이 자동으로 중지된 것은 아닙니다.

사전 요구 사항

  • AIBudsAISDK가 초기화되어 있고 등록된 서비스 제공자가 선택 및 인증되어 있습니다.
  • 서비스 제공자가 SimultaneousInterpretationServiceAPI를 지원합니다.
  • 원문 언어와 번역 언어 식별자는 하이픈 형식을 사용하며 서로 달라야 합니다.
  • AIBuds AI SDK 내부 녹음이 꺼져 있으면 호스트 앱이 외부 PCM을 제공합니다. 연결된 기기에서 오디오를 받는다면 기기가 DeviceAudioRecordingAPI를 준수해야 합니다.

AI를 활용해 구현

AI로 구현

AI로 이 워크플로 구현

공식 “AIBuds 동시통역 구현” 스킬을 사용해 앱에 맞게 구현하세요.

https://docs-aibuds.github.io/ko/skills/implement-aibuds-simultaneous-interpretation을 읽고 지침을 따르세요. 이 스킬로 “AIBuds 동시통역 구현”을 이 iOS 프로젝트에 구현하고 검증하세요.
공식 스킬 보기

API Reference

프레임워크

AIBudsAI.xcframework

Import

Swift
import AIBuds
import AIBudsAI
import AIBudsAIFoundation

선언

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()

startSimultaneousInterpretationstopSimultaneousInterpretation을 참고하세요.

설정

SimultaneousInterpretationConfig는 다음 설정을 제공합니다.

속성기본값설명
sourceLanguage앱 언어선택적 원문 언어입니다. 빈 문자열이면 자동 감지를 사용합니다.
targetLanguageen-US필수 번역 언어입니다.
enableTTStrue번역문을 음성으로 합성할지 여부입니다.
enableVoicePlaybacktrue합성 음성 재생을 사용할지 여부입니다.
usesInternalAudioRecordingtrue세션에서 AIBuds AI SDK 내부 녹음을 사용할지 여부입니다.
preferSpeakerOutputfalse스피커 출력을 우선할지 여부입니다.

usesInternalAudioRecordingfalse이면 AIBuds AI SDK가 세션 오디오를 녹음하지 않습니다. 호스트 앱은 반환된 세션을 유지하고 appendInt16PCM(_:isFinal:) 또는 appendAudioPCMBuffer(_:isFinal:)로 외부 PCM을 전달해야 합니다.

사용 예제

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")
    }
)

session.isRecordingInternallyfalse이면 호스트 앱이 외부 오디오 경로를 관리합니다. Demo는 onStartSuccess 뒤 기기 AI 녹음을 시작하고 디코딩한 PCM 묶음을 session.appendInt16PCM(_:isFinal:)로 전달한 다음, 기기 녹음을 먼저 중지하고 AIBudsAISDK.stopSimultaneousInterpretation()을 호출합니다.

참고

  • 시작 때 반환된 SimultaneousInterpretationSessionConvertible을 유지하여 활성 세션과 녹음 방식을 추적합니다.
  • onException이 세션 중지를 뜻하지는 않습니다. 계속할지 stopSimultaneousInterpretation()을 호출할지 결정하세요.
  • 모든 실시간 콜백을 그대로 이어 붙이지 말고 sourceTextSequencetargetTextSequence로 확정 구간의 순서를 정렬하세요.
  • SimultaneousInterpretationDataModel의 TTS 오디오는 상대 파일 경로, 전체 파일 경로 또는 Base64 PCM 데이터로 제공될 수 있습니다.