Commit 544164f3 by 苗权威

09.09

parent e1299aaa
......@@ -167,7 +167,45 @@ public class CallPython {
return "1";
}
public static String soxiGetAudioConfig(String arg) {
ProcessBuilder processBuilder = new ProcessBuilder(arg.split(" "));
processBuilder.redirectErrorStream(true); //错误输出流合并到标准输出流中
StringBuilder builder = new StringBuilder();
Process process = null;
try {
//long startTime = System.currentTimeMillis();
process = processBuilder.start();
process.waitFor();
BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
String line;
if (process.exitValue() != 0) {
while ((line = reader.readLine()) != null) {
builder.append(line);
}
if (builder.length() > 0) {
log.error("soxiGetAudioConfig 执行出错:{}",builder.toString());
return null;
}
} else {
while ((line = reader.readLine()) != null) {
builder.append(line);
}
if (builder.length() != 0){
return builder.toString();
}
}
//log.info(Thread.currentThread().getName()+"耗时:"+(System.currentTimeMillis()-startTime));
} catch (IOException | InterruptedException e) {
log.info("Error while running soxiGetAudioConfig. {}",e.getMessage());
return null;
} finally {
if (process != null) process.destroy();
}
return null;
}
static String ffmpegExecute(String arg) {
// log.warn("ffmpegExecute: "+arg);
ProcessBuilder processBuilder = new ProcessBuilder(arg.split(" "));
processBuilder.redirectErrorStream(true); //错误输出流合并到标准输出流中
StringBuilder builder = new StringBuilder();
......
package ai.qiwu.com.tts_service.common;
/**
* painter
* 20-8-4 下午5:37
*/
public enum ResponseCode {
SUCCESS(1, "成功"),
ERROR(500, "服务器出错"),
SERVER_IS_EXCEPTION(500, "服务器异常"),
PARAM_IS_FAULT(10005, "字段错误"),
USER_NOT_EXIST(20004, "用户不存在"),
USER_AUTHENTICATION_FAIL(20007, "用户认证失败!"),
PASSWORD_WRONG(20008, "密码错误"),
EMAIL_WRONG(20009, "用户名或邮箱地址错误"),
USER_LOGIN_OUT_TIME(20010, "超时请重新登录"),
DATA_IS_WRONG(50002, "数据有误"),
PERMISSION_NO_ACCESS(70001, "无访问权限"),
;
private final Integer code;
private final String desc;
ResponseCode(Integer code, String desc) {
this.code = code;
this.desc = desc;
}
public Integer getCode() {
return code;
}
public String getDesc() {
return desc;
}
}
package ai.qiwu.com.tts_service.common;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import lombok.ToString;
import java.io.Serializable;
/**
* painter
* 20-8-4 下午5:31
*/
@JsonInclude(JsonInclude.Include.NON_NULL)
@ToString
public class ServerResponse<T> implements Serializable {
private static final long serialVersionUID = -3948389268046368059L;
private Integer code;
private String msg;
private T data;
public ServerResponse(){}
private ServerResponse(Integer code){
this.code = code;
}
private ServerResponse(Integer code, T data){
this.code = code;
this.data = data;
}
private ServerResponse(Integer code, String msg, T data){
this.code = code;
this.msg = msg;
this.data = data;
}
private ServerResponse(Integer code, String msg){
this.code = code;
this.msg = msg;
}
@JsonIgnore
//使之不再json序列化结果当中
public boolean isSuccess(){
return this.code.equals(ResponseCode.SUCCESS.getCode());
}
public Integer getCode() {
return code;
}
public String getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
public T getData() {
return data;
}
public static <T> ServerResponse<T> createBySuccess(){
return new ServerResponse<>(ResponseCode.SUCCESS.getCode(),ResponseCode.SUCCESS.getDesc(), null);
}
public static <T> ServerResponse<T> createBySuccessMessage(String msg){
return new ServerResponse<>(ResponseCode.SUCCESS.getCode(), msg);
}
public static <T> ServerResponse<T> createBySuccess(T data){
return new ServerResponse<>(ResponseCode.SUCCESS.getCode(), data);
}
public static <T> ServerResponse<T> createBySuccess(String msg, T data){
return new ServerResponse<>(ResponseCode.SUCCESS.getCode(), msg, data);
}
public static <T> ServerResponse<T> createByError(){
return new ServerResponse<>(ResponseCode.ERROR.getCode(), ResponseCode.ERROR.getDesc());
}
public static <T> ServerResponse<T> createByErrorMessage(String msg){
return new ServerResponse<>(ResponseCode.ERROR.getCode(), msg);
}
public static <T> ServerResponse<T> createByErrorCodeMessage(int errorCode, String errorMessage){
return new ServerResponse<>(errorCode, errorMessage);
}
public static <T> ServerResponse<T> createByErrorEnum(ResponseCode code){
return new ServerResponse<>(code.getCode(), code.getDesc());
}
public static <T> ServerResponse<T> createByErrorEnumAndMsg(ResponseCode code, String msg){
return new ServerResponse<>(code.getCode(), msg);
}
}
......@@ -554,6 +554,20 @@ public class TTSUtils {
return filename;
}
public static Boolean changeAudioConfig(Integer sampleRate, String bitRate, String targetPath) {
try {
String temp = targetPath.substring(0, targetPath.lastIndexOf("."))+"_.mp3";
if ("1".equals(CallPython.ffmpegExecute(new StringBuilder("ffmpeg -i ").append(targetPath).append(" -b:a ")
.append(bitRate).append(" -ar ").append(sampleRate).append(" -y ").append(temp).toString()))) {
Files.move(new File(temp).toPath(), new File(targetPath).toPath(), StandardCopyOption.REPLACE_EXISTING);
return true;
}
} catch (Exception e) {
log.error("changeAudioConfig 修改音频数据出错:sampleRate:{}, bitRate:{}, targetPath:{}, {}", sampleRate, bitRate, targetPath, e);
}
return false;
}
/**
* 合并mp3文件
* @param filePathList 待合并mp3文件列表
......@@ -665,14 +679,14 @@ public class TTSUtils {
return;
}
}
long temp;
// long temp;
// log.warn("sox 切除静音耗时:"+((temp=System.currentTimeMillis())-startMark));
List<String> str = cutedPaths.stream().map(s -> "-i "+s).collect(Collectors.toList());
StringBuilder builder = new StringBuilder("ffmpeg ").append(StringUtils.join(str, " ")).append(" -filter_complex ");
for (int k = 0; k < filePathList.size(); k++) {
builder.append("[").append(k).append(":a:0]");
}
builder.append("concat=n=").append(filePathList.size()).append(":v=0:a=1[a] -map [a] ").append(targetFilepath);
builder.append("concat=n=").append(filePathList.size()).append(":v=0:a=1[a] -map [a] -b:a 64k -y ").append(targetFilepath);
CallPython.ffmpegExecute(builder.toString());
// log.warn("ffmpeg 拼接耗时:"+(System.currentTimeMillis()-temp));
POOL.submit(() -> {
......
package ai.qiwu.com.tts_service.controller;
import ai.qiwu.com.tts_service.common.FileUtil;
import ai.qiwu.com.tts_service.common.ServerResponse;
import ai.qiwu.com.tts_service.common.TTSUtils;
import ai.qiwu.com.tts_service.pojo.*;
import ai.qiwu.com.tts_service.pojo.upload.UploadOneSenData;
import ai.qiwu.com.tts_service.service.*;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.csv.CSVFormat;
import org.apache.commons.csv.CSVPrinter;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.exception.ExceptionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
......@@ -16,16 +21,18 @@ import org.springframework.web.multipart.MultipartHttpServletRequest;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.io.*;
import java.net.URLDecoder;
import java.net.URLEncoder;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardCopyOption;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
/**
......@@ -194,11 +201,103 @@ public class TTSController {
String npcName = mulRequest.getParameter("npcName");
String text = mulRequest.getParameter("text");
String tid = mulRequest.getParameter("tid");
String sampleRate = mulRequest.getParameter("sampleRate");
String bitRate = mulRequest.getParameter("bitRate");
UploadOneSenData data = new UploadOneSenData(Integer.valueOf(tid), botName, npcName, text, file);
data.setBitRate(bitRate);
data.setSampleRate(StringUtils.isBlank(sampleRate) ? 44100 : Integer.parseInt(sampleRate));
ttService.uploadOneSen(data, response, request.getHeader("Authorization"));
}
@PutMapping("/api/upload/record/one_sen")
public ServerResponse updateAudioConfig(@RequestBody UploadOneSenData data) {
return ttService.changeOneSenAudioConfig(data);
}
@GetMapping("/api/upload/record/one_sen")
public ServerResponse getAudioConfig(String botName, String npcName, String text) {
return ttService.getOneSenAudioConfig(botName, npcName, text);
}
// @GetMapping("/api/del/all/up")
public ServerResponse delAllUpAudio() throws IOException {
Set<String> onlinedNames = Initialize.getPersonInfoOnline().keySet().stream().filter(s -> s.length() == 3).collect(Collectors.toSet());
Files.list(Paths.get("/root/TTS-service/audio")).forEach(pt -> {
try {
Files.list(pt).filter(path -> onlinedNames.contains(path.getFileName().toString())).forEach(path -> FileUtil.deleteFile(path.toFile()));
} catch (IOException e) {
log.error(ExceptionUtils.getStackTrace(e));
}
});
return ServerResponse.createBySuccess();
}
// @GetMapping("/api/del/fragment")
public ServerResponse delAllFragment() throws IOException {
List<Path> botAccountPathList = Files.list(Paths.get("/root/TTS-service/audio"))
.filter(path -> !StringUtils.startsWithAny(path.getFileName().toString(), "miao", "mqw", "test", "tmp"))
.collect(Collectors.toList());
for (Path bpt: botAccountPathList) {
List<Path> personPathList = Files.list(bpt).filter(path -> !StringUtils.equalsAny(path.getFileName().toString(), "xiaoai", "record"))
.collect(Collectors.toList());
for (Path ppt: personPathList) {
List<Path> moodPathList =Files.list(ppt).filter(path -> {
boolean result = Files.isDirectory(path);
if (!result) {
try {
Files.deleteIfExists(path);
} catch (IOException e) {
log.error("error:"+e);
}
}
return result;
}).collect(Collectors.toList());
for (Path mpt: moodPathList) {
List<Path> mp3WavPathList = Files.list(mpt).filter(path -> !Files.isDirectory(path) &&
StringUtils.endsWithAny(path.getFileName().toString(), ".wav", ".mp3"))
.collect(Collectors.toList());
Map<String, Path> map = new HashMap<>();
String filename;
for (Path mwpt: mp3WavPathList) {
filename = mwpt.getFileName().toString();
filename = filename.substring(0, filename.indexOf("."));
if (map.remove(filename) == null) {
map.put(filename, mwpt);
}
}
List<String> fragmentList = map.values().stream().map(path -> path.toAbsolutePath().toString()).collect(Collectors.toList());
if (!CollectionUtils.isEmpty(fragmentList)) {
map.values().forEach(path -> {
try {
Files.deleteIfExists(path);
} catch (IOException e) {
log.error("del fragment path:"+e);
}
});
buildFragmentCSV(fragmentList);
}
}
}
}
log.warn("delAllFragment end");
return ServerResponse.createBySuccess();
}
private void buildFragmentCSV(List<String> fragmentList) {
CSVFormat format;
if (Files.exists(Paths.get("/root/TTS-service/fragment_del.csv"))) format = CSVFormat.DEFAULT;
else format = CSVFormat.DEFAULT.withHeader("path");
try (CSVPrinter csvPrinter = new CSVPrinter(new OutputStreamWriter(
new FileOutputStream("/root/TTS-service/fragment_del.csv", true), Charset.forName("UTF-8")),format)){
for (String s: fragmentList) {
csvPrinter.printRecord(s);
}
} catch (IOException e) {
log.error("buildFragmentCSV error:"+e);
}
}
// @PostMapping("/api/upload/record/one_npc")
// public void uploadOneNpc(MultipartFile file, String botName, String npcName,
// HttpServletResponse response) {
......@@ -217,7 +316,11 @@ public class TTSController {
MultipartFile file = mulRequest.getFile("file");
String botName = mulRequest.getParameter("botName");
String npcName = mulRequest.getParameter("npcName");
String sampleRate = mulRequest.getParameter("sampleRate");
String bitRate = mulRequest.getParameter("bitRate");
UploadOneSenData data = new UploadOneSenData(botName, npcName, file);
data.setSampleRate(StringUtils.isBlank(sampleRate) ? 44100 : Integer.parseInt(sampleRate));
data.setBitRate(bitRate);
final String result = ttService.uploadOneNpc(data, response, request.getHeader("Authorization"));
if (result != null) {
TTService.getPOOL().submit(() -> TTSUtils.deleteFile(new File(result)));
......@@ -311,14 +414,15 @@ public class TTSController {
// }
public static void main(String[] args) throws IOException {
String path = "/home/yf01/下载/yace/data/datum_";
String targetPath = "/home/yf01/data601_900/datum_";
Files.createDirectories(Paths.get("/home/yf01/data601_900"));
String s;
for (int i = 1; i <= 300; i++) {
s = path+(600+i)+".csv";
Files.copy(Paths.get(s), Paths.get(targetPath+i+".csv"), StandardCopyOption.REPLACE_EXISTING);
}
String text = "今天是第";
String text2 = "6";
String text3 = "天,知道吗?,";
String text4 = "知道";
System.out.println(TTSUtils.buildMP3Filename(text));
System.out.println(TTSUtils.buildMP3Filename(text2));
System.out.println(TTSUtils.buildMP3Filename(text3));
System.out.println(TTSUtils.buildMP3Filename(text4));
}
}
package ai.qiwu.com.tts_service.pojo.upload;
import lombok.Getter;
import lombok.Setter;
/**
* painter
* 20-9-2 下午7:48
*/
@Getter
@Setter
public class AudioConfigInfo {
private String channel;
private String sampleRate;
private String duration;
private String fileSize;
private String bitRate;
}
......@@ -19,6 +19,8 @@ public class UploadOneSenData {
private String botName;
private String npcName;
private String text;
private Integer sampleRate = 44100;
private String bitRate = "64K";
private MultipartFile file;
public UploadOneSenData() {
......
package ai.qiwu.com.tts_service.pojo.upload;
import lombok.Getter;
import lombok.Setter;
/**
* painter
* 20-9-8 上午11:32
*/
@Getter
@Setter
public class UploadPlotImgResponse {
private String absolutePath;
private String relativePath;
}
......@@ -114,9 +114,9 @@ public class Initialize implements InitializingBean {
/**
* 线下服务地址,用于删除线下服务器上的缓存还有响应线下mp3文件的请求
*/
public static final String OFFLINE_SERVER;
static final String OFFLINE_SERVER;
public static final String ONLINE_CACHE_URL;
static final String ONLINE_CACHE_URL;
/**
* 第三方请求的标识,出现在tts_ls请求返回的.b64文件名列表和.b64文件数据中
*/
......@@ -146,11 +146,13 @@ public class Initialize implements InitializingBean {
static final String AUDIO_GENERATE_SERVER;
public static final int XIAODU_TEXT_SIZE_LIMIT;
public static final String ZUUL_HOST;
public static final int LIEHU_TEXT_SIZE_LIMIT;
// private static final int XIAODU_TEXT_SIZE_LIMIT;
public static final int US_TEXT_SIZE_LIMIT;
// private static final int LIEHU_TEXT_SIZE_LIMIT;
// private static final int US_TEXT_SIZE_LIMIT;
/**
* 静态代码块
......@@ -176,10 +178,11 @@ public class Initialize implements InitializingBean {
delRecordCallbackUrl = Config.getProperty("del_record_callback_url");
record_callback_url = Config.getProperty("record_callback_url");
AUDIO_GENERATE_SERVER = Config.getProperty("audio_generate_server");
ZUUL_HOST = Config.getProperty("zuulHost");
XIAODU_TEXT_SIZE_LIMIT = Integer.parseInt(Config.getProperty("xiaodu_text_size_limit", "2040"));
LIEHU_TEXT_SIZE_LIMIT = Integer.parseInt(Config.getProperty("xiaoai_text_size_limit", "1500"));
US_TEXT_SIZE_LIMIT = Integer.parseInt(Config.getProperty("us_text_size_limit", "495"));
// XIAODU_TEXT_SIZE_LIMIT = Integer.parseInt(Config.getProperty("xiaodu_text_size_limit", "2040"));
// LIEHU_TEXT_SIZE_LIMIT = Integer.parseInt(Config.getProperty("xiaoai_text_size_limit", "1500"));
// US_TEXT_SIZE_LIMIT = Integer.parseInt(Config.getProperty("us_text_size_limit", "495"));
// 根据数据库表中get_online字段的值来抉择不同的服务器
String[] online_sever_list = Config.getProperty("online_sever").split(",");
......
......@@ -196,7 +196,7 @@ public class TTServiceEdition2 {
public void ttsAudioGet(String filename, Integer exist, String _type, HttpServletResponse response) {
boolean tmp = StringUtils.startsWith(filename, "/tmp");
if (StringUtils.endsWith(filename,".mp3")) {
String filepath = Initialize.getAudioDir() + filename;
String filepath = Initialize.AUDIO_DIR + filename;
Path pt = Paths.get(filepath);
// exist == null 表明调用时确定已存在
if (exist == null) {
......
......@@ -167,7 +167,10 @@ public class Oauth2Controller {
if (code == null && refresh_token != null) {
refresh_token = refresh_token.substring(refresh_token.lastIndexOf(",")+1);
TokenResponse tokenResponse = LoadBySMS.getTokenByRefreshToken(refresh_token);
if (tokenResponse == null) return null;
// log.warn("refreshToken:"+tokenResponse);
if (tokenResponse == null) {
return new TokenDuerosResponse();
}
TokenDuerosResponse response = new TokenDuerosResponse();
response.setAccess_token(tokenResponse.getAccessToken());
response.setRefresh_token(tokenResponse.getRefreshToken());
......
package ai.qiwu.com.xiaoduhome.dpl2.model;
import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Getter;
import lombok.Setter;
......@@ -9,6 +10,7 @@ import lombok.Setter;
*/
@Getter
@Setter
@JsonInclude(JsonInclude.Include.NON_NULL)
public class ProjectDetailData {
private String imgUrl;
private String workName;
......
......@@ -386,6 +386,7 @@ public class DplbotServiceUtil {
// noticeOtherServer(3, botAccount, ScheduleServiceNew.curTime, true, userId, jytUserId, channelId, true);
final String jytId = jytUserId;
POOL.submit(() -> updateCollectTable(true, userId, channelId, botAccount, jytId));
getRedisTemplate().opsForValue().set(userId, behaviorData, 1, TimeUnit.HOURS);
return true;
}
return false;
......@@ -457,7 +458,7 @@ public class DplbotServiceUtil {
return data != null && data.getUserBotId2History().containsKey(botAccount);
}
public static void updateUserFlower(String userId, int flowerNum, String channelId,
public static long updateUserFlower(String userId, int flowerNum, String channelId,
String jytUserId, String accessToken, String botAccount) {
UserBehaviorData data = getRedisTemplate().opsForValue().get(userId);
if (data == null) {
......@@ -466,7 +467,7 @@ public class DplbotServiceUtil {
data = onLunchFillUserBehaviorDataInMaster(userId, channelId, jytUserId, true);
if (data == null) {
log.error("没有获取到用户数据信息,导致更新用户送花缓存数据失败");
return;
return 0;
}
}
Long before = data.getUserBotId2Flowers().get(botAccount);
......@@ -475,6 +476,7 @@ public class DplbotServiceUtil {
}
data.getUserBotId2Flowers().put(botAccount, before+flowerNum);
getRedisTemplate().opsForValue().set(userId, data, 1, TimeUnit.HOURS);
return before+flowerNum;
}
public static void updateTheUserHistory(final String userId,final String botAccount, final String accessToken,
......@@ -493,18 +495,18 @@ public class DplbotServiceUtil {
data = onLunchFillUserBehaviorDataInMaster(userId, channelId, appUserId, loaded);
if (data == null) return;
}
data.getUserBotId2History().put(botAccount, System.currentTimeMillis());
ProjectData actualBot = ScheduleServiceNew.getProjectByBotAccount(botAccount);
data.getUserBotId2History().put(actualBot.getBotAccount(), System.currentTimeMillis());
getRedisTemplate().opsForValue().set(userId, data, 1, TimeUnit.HOURS);
XiaoDuHistoryTBRepository repository = BaseHolder.getBean("xiaoDuHistoryTBRepository");
String botName = ScheduleServiceNew.getWorkNameByBotAccount(botAccount);
XiaoDuHistoryTB tb = repository.getByXiaoduUserIdAndChannelIdAndWorkName(userId, channelId, botName);
XiaoDuHistoryTB tb = repository.getByXiaoduUserIdAndChannelIdAndWorkName(userId, channelId, actualBot.getName());
if (tb == null) {
tb = new XiaoDuHistoryTB();
tb.setChannelId(channelId);
tb.setJytUserId(jytUserId);
tb.setXiaoduUserId(userId);
tb.setWorkName(botName);
tb.setWorkName(actualBot.getName());
}
repository.save(tb);
});
......
......@@ -125,7 +125,7 @@ public class LoadBySMS {
headers.put("Content-Type", "application/json;charset=utf-8");
headers.put("Authorization", Utils.tokenAuthorization(phoneNumber, captcha));
String tokenStr = OkHttp3Utils.doGet(XIAOWU_API.SDK_TOKEN, new HashMap<>(), headers);
// log.info("获取Token返回");
log.info("获取Token返回:"+tokenStr);
TokenResponse tokenResponse = JSON.parseObject(tokenStr, TokenResponse.class);
// log.info("获取Token返回信息:{}", tokenResponse);
if (tokenResponse.getRetcode() == 0) {
......@@ -217,10 +217,15 @@ public class LoadBySMS {
// System.out.println(tokenStr);
HashMap<String, String> headers = new HashMap<>();
headers.put("App-Channel-Id", "JIAOYOUTIANXIA");
headers.put("App-Channel-Id", "xiaodu-speaker-api-test");
headers.put("Content-Type", "application/json;charset=utf-8");
headers.put("Authorization", Utils.captchaAuthorization("13410129349"));
String smsStr = OkHttp3Utils.doGet(XIAOWU_API.CAPTCHA_SMS, new HashMap<>(), headers);
headers.put("Authorization", XIAOWU_API.BEARER+"dba29f53-41b1-4144-906d-a19f15d25dc8");
String smsStr = null;
try {
smsStr = OkHttp3Utils.doPostJsonStr("https://account-center-test.chewrobot.com/api/sdk/token", "", headers);
System.out.println(smsStr);
} catch (Exception e) {
log.error("通过RefreshToken请求Token出错:{}",e.toString());
}
}
}
......@@ -103,7 +103,7 @@ public class ScheduleServiceNew implements InitializingBean {
OLD_CDN_HOST_URL = CDN_HOST_URL;
XIAO_AI_ENCRY_HOST = Config.getProperty("host");
THE_PROCESS_IS_MASTER = Config.getProperty("masterSlave", "slave").equals("master");
THE_PROCESS_IS_MASTER = "master".equals(Config.getProperty("masterSlave", "slave"));
log.info("BASE_HOST_URL:{},CDN_HOST_URL:{}, xiaoai encry host:{}, masterSlave:{}",BASE_HOST_URL,CDN_HOST_URL,
XIAO_AI_ENCRY_HOST,THE_PROCESS_IS_MASTER);
......
......@@ -367,6 +367,7 @@ public class XiaoAiServiceRedis {
*/
private String getUserId(XiaoAiRequest request) {
String userId = request.getSession().getUser().getUser_id();
// log.info("小爱,userId:{}", userId);
if (userId == null) {
userId = request.getContext().getDevice_id();
if (userId != null) userId = Utils.modifyDeviceId(userId);
......@@ -388,9 +389,9 @@ public class XiaoAiServiceRedis {
}
String response;
try {
// log.info("小爱,用户话:{}", userWord);
log.info("==================\n小爱,用户话:{}, userId:{}", userWord, userId);
response = RequestTerminal.requestTerminate(userId, userWord, type, baseUrl);
// log.info("小爱,小悟返回:{}", response);
log.info("小爱,小悟返回:{}", response);
} catch (Exception e) {
log.error("向终端发出的请求信息失败:{}", e.toString());
return buildTextResponse(SORRY_REPEAT);
......@@ -453,7 +454,7 @@ public class XiaoAiServiceRedis {
String path;
try {
path = OkHttp3Utils.doPostJsonStr(audioUrl+"/api/audio", response);
if (StringUtils.isBlank(path) || path.equals("null")) {
if (StringUtils.isBlank(path) || "null".equals(path)) {
log.error("没有获取到TTS返回的路径path");
return buildTextResponse(SORRY_REPEAT);
}
......@@ -463,7 +464,7 @@ public class XiaoAiServiceRedis {
botAccount = "empty";
}
xiaoAiResponse = buildAudioResponse((path = changeAudioUrlTemp(path, botAccount, cdnUrl)));
// log.info("音频地址:"+path);
log.info("音频地址:"+path);
if (Boolean.TRUE.equals(stringRedisTemplate.opsForValue()
.setIfPresent(SpiritRedisService.PREFIX_REDIS+userId, path, 15, TimeUnit.SECONDS))) {
log.info("xiaoai 超时redis存储成功");
......
......@@ -43,7 +43,8 @@
"type": "Header",
"props": {
"title": "${payload.headerTitle}",
"sideText": "${payload.sideText}"
"sideText": "${payload.sideText}",
"destroy": false
},
"events": {
"onBackTap": [{
......
......@@ -43,7 +43,14 @@
{
"type": "Header",
"props": {
"title": "${payload.headerTitle}"
"title": "${payload.headerTitle}",
"destroy": false
},
"events": {
"onBackTap": [{
"type": "SendEvent",
"componentId": "backTrigger"
}]
}
},
{
......
......@@ -49,11 +49,16 @@
},
{
"type": "Header",
"props": {
"destroy": false
},
"events": {
"onBackTap": [{
"onBackTap": [
{
"type": "SendEvent",
"componentId": "backTrigger"
}]
}
]
}
},
{
......
......@@ -44,7 +44,8 @@
"type": "Header",
"props": {
"title": "${payload.headerTitle}",
"sideText": "${payload.sideText}"
"sideText": "${payload.sideText}",
"destroy": false
},
"events": {
"onBackTap": [{
......@@ -319,7 +320,6 @@
},
{
"type": "Container",
"dWhen": "<%= $ITEM.num4 != 0 %>",
"props": {
"clickTimeout": 2000
},
......
......@@ -42,7 +42,8 @@
{
"type": "Header",
"props": {
"title": "${payload.headerTitle}"
"title": "${payload.headerTitle}",
"destroy": false
},
"events": {
"onBackTap": [{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment