Skip to main content

API Reference

DBSDKManager​

prepare​

Prepares the resources required by the engine and performs authentication. The first call will download voice model files, which may take a long time.

getVoiceList​

Gets the list of available voices. Only returns available voices after the engine is prepared.

Returns: NSArray<DBSpeakerItem *>, the list may be empty.

getCurrentVoice​

Gets the currently set voice.
Returns: Voice ID, may be nil.

cleanAllFiles​

Deletes voice model files. After calling this method, these files will be re-downloaded the next time prepare() is called.

Returns: void
Note: The engine automatically cleans up unnecessary files. Do not store other files in the engine's file directory.

start​

Starts voice transformation.

stop​

Stops voice transformation, but does not exit the voice transformation thread. After calling this method, the data in the thread will be cleared and the thread will enter a sleep state.

getEngineStatus​

Gets the current engine status.

setVoice(voiceId: NSNumber)​

When calling this method, it first checks whether the model required for this voice has been loaded; if not loaded, it will load the model into memory first.

Sets the voice. This operation is asynchronous, and the result will be returned through the DBActionResultBlock callback.

Note: Can only be set successfully after the engine is prepared. The voice can be set regardless of whether voice transformation is currently in progress. For example, during voice transformation, after successful setting, the voice will immediately switch to the new voice.

releaseEngine​

Releases engine resources and terminates the thread.

transform(data: NSData): NSData?​

Transforms audio data.
Input: data: NSData
Returns: NSData? (transformed data)

checkResources​

Checks whether required resource files need to be downloaded.

setMode​

Sets the engine processing mode (e.g., Pro mode).

setMode(mode: DubbingMode, intonation: Float, pitch: Float)
ParameterTypeDescription
modeDubbingModeMode enumeration
intonationfloatEmotional variation / Intonation
pitchfloatPitch

getSupportIntonation​

Checks whether the current voice supports intonation adjustment.

getSupportPitch​

Checks whether the current voice supports pitch adjustment.

getMode​

Gets the current engine mode settings.

getIntonation​

Gets the current intonation value.

getPitch​

Gets the current pitch value.

proCalibration​

Performs Pro mode calibration.

DBSDKManager Default Parameters​

ParameterTypeDefault ValueDescription
onActionResultDBActionResultBlocknilEngine event callback
sampleRateNSInteger48000Sample rate
tokenNSString *nilAuthentication Token, obtained by the developer
debugBOOLNOWhether to print engine runtime logs
transformDebugBOOLNOWhether to print voice transformation logs. Enabling this will significantly increase log output
muteOnFailBOOLYESWhether to mute when voice transformation fails
channelNSInteger1Default number of channels
formatDBAudioSampleFormatAUDIO_PCM_S16Default audio format
isSyncBOOLNOWhether to enable synchronous transformation

EngineConfig​

EngineConfig()​

Constructor.

defaultConfig​

Creates a default configuration instance.

debug​

Enables log printing, only outputs log information during engine runtime.

transformDebug​

Enables voice transformation logs. Voice transformation is a high-frequency operation, enabling this will result in faster log refresh rates.

token​

Authentication Token, issued by the server.

sampleRate​

Sample rate, default value is 48000. Common optional values include 16000, 24000, 48000.

onActionResult​

Engine callback.

muteOnFail​

Whether to mute when voice transformation fails.

isSync​

Whether to enable synchronous transformation.

channel​

Number of audio channels.

format​

Audio format settings.

onDownload​

Download progress callback.

DBDownloadProgressBlock​

onDownload(percent: NSInteger, index: NSInteger, count: NSInteger)​

ParameterTypeDescription
percentNSIntegerCurrent file download progress (0–100)
indexNSIntegerCurrent downloading file index, starting from 1
countNSIntegerTotal number of files to download

DBActionResultBlock​

onActionResult(action: DubbingAction, code: DubbingEngineCode, msg: String?)​

ParameterTypeDescription
actionDubbingAction enumEvent type
codeDubbingEngineCode enumEvent result
msgNSString *Event message, may be nil

DubbingAction​

Enum ValueDescription
SET_VOICESet voice
AUTHAuthentication
PREPAREPrepare engine
CHECK_RESOURCESCheck resource files
PRO_CALIBRATIONPro mode calibration

DubbingEngineCode​

Enum ValueDescription
SUCCESSSuccess
UNKNOWN_ERRORUnknown error
NET_REQUEST_ERRORNetwork error
NET_AUTH_ERRORAuthentication failed
LIC_ERRORAuthentication failed
ENGINE_STATUS_ERRORCurrent engine status does not support this operation
RESOURCE_MISSING_FILESMissing resource files
VOICE_SETTINGVoice is being set
VOICE_NOT_SETVoice not set

DubbingEngineStatus​

Enum ValueDescription
IDLEInstance created successfully
PREPARINGPreparing engine resources
PREPAREDEngine resources ready
STARTEDVoice transformation started
STOPPEDVoice transformation stopped
RELEASEDEngine released
ERROREngine error
CHECKINGChecking resource files
CALIBRATINGPerforming automatic calibration

DBSpeakerItem​

Member VariableDescription
idVoice ID
nameVoice name

DubbingMode​

Enum ValueDescription
NORMAL_MODENormal mode
PRO_MODEPro mode