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

AI ऑडियो रिकॉर्डिंग

किसी specific RecordingScene के लिए AI audio recording शुरू और बंद करें।

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

  • डिवाइस connected और ready है।
  • डिवाइस DeviceAudioRecordingAPI को conform करता है।
  • Recording बंद करते समय वही scene उपयोग करें जिससे recording शुरू की थी।

API संदर्भ

Framework

AIBuds.xcframework

Import

Swift
import AIBuds
import AIBudsFoundation

प्रोटोकॉल

Swift
/// The protocol for device API that supports audio recording.
protocol DeviceAudioRecordingAPI: DeviceAPI {
    /// Starts an AI audio recording for the specified scene.
    /// - Parameters:
    ///   - scene: The recording scenario context.
    ///   - completion: A closure that is called when the operation completes.
    ///     - success: `true` if the operation was successful; otherwise `false`.
    ///     - error: An `NSError` object that describes the error that occurred, or `nil` if the operation was successful.
    func startAIAudioRecording(
        _ scene: RecordingScene,
        completion: AIBudsCompletionHandler?
    )

    /// Stops the AI audio recording for the specified scene.
    /// - Parameters:
    ///   - scene: The recording scenario context.
    ///   - completion: A closure that is called when the operation completes.
    ///     - success: `true` if the operation was successful; otherwise `false`.
    ///     - error: An `NSError` object that describes the error that occurred, or `nil` if the operation was successful.
    func stopAIAudioRecording(
        _ scene: RecordingScene,
        completion: AIBudsCompletionHandler?
    )
}

इंस्टेंस मेथड

Methodउपयोग
startAIAudioRecordingकिसी scene के लिए AI recording शुरू करें।
stopAIAudioRecordingउस scene की AI recording बंद करें।

रिकॉर्डिंग सीन

SwiftObjective-Cविवरण
.onSiteAIBudsRecordingSceneOnSiteAmbient या on-site recording।
.callAIBudsRecordingSceneCallPhone call के दौरान recording।

Completion handler success और optional NSError report करता है। ये methods transcription text या recording file path नहीं लौटाते।

उपयोग के उदाहरण

Swift
import AIBuds

guard let device = device as? DeviceAudioRecordingAPI else {
    print("Device does not support audio recording")
    return
}

let scene: RecordingScene = .onSite
device.startAIAudioRecording(scene) { success, error in
    guard success else {
        print("AI recording failed to start: \(error?.localizedDescription ?? "Unknown error")")
        return
    }
    print("AI recording started")
}

// Stop using the same scene.
device.stopAIAudioRecording(scene) { success, error in
    if !success {
        print(error?.localizedDescription ?? "AI recording failed to stop")
    }
}

त्रुटि प्रबंधन

App में active scene track करें ताकि stop request में matching scene भेज सकें। Callback fail हो तो डिवाइस के अगले recording-state update तक UI state conservative रखें।