Installation
- Swift Package Manager
- CocoaPods
- Manual
https://github.com/spatius-ai/avatarkit-ios-release.git, and select the latest stable release.AvatarSDK
Main initialization and configuration interface for AvatarKit.Type Properties
appID
appID
configuration
configuration
sessionToken
sessionToken
userID
userID
version
version
Type Methods
initialize(appID:configuration:)
initialize(appID:configuration:)
appID: The app identifierconfiguration: The configuration for AvatarKit
setRenderQuality(_:)
setRenderQuality(_:)
setRenderResolutionCap(enabled:maxHeight:)
setRenderResolutionCap(enabled:maxHeight:)
isDeviceSupported()
isDeviceSupported()
deviceScore()
deviceScore()
AvatarManager
Manage avatar asset loading, caching, and retrieval.Type Properties
Instance Methods
load(id:useCompressedModel:onProgress:)
load(id:useCompressedModel:onProgress:)
id: The avatar identifieruseCompressedModel: Load the smaller compressed model variantonProgress: Optional progress callback
Avatar instance.cancelLoading(id:)
cancelLoading(id:)
id: The avatar identifier
cancelAllLoading()
cancelAllLoading()
retrieve(id:)
retrieve(id:)
id: The avatar identifier
Avatar if available, otherwise nil.derive(assetPath:)
derive(assetPath:)
assetPath: The path to the avatar asset
Avatar instance.clear(id:)
clear(id:)
id: The avatar identifier to clear
clearAll()
clearAll()
clearLRU(keepCount:)
clearLRU(keepCount:)
keepCount: Number of most recently used avatars to keep
getCacheSize(id:)
getCacheSize(id:)
id: The avatar identifier
getAllCacheSize()
getAllCacheSize()
AvatarController
The main controller for managing avatar driving service connections and interactions.Instance Properties
onConnectionState
onConnectionState
onConversationState
onConversationState
onError
onError
start()
start()
close()
close()
pause()
pause()
resume()
resume()
interrupt()
interrupt()
send(_:end:)
send(_:end:)
data: The audio data to sendend: Whether this is the end of the audio stream
yieldAudioData(_:end:)
yieldAudioData(_:end:)
data: The audio dataend: Whether this is the end of the audio stream
yieldFramesData(_:conversationID:)
yieldFramesData(_:conversationID:)
frames: Array of encoded motion data payloadsconversationID: The identifier returned by the matchingyieldAudioData()call
pointCount
pointCount
volume
volume
AvatarView
A UIView subclass for rendering avatars.Initializers
init(avatar:)
init(avatar:)
avatar: The avatar to display
Instance Properties
controller
controller
onFirstRendering
onFirstRendering
avatarTransform
avatarTransform
Instance Methods
pauseRendering()
pauseRendering()
resumeRendering()
resumeRendering()
isRenderingEnabled()
isRenderingEnabled()
getBoundingRect()
getBoundingRect()
Render over an Avatar Background
Download the optional 16:9 background from Spatius Studio and add it to the Asset Catalog. Place the image andAvatarView in the same ZStack, with the image first. AvatarView is transparent by default, so the background shows through.
Avatar
Represents an avatar instance.Configuration
Configuration for AvatarKit.Initializers
init(region:audioFormat:drivingServiceMode:logLevel:renderQuality:)
init(region:audioFormat:drivingServiceMode:logLevel:renderQuality:)
region: The region to connect to. Defaults to"auto": the SDK selects the closest serving region at initialization and reuses the cached choice on later launches. Pass"us-west","ap-northeast", or"cn-beijing"to force that region. If automatic selection cannot be reached, the SDK falls back to a default region and continues initializing.audioFormat: The audio format configurationdrivingServiceMode: The driving service modelogLevel: The log levelrenderQuality: Render quality tier
AudioFormat
Audio format configuration for AvatarKit.Initializers
init(sampleRate:inputAudioFormat:opusBitrate:opusUplinkEnabled:)
init(sampleRate:inputAudioFormat:opusBitrate:opusUplinkEnabled:)
sampleRate: The audio sample rate in Hz. Defaults to 16000. Supported: 8000, 16000, 22050, 24000, 32000, 44100, 48000. Not used wheninputAudioFormatis.opus: Opus always decodes at 48 kHz, so the session runs at 48000.inputAudioFormat: The codec of the audio you feed into the SDK viasendoryieldAudioData..pcm(default) for raw PCM16,.opusfor Opus. Fixed for the whole session; audio that does not match is reported asAvatarError.invalidAudioInput.opusBitrate: Target bitrate in bits/sec for the uplink the SDK encodes. Defaults to 48000. Higher means better quality and a larger upload.opusUplinkEnabled: Whether the SDK compresses the direct mode uplink to Opus. On by default, which reduces the upload to roughly an eighth at the cost of encoding on the client. Setfalseto keep a raw PCM uplink. Not used in.backendmode, which has no uplink, or with Opus input, which is already compressed. With PCM input,sampleRatemust be 8000, 16000, 24000, or 48000; on any other rate the SDK logs a warning and sends raw PCM instead of failing to initialize.
DrivingServiceMode
Driving service modes for AvatarKit.AudioCodec
Codec of the audio the host feeds into the SDK.RenderQuality
Render quality tiers for AvatarKit.FrameStarvationMode
Controls playback behavior when motion data cannot keep up with the audio clock.LogLevel
Log levels for AvatarKit.ConnectionState
Connection states for AvatarKit.ConversationState
Conversation states for AvatarKit.Transform
Transform for avatar content rendering.Initializers
init(x:y:scale:)
init(x:y:scale:)
x: The x-axis translationy: The y-axis translationscale: The scale factor

