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
DeviceAudioRecordingAPIprotokolüne uyar. - Kaydı durdururken başlatırken kullandığınız senaryonun aynısını kullanın.
API Reference
Framework
AIBuds.xcframework
Import
- Swift
- Objective-C
import AIBuds
import AIBudsFoundation#import <AIBuds/AIBuds-Swift.h>
#import <AIBuds/AIBuds.h>Protokol
- Swift
- Objective-C
/// 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?
)
}/// The protocol for device API that supports audio recording.
@protocol AIBudsDeviceAudioRecordingAPI <AIBudsDeviceAPI>
/// 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.
- (void)startAIAudioRecordingWithScene:(enum AIBudsRecordingScene)scene
completion:(AIBudsCompletionHandler _Nullable)completion;
/// 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.
- (void)stopAIAudioRecordingWithScene:(enum AIBudsRecordingScene)scene
completion:(AIBudsCompletionHandler _Nullable)completion;
@endÖrnek Yöntemleri
| Yöntem | Amaç |
|---|---|
startAIAudioRecording | Belirli bir senaryo için AI kaydını başlatır. |
stopAIAudioRecording | Belirli senaryonun AI kaydını durdurur. |
Kayıt Senaryoları
| Swift | Objective-C | Açıklama |
|---|---|---|
.onSite | AIBudsRecordingSceneOnSite | Ortam veya yerinde kayıt. |
.call | AIBudsRecordingSceneCall | Telefon 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
- Objective-C
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")
}
}#import <AIBuds/AIBuds-Swift.h>
#import <AIBuds/AIBuds.h>
id<AIBudsDeviceAudioRecordingAPI> device = (id<AIBudsDeviceAudioRecordingAPI>)self.device;
if (![device conformsToProtocol:@protocol(AIBudsDeviceAudioRecordingAPI)]) {
NSLog(@"Device does not support audio recording");
return;
}
AIBudsRecordingScene scene = AIBudsRecordingSceneOnSite;
[device startAIAudioRecordingWithScene:scene
completion:^(BOOL success, NSError *_Nullable error) {
if (!success) {
NSLog(@"AI recording failed to start: %@",
error.localizedDescription);
return;
}
NSLog(@"AI recording started");
}];
// Stop using the same scene.
[device stopAIAudioRecordingWithScene:scene
completion:^(BOOL success, NSError *_Nullable error) {
if (!success) {
NSLog(@"AI recording failed to stop: %@",
error.localizedDescription);
}
}];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.