context.getFilesDir() + "/my_models_dir/audio2exp"
,然后在调用 Audio2ExpApi 的 init(String modelPath)
接口时,传入参数 context.getFilesDir() + "/my_models_dir"
模型文件在 SDK 包里,位置如下:
接口 | 说明 |
public int Audio2ExpApi.init(String modelPath); | 初始化,传入模型路径,见上文说明。返回值为0表示成功 |
public float[] Audio2ExpApi.parseAudio(float[] inputData); | 输入的是音频数据,要求单通道,16K采样率,数组长度为267(即267个采样点),输出的数据是长度为52的float数组,表示52表情基,取值为0到1之间,顺序为 苹果标准顺序 {"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(); | 使用完毕后调用,释放资源 |
@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
及其相关类。
本页内容是否解决了您的问题?