assets
to a private directory of your application, such as context.getFilesDir() + "/my_models_dir/audio2exp"
. Then, call the init(String modelPath)
API of Audio2ExpApi
, passing in context.getFilesDir() + "/my_models_dir"
.
You can find the model files at the following location of the SDK package:
API | Description |
public int Audio2ExpApi.init(String modelPath); | Initializes the SDK. You need to pass in the path of the model files. 0 indicates the initialization is successful. |
public float[] Audio2ExpApi.parseAudio(float[] inputData); | The input is audio, which must be one-channel and have a sample rate of 16 Kbps and an array length of 267 (267 sampling points). The output is a float array with 52 elements, which correspond to 52 blendshapes. The value range of each element is 0-1, and their sequence is specified by Apple {"eyeBlinkLeft","eyeLookDownLeft","eyeLookInLeft","eyeLookOutLeft","eyeLookUpLeft","eyeSquintLeft","eyeWideLeft","eyeBlinkRight","eyeLookDownRight","eyeLookInRight","eyeLookOutRight","eyeLookUpRight","eyeSquintRight","eyeWideRight","jawForward","jawLeft","jawRight","jawOpen","mouthClose","mouthFunnel","mouthPucker","mouthRight","mouthLeft","mouthSmileLeft","mouthSmileRight","mouthFrownRight","mouthFrownLeft","mouthDimpleLeft","mouthDimpleRight","mouthStretchLeft","mouthStretchRight","mouthRollLower","mouthRollUpper","mouthShrugLower","mouthShrugUpper","mouthPressLeft","mouthPressRight","mouthLowerDownLeft","mouthLowerDownRight","mouthUpperUpLeft","mouthUpperUpRight","browDownLeft","browDownRight","browInnerUp","browOuterUpLeft","browOuterUpRight","cheekPuff","cheekSquintLeft","cheekSquintRight","noseSneerLeft","noseSneerRight","tongueOut"} |
public int Audio2ExpApi.release(); | Releases resources. Call this API when you no longer need the capability. |
@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);findViewById(R.id.button).setOnClickListener(new OnClickListener() {@Overridepublic void onClick(View view) {TELicenseCheck.getInstance().setTELicense(MainActivity.this, licenseUrl, licenseKey, new TELicenseCheckListener() {@Overridepublic void onLicenseCheckFinish(int errorCode, String s) {Log.d(TAG, "onLicenseCheckFinish: errorCode = "+errorCode+",msg="+s);if (errorCode == TELicenseCheck.ERROR_OK) {//license check successAudio2ExpApi audio2ExpApi = new Audio2ExpApi();int err = audio2ExpApi.init(MainActivity.this.getFilesDir() +"/models");Log.d(TAG, "onLicenseCheckFinish: err="+err);//TODO start record and parse audio data} else {// license check failed}}});}});}
com.tencent.demo.avatar.audio.AudioCapturer
.com.tencent.demo.avatar.activity.Audio2ExpActivity
and its related classes.
Was this page helpful?