-
Notifications
You must be signed in to change notification settings - Fork 0
Ai Select Provider
Register the AI provider SDKs included by your app, then select the provider that AIBudsAISDK uses for subsequent AI operations.
- The base AIBuds SDK is initialized.
- At least one provider SDK is installed and linked by the app.
- The selected provider is included in the array passed to
AIBudsAISDK.initialize(_:). - Device information is configured before provider authentication or device-dependent AI operations.
AIBudsAI.xcframework
Provider implementations are distributed separately, including AIBudsStarBurst.xcframework and AIBudsMagicHelper.xcframework.
import AIBudsAI
import AIBudsAIFoundation
import AIBudsStarBurst
import AIBudsMagicHelper#import <AIBudsAI/AIBudsAI-Swift.h>
#import <AIBudsStarBurst/AIBudsStarBurst-Swift.h>
#import <AIBudsMagicHelper/AIBudsMagicHelper-Swift.h>The provider lifecycle is managed by AIBudsAISDK. Provider implementations conform to AIConnectSDK.
/// Initializes the SDK with the specified provider implementations.
/// - Parameter aiSDKs: The providers to register. Their order determines
/// recognition priority; a later provider using an already-registered
/// Bluetooth data protocol type is ignored.
/// - Returns: `true` when initialization succeeds; otherwise `false`.
static func initialize(_ aiSDKs: [AIConnectSDK]) -> Bool
/// The current AI service vendor.
static var aiServiceVendor: AIServiceVendor { get }
/// Sets the AI service vendor for the SDK.
/// - Parameter aiServiceVendor: The vendor used by subsequent AI services.
/// - Important: Call this method before using AI service-dependent functionality.
static func setAIServiceVendor(_ aiServiceVendor: AIServiceVendor)
/// Returns all languages supported by the specified vendor.
/// - Parameter vendor: The vendor whose languages are requested.
/// - Returns: Supported languages, or an empty array when the vendor is `.none`
/// or its provider SDK is not registered.
static func allSupportedLanguages(
for vendor: AIServiceVendor
) -> [AIServiceLanguage]
/// Returns the authentication initiation mode for the specified vendor.
/// - Parameter vendor: The vendor whose authentication mode is requested.
/// - Returns: The provider authentication mode.
static func authenticationMode(
for vendor: AIServiceVendor
) -> AIAuthenticationMode
/// Indicates whether the device is authenticated for the specified vendor.
/// - Parameter vendor: The vendor whose authentication state is requested.
/// - Returns: `true` when the provider reports an authenticated device.
static func isAuthenticated(for vendor: AIServiceVendor) -> Bool/// Initializes the SDK with the specified provider implementations.
/// - Parameter aiSDKs: The providers to register. Their order determines
/// recognition priority; a later provider using an already-registered
/// Bluetooth data protocol type is ignored.
/// - Returns: `YES` when initialization succeeds; otherwise `NO`.
+ (BOOL)initWithAISDKs:
(NSArray<id<AIBudsAIConnectSDK>> *)aiSDKs;
/// The current AI service vendor.
@property (nonatomic, class, readonly)
AIBudsAIServiceVendor aiServiceVendor;
/// Sets the AI service vendor for the SDK.
/// - Parameter aiServiceVendor: The vendor used by subsequent AI services.
/// - Important: Call this method before using AI service-dependent functionality.
+ (void)setAIServiceVendor:
(AIBudsAIServiceVendor)aiServiceVendor;
/// Returns all languages supported by the specified vendor.
/// - Parameter vendor: The vendor whose languages are requested.
/// - Returns: Supported languages, or an empty array when the vendor is
/// `AIBudsAIServiceVendorNone` or its provider SDK is not registered.
+ (NSArray<AIBudsAIServiceLanguage *> *)allSupportedLanguagesForVendor:
(AIBudsAIServiceVendor)vendor;
/// Returns the authentication initiation mode for the specified vendor.
/// - Parameter vendor: The vendor whose authentication mode is requested.
/// - Returns: The provider authentication mode.
+ (AIBudsAIAuthenticationMode)authenticationModeForVendor:
(AIBudsAIServiceVendor)vendor;
/// Indicates whether the device is authenticated for the specified vendor.
/// - Parameter vendor: The vendor whose authentication state is requested.
/// - Returns: `YES` when the provider reports an authenticated device.
+ (BOOL)isAuthenticatedForVendor:
(AIBudsAIServiceVendor)vendor;| Swift | Objective-C | Description |
|---|---|---|
.none |
AIBudsAIServiceVendorNone |
No provider is selected. This is the default state. |
.starBurst |
AIBudsAIServiceVendorStarBurst |
StarBurst AI (ByteDance). |
.mltcloud |
AIBudsAIServiceVendorMltcloud |
MltCloud AI (Meilc). |
See AIServiceVendor for the authoritative enumeration.
Provider registration normally occurs once during application startup.
import AIBudsAI
import AIBudsStarBurst
import AIBudsMagicHelper
let initialized = AIBudsAISDK.initialize([
StarBurstSDK.shared,
MagicHelperSDK.shared,
])
guard initialized else {
print("AIBudsAISDK initialization failed")
return
}#import <AIBudsAI/AIBudsAI-Swift.h>
#import <AIBudsStarBurst/AIBudsStarBurst-Swift.h>
#import <AIBudsMagicHelper/AIBudsMagicHelper-Swift.h>
BOOL initialized = [AIBudsAISDK initWithAISDKs:@[
[AIBudsStarBurstSDK shared],
[AIBudsMagicHelperSDK shared],
]];
if (!initialized) {
NSLog(@"AIBudsAISDK initialization failed");
return;
}If your app uses AIBudsAllInOneSDK, its initialization can install the bundled AI providers. Do not initialize AIBudsAISDK a second time.
let vendor: AIServiceVendor = .starBurst
AIBudsAISDK.setAIServiceVendor(vendor)
print("Selected provider: \(AIBudsAISDK.aiServiceVendor)")
print("Supported languages: \(AIBudsAISDK.allSupportedLanguages(for: vendor))")AIBudsAIServiceVendor vendor = AIBudsAIServiceVendorStarBurst;
[AIBudsAISDK setAIServiceVendor:vendor];
NSLog(@"Selected provider: %ld", (long)AIBudsAISDK.aiServiceVendor);
NSLog(@"Supported languages: %@",
[AIBudsAISDK allSupportedLanguagesForVendor:vendor]);After configuring the connected device's AI information, authenticate providers whose mode is app initiated.
let vendor = AIBudsAISDK.aiServiceVendor
if AIBudsAISDK.authenticationMode(for: vendor) == .appInitiated,
!AIBudsAISDK.isAuthenticated(for: vendor) {
AIBudsAISDK.authenticateDevice(deviceInfo) { success, error in
guard success else {
print(error?.localizedDescription ?? "Authentication failed")
return
}
print("AI provider authenticated")
}
}AIBudsAIServiceVendor vendor = AIBudsAISDK.aiServiceVendor;
if ([AIBudsAISDK authenticationModeForVendor:vendor] ==
AIBudsAIAuthenticationModeAppInitiated &&
![AIBudsAISDK isAuthenticatedForVendor:vendor]) {
[AIBudsAISDK authenticateDevice:deviceInfo
completion:^(BOOL success, NSError *error) {
if (!success) {
NSLog(@"%@", error.localizedDescription ?: @"Authentication failed");
return;
}
NSLog(@"AI provider authenticated");
}];
}-
setAIServiceVendor(_:)does not register or install a provider SDK. - Selecting
.noneleaves AI service-dependent operations without a usable provider. - Calling
initialize(_:)more than once returnsfalseand keeps the existing initialization. - If duplicate implementations declare the same provider enum value, the first registered implementation is retained.
- Supported features and languages can differ between providers.
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