接口 | 说明 |
+ (int)initWithModelPath:(NSString*)modelPath; | 初始化,传入模型路径,见上文说明。返回值为0表示成功 |
+ (NSArray *)parseAudio:(NSArray *)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"} |
+ (int)releaseSdk | 使用完毕后调用,释放资源 |
// 初始化语音转表情sdkNSString *path = [[NSBundle mainBundle] pathForResource:@"audio2exp" ofType:@"bundle"];int ret = [Audio2ExpApi initWithModelPath:path];// 语音数据转52表情数据NSArray *emotionArray = [Audio2ExpApi parseAudio:floatArr];// 释放sdk[Audio2ExpApi releaseSdk];// 结合腾讯特效sdk xmgaic使用// 使用对应的资源初始化美颜sdkself.beautyKit = [[XMagic alloc] initWithRenderSize:previewSize assetsDict:assetsDict];// 加载avatar素材[self.beautyKit loadAvatar:bundlePath exportedAvatar:nil completion:nil];// 将52表情数据传入美颜sdk 就能看到效果[self.beautyKit updateAvatarByExpression:emotionArray];
TXCAudioRecorder
。VoiceViewController
及其相关类。
本页内容是否解决了您的问题?