System | Support Android 6 and later systems |
Processor Architecture | Support arm64-v8a CPU architecture |
Processor Performance Requirements | Support Qualcomm Snapdragon 8+, HiSilicon Kirin 980+, and MediaTek mt6878+ |
Development IDE | Android Studio |
Memory Requirements | More than 500 MB |
common_model/. If there are multiple character models, they can share one Base Model package.human_xxxxx_540p_v2/, where xxxxx is the name of the custom avatar.
virtualhuman_2d_sdk_v202502071637.aardependencies{implementation fileTree(dir: 'libs', include: ['*.aar'])// add dependencyimplementation'com.squareup.okhttp3:okhttp:4.9.0'implementation 'com.parse.bolts:bolts-tasks:1.4.0'}
// Set log levelVirtualHumanController.setLogLevel(Int level);// Set log callbackVirtualHumanController.setLogCallback(IDataCallback logCallback);
Log level | level Flag |
Close logs | 0 |
Error logs | 1 |
Warning logs | 2 |
Log information | 3 |
Debug Logs | 4 |
Trace logs | 5 |
Parameter Name | Data Type | Parameter Type | Description |
level | int | Required or Not | Log level |
logMsg | String | Required or Not | Log information |
VirtualHumanParam vhParam = new VirtualHumanParam();// local model pathvhParam.humanModelPath = "/data/user/0/com.tencent.virtualhuman_2d_demo/files/test_model/human_model";// local model pathvhParam.commonModelPath = "/data/user/0/com.tencent.virtualhuman_2d_demo/files/test_model/common_model";vhParam.appId = "License appId";vhParam.secretKey = "License secretKey";vhParam.deviceName = "Device tag, recommended to use nameplate info";// error callback functionvhParam.errorCallback = (code, message) -> {Log.d(TAG, "Code: " + code + ", Message: " + message);};// event callback functionvhParam.eventCallback = (code, message) -> {Log.d(TAG, "Code: " + code + ", Message: " + message);};controller = new VirtualHumanController(this, vhParam);int ret = controller.initHuman();if (ret == 0) {controller.setRenderView(virtualHumanView);// set rendering viewcontroller.startHuman();// start rendering} else {Log.i(TAG, "init fail=" + ret);}
Parameter Name | Data Type | Required | Description |
humanModelPath | String | Yes | local model path |
commonModelPath | String | Yes | local general model path |
appId | String | Yes | AppId in License |
secretKey | String | Yes | SecretKey in License |
eventCallback | IDataCallback | No | event callback function event notification |
eventCallback | IDataCallback | Yes | exception callback function, monitor exception messages |
deviceName | String | No | device alias, recommended to use nameplate info |
Parameter Name | Data Type | Required | Description |
code | int | Yes | code |
message | String | Yes | Information |
Error No. | Error Message |
20001 | Algorithm model initialization error. |
20010 | Authentication failed. |
20012 | Insufficient device performance, cannot operate smoothly. |
Error No. | Error Message |
10001 | Broadcast started. |
10002 | Broadcast ended. |
10003 | controller.appendAudioData('audio data', boolean, 'tag'). When calling appendAudioData with a tag parameter, 10003 represents the start event for playing this audio data, and the tag is returned in the callback event. |
10004 | controller.appendAudioData('audio data', boolean, 'tag'). When calling appendAudioData with a tag parameter, 10003 represents the end event for playing this audio data, and the tag is returned in the callback event. |
10005 | The callback event for the first-frame image rendering of Digital Human. |
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"android:orientation="vertical"android:layout_width="match_parent"android:layout_height="match_parent"><LinearLayoutandroid:id="@+id/ll_floating_ball"android:layout_width="180dp"android:layout_height="320dp"android:background="#8f15ab71"android:gravity="center"android:orientation="horizontal"><com.tencent.virtualhuman_2d_sdk.VirtualHumanViewandroid:id="@+id/virtual_human_view"app:TVHFillMode="fill" // render View filling modeandroid:layout_width="match_parent"android:layout_height="match_parent" /></LinearLayout></LinearLayout>
<?xml version="1.0"encoding="utf-8"?><LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"android:orientation="vertical"android:layout_width="match_parent"android:layout_height="match_parent"><LinearLayoutandroid:id="@+id/ll_container"android:layout_width="480dp"android:layout_height="480dp"android:background="#8f15ab71"android:gravity="center"android:orientation="horizontal"></LinearLayout></LinearLayout>
// context is the context of the current Activity interfaceVirtualHumanView virtualHumanView = new VirtualHumanView(context);virtualHumanView.setFillMode(VirtualHumanViewType.fill);LinearLayout ll_container = findViewById(R.id.ll_container);ll_container.addView(virtualHumanView);
VirtualHumanViewType.stretch | Stretch image |
VirtualHumanViewType.fit | Crop image |
VirtualHumanViewType.fill | Keep black border (transparent edge) |
Parameter Name | Data Type | Parameter Type | Description |
virtualHumanView | VirtualHumanView | Required or Not |
controller.setRenderView(virtualHumanView);
Parameter Name | Data Type | Parameter Type | Description |
decodedBytes | Byte[] | Yes | PCM audio data. |
isFinal | Boolean | Yes | Whether it is the audio end frame. |
metaData | String | No | Import the tag corresponding to the audio data. There will be event 10003/10004 when broadcasting the audio fragment. |
controller.appendAudioData(decodedBytes, isFinal);controller.appendAudioData(decodedBytes, isFinal, metaData);
controller.interrupt();
controller.pause();
controller.resume();


Refer to the above text to create a Digital Human controllercontroller = new VirtualHumanController(DemoActivity.this, vhParam);int ret = controller.initHuman();// Initialize Digital Humanif (ret == 0) {2. Not calling setRenderView, start rendering directlycontroller.startHuman();} else {Log.i(TAG, "init fail=" + ret);}Listen to the returned value of errorCallback. If error code 20012 occurs within a period of time, it indicates low performance of the device and cannot ensure smooth operation.
implementation 'com.parse.bolts:bolts-tasks:1.4.0'.vhParam.bindDevice parameter.controller.setRenderView(virtualHumanView); to the following writing style:int ret = controller.initHuman();if (ret == 0) {controller.setRenderView(virtualHumanView);controller.startHuman();} else {Log.i(TAG, "init fail=" + ret);}
Feedback