GJLocalDigitalSDK.framework (-Embed & Sign)
1.下载GJLocalDigitalSDKDemo_1.1.0.zip
2.解压zip包,找到GJLocalDigitalSDK.framework包,将SDK包集成到您的工程项目并设置 (-Embed & Sign)
开发⼯具: Xcode ios12.0以上 iphoneX及以上
//授权
[[GJLDigitalManager manager] initWithAppId:APPID appKey:APPKEY conversationId:CONVERSATIONID block:^(BOOL isSuccess, NSString *errorMsg) {
if(isSuccess)
{
NSString *basePath =[NSString stringWithFormat:@"%@/%@",[[NSBundle mainBundle] bundlePath],@"gj_dh_res"];
NSString *digitalPath =[NSString stringWithFormat:@"%@/%@",[[NSBundle mainBundle] bundlePath],@"lixin_a_540s"];
//初始化
NSInteger result= [[GJLDigitalManager manager] initBaseModel:basePath digitalModel:digitalPath showView:weakSelf.showView];
if(result==1)
{
//开始
[[GJLDigitalManager manager] toStart:^(BOOL isSuccess, NSString *errorMsg) {
if(!isSuccess)
{
[SVProgressHUD showInfoWithStatus:errorMsg];
}
}];
}
}
else
{
[SVProgressHUD showInfoWithStatus:errorMsg];
}
}];
1. 启动服务前需要准备好授权的appId,appKey以及同步数字人需要的基础配置和模型文件。
2. 使用授权接口授权。
3. 初始化数字人渲染服务。
4. 调用toStart函数开始渲染数字人
5. 调用toSpeakWithPath函数驱动数字人播报。
6. 调用cancelAudioPlay函数可以主动停止播报。
7. 调用toStop结束并释放数字人渲染
/*
*数字人渲染报错回调
*0 未授权 -1未初始化 50009资源超时或未配置
*/
@property (nonatomic, copy) void (^playFailed)(NSInteger code,NSString *errorMsg);
/*
*音频播放结束回调
*/
@property (nonatomic, copy) void (^audioPlayEnd)(void);
/*
*音频播放进度回调
/
@property (nonatomic, copy) void (^audioPlayProgress)(float current,float total);
/*
*相机回调
*/
@property (nonatomic, copy) void (^captureBlock)(CMSampleBufferRef sampleBuffer ,AVMediaType type);
/*
*授权
*appsign 根据appID和appkey生成的appsign
*isSuccess YES 返回成功 NO返回失败
*errorMsg 错误原因
*/
- (void)initWithAppSign:(NSString *)appsign conversationId:(NSString*)conversationId block:(void (^) (BOOL isSuccess, NSString *errorMsg))block;
/*
*appId 对应应用的APPID
*appKey 对应应用的密钥
*isSuccess YES 返回成功 NO返回失败
*errorMsg 错误原因
*/
- (void)initWithAppId:(NSString *)appId appKey:(NSString *)appKey block:(void (^) (BOOL isSuccess, NSString *errorMsg))block;
/*
*basePath 底层通用模型路径-保持不变
*digitalPath 数字人模型路径- 替换数字人只需要替换这个路径
*return 1 返回成功 0未授权 -1 初始化失败
*showView 显示界面
*/
-(NSInteger)initBaseModel:(NSString*)basePath digitalModel:(NSString*)digitalPath showView:(UIView*)showView;
/*
* bbgPath 替换背景
* 注意: -jpg格式 ----背景size等于数字人模型的getDigitalSize-----------
*/
-(void)toChangeBBGWithPath:(NSString*)bbgPath;
/*
*wavPath 音频的本地路径
*/
-(void)toSpeakWithPath:(NSString*)wavPath;
/*
*开始
*/
-(void)toStart:(void (^) (BOOL isSuccess, NSString *errorMsg))block;
/*
*结束
*/
-(void)toStop;
/*
*初始化模型过后才能获取
*getDigitalSize 数字人模型的宽度 数字人模型的高度
*/
-(CGSize)getDigitalSize;
/*
*取消播放音频
*/
-(void)cancelAudioPlay;
/*
*文字驱动数字人说话
*content 文字
*conversationId 会话ID
*/
-(void)toSpeakWithText:(NSString*)content conversationId:(NSString*)conversationId success:(void (^) (NSString *wavPath))success failure:(void (^)(NSString *errorStr))failure;
/*
*问答
*question 问题
*conversationId 会话ID
*isWav 是否需要返回tts合成好的音频地址
*extContext 拓展字段,json字符串 默认为空
*userId 用户ID 默认nil
*/
-(void)toAnswer:(NSString*)question conversationId:(NSString*)conversationId isWav:(BOOL)isWav extContext:(NSString *)extContext userId:(NSString*)userId success:(void (^) (NSDictionary *answerMsg))success failure:(void (^)(NSDictionary *errorMsg))failure;
/*
*问答 + 图片多模态
*question 问题
*conversationId 会话ID
*isWav 是否需要返回tts合成好的音频地址 默认YES
*extContext 拓展字段,json字符串 默认为空
*userId 用户ID 默认nil
*image 上传的图片
*/
-(void)toAnswer:(NSString*)question conversationId:(NSString*)conversationId isWav:(BOOL)isWav extContext:(NSString *)extContext userId:(NSString*)userId image:(UIImage*)image success:(void (^) (NSDictionary *answerMsg))success failure:(void (^)(NSDictionary *errorMsg))failure;
/*
*生成问题ID
*/
-(NSString *)getQuestionId;
/*
*是否授权成功
*/
-(NSInteger)isGetAuth;
/*
* 开始动作前调用
* 随机动作(一段文字包含多个音频,建议第一个音频开始时设置随机动作)
* return 0 数字人模型不支持随机动作 1 数字人模型支持随机动作
*/
-(NSInteger)toRandomMotion;
/*
* 开始动作 (一段文字包含多个音频,第一个音频开始时设置)
* return 0 数字人模型不支持开始动作 1 数字人模型支持开始动作
*/
-(NSInteger)toStartMotion;
/*
* 结束动作 (一段文字包含多个音频,最后一个音频播放结束时设置)
*isQuickly YES 立即结束动作 NO 等待动作播放完成再静默
*return 0 数字人模型不支持结束动作 1 数字人模型支持结束动作
*/
-(NSInteger)toSopMotion:(BOOL)isQuickly;
/*
*暂停后才需执行播放数字人
*/
-(void)toPlay;
/*
*暂停数字人播放
*/
-(void)toPause;
/*
*打开摄像头
*/
-(void)toOpenCamera;
/*
*切换前后摄像头
*/
- (void)switchCamera;
/*
*关闭摄像头
*/
-(void)toStopCamera;
/*
*初始化录音和ASR
*langType 0 中文 1 英文 2日语
*/
-(void)initASR:(NSInteger)langType;
/*
*开始识别
*/
-(void)toOpenAsr;
/*
*停止识别
*/
-(void)toCloseAsr;
/*
*asrText 识别文字
*isFinish 一句话是否结束
*/
@property (nonatomic, copy) void (^asrBlock)(NSString * asrText,BOOL isFinish);
/*
*data 录音返回 单声道 1 采样率 16000
*/
@property (nonatomic, copy) void (^recordDataBlock)(NSData * data);
/*
*设置initASR langType 0 中文 1 英文 2日语
*langType=0 中文时 rms: 语音能量值,范围为-160至0
*langType=1 英文时 rms: 语音能量值,范围为0至10
*langType=2 日语时 rms: 语音能量值,范围为0至10
*/
@property (nonatomic, copy) void (^rmsBlock)(float rms);
1.1.0
1. 支持多模态
1.0.3
1. 数字人背景透明
2. 解压内存问题
1.0.2
1. 问答
2. 语音识别
3. 文字合成
4. 说话动作
1.0.1
1. 数字人本地授权和初始化
2. 数字人本地渲染
3. 音频播放和驱动嘴形