Skip to main content

API Reference

DubbingEngine

prepare

Prepares the resources required by the engine and performs authentication. The first time it is called, it downloads the voice model files, which takes a longer time.

getVoiceList

Gets the list of available voice tones. The list of available voice tones will only be returned after the engine is prepared.

Return value: json:[{"id":10, "name":"xx"},{"id":11, "name":"xxx"}], the voice list may be empty.

getCurrentVoice

Gets the currently set voice. Return value: Voice id, may be 0.

start

Starts the voice conversion.

stop

Stops the voice conversion, but does not exit the voice conversion thread. After executing this method, the data in the thread is cleared, and the thread goes to sleep.

getEngineStatus

Gets the current status of the engine.

setVoice(voiceId: int)

When calling this method, it first checks if the model required for the voice tone has been loaded. If not, it loads the model into memory.

Sets the voice. This operation is asynchronous, and the result is returned in the DubbingCallback callback.

Note: It can only be set successfully after the engine is prepared. It can be set whether voice conversion is currently active or not. For example, if voice conversion is active, the sound will immediately change to the new voice tone upon successful setting.

releaseEngine

Releases the engine resources and terminates the thread.

transform(originData: char* data, int dataSize): bool?

Converts the audio data. Input: originData: char* data, int dataSize . Returns: bool (converted data).

checkResources

Checks if required resource files need to be downloaded.

setMode

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

setMode(mode: DubbingMode, intonation: Float, pitch: Float)
Parameter NameParameter TypeDescription
mode[DubbingMode]Mode enumeration
intonationfloatEmotional fluctuation / Intonation
pitchfloatPitch

getSupportIntonation

Checks if the current voice supports intonation adjustment.

getSupportPitch

Checks if the current voice supports pitch adjustment.

getMode

Gets the current engine mode setting.

getIntonation

Gets the current intonation value.

getPitch

Gets the current pitch value.

proCalibration

Performs calibration for Pro mode.

getDelayMillis(): int

Gets the processing delay (latency) in milliseconds. Returns: int.

EngineConfig Default Values Description

Parameter NameParameter TypeDefault ValueDescription
m_dubbbingCallBackIDubbbingCallBacknullptrEngine event callback
m_sampleRateint48000Input Sample Rate
m_channelint1Default channel count
m_formatAudioSampleFormatAUDIO_PCM_S16Default audio format.
m_tokenstd::string""Authentication token, obtained by the developer.
m_resourcePathstd::stringdubbing_resourceThe default value is obtained via the following code: ${context?.filesDir}/dubbing_resource.
m_muteOnFailbooltrueWhether to mute when voice transformation fails.
m_enableLogboolfalseWhether to print engine operation Log.
m_enableTransformLogboolfalseWhether to print engine voice transformation process Log. Enabling this will greatly increase the Log output volume.
m_isSyncboolfalseWhether to perform synchronous transform.

EngineConfig(context: Context)

Constructor.

enableLog (Optional)

Enables Log printing, which only prints process information during engine operation.

enableTransformLog (Optional)

Enables voice transformation Log. Voice transformation is a high-frequency operation, and enabling this will cause the Log information to refresh quickly.

enableTransformLog(TransformDebugHelper) (Optional)

Effect is the same as transformLog(), and the helper will record various time data of the voice transformation.

token

Authentication token, issued by the server.

sampleRate (Optional)

Sample Rate. The default value is 48000. Common optional values include 16000, 24000, and 48000.

DubbingCallback(callback) (Optional)

Dubbing Callback.

Parameter NameParameter TypeDescription
callbackDubbingCallback Interface/** Downloads progress * @param percent Current download file progress, integer from 0-100, 100 means current file download is complete * @param index The index of the current file being downloaded, starting from 1 * @param count The total number of files to be downloaded */ fun onDownload(percent: Int , index: Int, count: Int)
/** Event change * @param action Event * @param code Event result * @param msg Message */ fun onActionResult(action: DubbingAction, code: DubbingRetCode, msg: std::string)

muteOnFail

Whether to mute when voice transformation fails.

DubbingEngineCallback

onDownload(percent: Int, index: Int, count: Int)

Parameter NameParameter TypeDescription
percentintCurrent file download progress, ranging from 0 to 100. 100 means 100%.
indexintThe index of the current file being downloaded, starting from 1.
countintThe total number of files to be downloaded.

onActionResult(action: DubbingAction, code: DubbingRetCode, msg: std::string)

Parameter NameParameter TypeDescription
actionDubbingAction EnumEvent type.
codeDubbingRetCode EnumEvent result.
msgstd::stringEvent message, may be null.

DubbingAction

Enum ValueDescription
SET_VOICESet voice.
AUTHAuth action.
PREPAREPrepare engine.
CHECK_RESOURCESCheck file.
PRO_CALIBRATIONPro mode calibration.

DubbingRetCode

Enum ValueDescription
SUCCESSSuccess.
UNKNOWN_ERRORUnknown error.
NET_REQUEST_ERRORNetwork Error.
NET_AUTH_ERRORAuthentication failed.
LIC_ERRORAuthentication failed.
ENGINE_STATUS_ERRORThe current engine status does not support this operation.
RESOURCE_MISSING_FILESMissing files.
VOICE_SETTINGA voice already in the process of being set.
VOICE_NOT_SETVoice not set.

DubbingEngineStatus

Enum ValueDescription
IDLEInstance successfully created.
PREPARINGEngine resources are being prepared.
PREPAREDEngine resources are ready.
STARTEDVoice transformation started.
STOPPEDVoice transformation stopped.
RELEASEDEngine has been released.
ERROREngine error.
CHECKINGResource files are being checked.
CALIBRATINGAuto calibration is in progress.

DubbingMode

Enum ValueDescription
NORMAL_MODENormal mode.
PRO_MODEPro mode.