-
Notifications
You must be signed in to change notification settings - Fork 0
Ai Ai Summary
Mr.P edited this page Aug 25, 2026
·
2 revisions
Generate a concise summary from text and update the UI as the selected provider returns incremental results.
-
AIBudsAISDKis initialized and a registered provider is selected. - The provider supports
AISummaryServiceAPI. - Provider authentication and network access are available when required.
- The input text is non-empty.
AIBudsAI.xcframework
import AIBudsAI#import <AIBudsAI/AIBudsAI-Swift.h>/// Generates a concise summary for the provided text.
/// - Parameters:
/// - text: The text to summarize.
/// - streamResultHandler: Called repeatedly with the current summary.
/// - isFinal: `true` when the summary is complete; otherwise `false`.
/// - transcript: The current incremental summary text.
/// - error: The operation error, or `nil` when no error occurred.
static func summary(
withText text: String,
streamResultHandler: ((
_ isFinal: Bool,
_ transcript: String?,
_ error: Error?
) -> Void)? = nil
)
/// Cancels the current summary operation before it completes.
static func cancelSummary()/// Generates a concise summary for the provided text.
/// - Parameters:
/// - text: The text to summarize.
/// - streamResultHandler: Called repeatedly with the current summary.
/// - isFinal: `YES` when the summary is complete; otherwise `NO`.
/// - transcript: The current incremental summary text.
/// - error: The operation error, or `nil` when no error occurred.
+ (void)summaryWithText:(NSString *)text
streamResultHandler:(void (^ _Nullable)(BOOL isFinal, NSString * _Nullable transcript, NSError * _Nullable error))streamResultHandler;
/// Cancels the current summary operation before it completes.
+ (void)cancelSummary;See summary and cancelSummary.
let sourceText = """
The AIBuds SDK connects supported devices to an iOS application and exposes
device control, media, AI, voice assistant, and diagnostic capabilities.
"""
AIBudsAISDK.summary(withText: sourceText) { isFinal, transcript, error in
DispatchQueue.main.async {
if let error {
summaryLabel.text = "Summary failed: \(error.localizedDescription)"
return
}
if let transcript {
summaryLabel.text = transcript
}
if isFinal {
summaryActivityIndicator.stopAnimating()
}
}
}NSString *sourceText =
@"The AIBuds SDK connects supported devices to an iOS application and "
"exposes device control, media, AI, voice assistant, and diagnostic "
"capabilities.";
[AIBudsAISDK summaryWithText:sourceText
streamResultHandler:^(BOOL isFinal,
NSString *transcript,
NSError *error) {
dispatch_async(dispatch_get_main_queue(), ^{
if (error != nil) {
self.summaryLabel.text = [NSString stringWithFormat:
@"Summary failed: %@", error.localizedDescription];
return;
}
if (transcript != nil) {
self.summaryLabel.text = transcript;
}
if (isFinal) {
[self.summaryActivityIndicator stopAnimating];
}
});
}];Cancel an in-progress request when its result is no longer needed:
AIBudsAISDK.cancelSummary()[AIBudsAISDK cancelSummary];- The API summarizes text only. It does not accept a file path or expose a
maxLengthparameter. - Each transcript can replace the previous displayed value because the provider returns an incrementally growing summary.
- Treat a non-
nilerror as failure even if a transcript was received earlier. -
cancelSummary()does not provide a completion callback; update application state when cancellation is requested.
AIBuds SDK documentation · Full documentation · API Reference
- Introduction
- Getting Started
- Core Concepts
-
Core Features
- Basic Features
- Device Info
- Find Device
- Physical Operations
- Work Mode
- Work Status
- Wear Detection
- Volume Control
- Music Control
- TWS
- Equalizer
- ANC
- Audio
- Camera
- Remote Camera
- File Import
- Teleprompter
- Segment Navigation
- Live Streaming
- Device Applications
- OTA
- Camera OTA
- Service Auth
- AI Services
- Voice Assistant
- Logging
- Advanced Topics
- Releases
- Troubleshooting