Ana içeriğe geç

AI Ses Kaydı

Belirli bir RecordingScene için AI ses kaydını başlatın veya durdurun.

Ön Koşullar

  • Aygıt bağlı ve hazırdır.
  • Aygıt DeviceAudioRecordingAPI protokolüne uyar.
  • Kaydı durdururken başlatırken kullandığınız senaryonun aynısını kullanın.

API Reference

Framework

AIBuds.xcframework

Import

Swift
import AIBuds
import AIBudsFoundation

Protokol

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

Örnek Yöntemleri

YöntemAmaç
startAIAudioRecordingBelirli bir senaryo için AI kaydını başlatır.
stopAIAudioRecordingBelirli senaryonun AI kaydını durdurur.

Kayıt Senaryoları

SwiftObjective-CAçıklama
.onSiteAIBudsRecordingSceneOnSiteOrtam veya yerinde kayıt.
.callAIBudsRecordingSceneCallTelefon görüşmesi sırasında kayıt.

Tamamlanma işleyicisi success ve isteğe bağlı NSError bildirir. Bu yöntemler döküm metni veya kayıt dosyası yolu döndürmez.

Kullanım Örnekleri

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

Hata Yönetimi

Durdurma isteğine eşleşen senaryoyu verebilmek için etkin senaryoyu uygulamada izleyin. Geri çağrı başarısız olursa aygıt bir sonraki kayıt durumu güncellemesini bildirene kadar arayüzü ihtiyatlı durumda tutun.