मुख्य कंटेंट तक स्किप करें

समकालिक व्याख्या

लंबा spoken-language interpretation session शुरू करें और क्रमशः source text, translated text, optional TTS audio, events तथा अंतिम report पाएँ।

SimultaneousInterpretationEventType lifecycle समझने के लिए AI Session Events देखें, जिसका उपयोग onEvent करता है।

Animated workflow

Interpretation session lifecycle

Provider startup, active audio source, क्रमबद्ध incremental results, interruption handling और final shutdown coordinate करें।

Host app

Languages कॉन्फ़िगर करें

Compatible source/target languages तथा TTS और playback options set करें।

AI service

Session शुरू करें

Provider-backed simultaneous interpretation service शुरू करें।

Host app

Session बनाए रखें

मिला session सहेजें और देखें कि AIBuds AI SDK internally record करता है या नहीं।

Host app + डिवाइस

Audio दें

SDK internal recording बंद हो तो session को external PCM दें; device recording एक source हो सकती है।

AI service → app

Results Stream करें

Definite source/target segments को क्रम दें और optional TTS audio संभालें।

incremental results
Host app

Runtime Events संभालें

Events, recoverable exceptions और interruption-driven stops process करें।

डिवाइस

External Audio रोकें

Device recording active हो तो interpretation से पहले उसे रोकें।

AI service

Interpretation रोकें

वर्तमान simultaneous interpretation session shutdown का request करें।

अंतिम callback

Session पूरा करें

Optional report लें और retained active session हटाएँ।

Recoverable onException callback का अर्थ session अपने आप रुक जाना नहीं है।

आवश्यक शर्तें

  • AIBudsAISDK initialize हो और registered provider चुना तथा authenticated हो।
  • Provider SimultaneousInterpretationServiceAPI support करता हो।
  • Source और target language identifiers hyphenated format में हों और समान न हों।
  • AIBuds AI SDK की internal recording बंद होने पर host app external PCM देता है। Audio जुड़े डिवाइस से आता हो तो वह DeviceAudioRecordingAPI को conform करता है।

AI की सहायता से लागू करें

AI से बनाएँ

इस वर्कफ़्लो को AI से लागू करें

आधिकारिक “AIBuds समकालिक अनुवाद लागू करें” स्किल से वर्कफ़्लो को अपने ऐप के अनुसार लागू करें।

https://docs-aibuds.github.io/hi/skills/implement-aibuds-simultaneous-interpretation को पढ़ें और निर्देशों का पालन करें। इस स्किल से “AIBuds समकालिक अनुवाद लागू करें” को इस iOS प्रोजेक्ट में लागू करें और परिणाम सत्यापित करें।
आधिकारिक स्किल देखें

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

startSimultaneousInterpretation और stopSimultaneousInterpretation देखें।

कॉन्फ़िगरेशन

SimultaneousInterpretationConfig ये settings देता है:

प्रॉपर्टीDefaultविवरण
sourceLanguageApp languageOptional source language; empty string auto-detection चालू करती है।
targetLanguageen-USआवश्यक target language।
enableTTStrueTranslated speech synthesize होगी या नहीं।
enableVoicePlaybacktrueSynthesized voice playback चालू है या नहीं।
usesInternalAudioRecordingtrueAIBuds AI SDK session के लिए audio record करता है या नहीं।
preferSpeakerOutputfalseSpeaker output को प्राथमिकता देनी है या नहीं।

usesInternalAudioRecording के false होने पर AIBuds AI SDK session का audio capture नहीं करता। Host app को मिला session बनाए रखना और appendInt16PCM(_:isFinal:) या appendAudioPCMBuffer(_:isFinal:) से external 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.isRecordingInternally के false होने पर external audio path host app संभालता है। Demo onStartSuccess के बाद device-side AI recording शुरू करता है, हर decoded PCM batch को session.appendInt16PCM(_:isFinal:) भेजता है, पहले device recording रोकता है और फिर AIBudsAISDK.stopSimultaneousInterpretation() call करता है।

ध्यान देने योग्य बातें

  • Active session और recording mode track करने के लिए startup पर मिला SimultaneousInterpretationSessionConvertible बनाए रखें।
  • onException जरूरी नहीं कि session रोक दे। तय करें कि जारी रखना है या stopSimultaneousInterpretation() call करना है।
  • हर incremental callback सीधे जोड़ने के बजाय निश्चित segments को क्रम देने के लिए sourceTextSequence और targetTextSequence उपयोग करें।
  • TTS audio SimultaneousInterpretationDataModel में relative file, full file path या Base64 PCM data के रूप में मिल सकता है।