1,TTS播报相关
1.1 简单音色切换
//天琴内置的音色有【女神】和【男神】,示例如下:
AiLitContext.getSpeechManager().setTtsResource(SpeakInfo.SPEAKER_FEMALE_LZL);//【音色名:zhilingf】
AiLitContext.getSpeechManager().setTtsResource(SpeakInfo.SPEAKER_MAN_GDG);//【音色名:gdgm】
1.2 高级音色切换
//可支持音色的属性进行配置,传入的是一个json文本,示例如下:
JSONObject jsonObject = new JSONObject();
jsonObject.put("name","zhilingf");//音色名
jsonObject.put("speed","1.1"); //播报语速
jsonObject.put("volume","100"); //合成音大小
// jsonObject.put("mode","local");//如果是云端音色传cloud,默认本地音色local
// jsonObject.put("type","custom");//如果是复刻的音色,需要标明type是 custom,默认非复刻音色
jsonObject.put("respath","/sdcard/xxx/zhilingf.bin"); //资源路径
AiLitContext.getSpeechManager().setTtsResource(jsonObject.toString());
1.3 当前的音色名获取
//返回值即是上述2种方式设置的音色名
AiLitContext.getSpeechManager().getTtsResource();
1.4 语速设置
// TTS 播报速度设置 值一般是1.0f[范围0-2],越大速度越快,越小速度越慢
AiLitBusiness.getSettingManager().setFloat(SettingKeys.SPEECH_TTS_SPEED, 1.0f);
1.5 播报风格设置
//播报风格需要在DUI上配置,天琴支持进行播报风格的切换
JSONObject valueObj =new JSONObject();
valueObj.put("ttsStyle", "emotion");//情感:emotion,极致:ultra
HashMap<String,String> cinfoMap =new HashMap<>();
cinfoMap.put("isProductContext","true");
JSONObject jsonObject=new JSONObject(cinfoMap);
AiLitBusiness.getSettingManager().setString( SettingKeys.SPEECH_CINFO_CONFIG,jsonObject.toString());