增加LAC、语音合成方案配置
This commit is contained in:
parent
8a84450b5d
commit
cd8c4fc347
@ -10,8 +10,8 @@ public class ChineseDateTimeUtils {
|
|||||||
* @param c 时间字符串
|
* @param c 时间字符串
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static LocalDateTime getDateWithCode(String c){
|
public static LocalDateTime getDateWithString(String c){
|
||||||
return getDateWithCodeAndLocalDateTime(c, LocalDateTime.now(), 0, 0);
|
return getDateTime(c.replace("的", ""), LocalDateTime.now(), 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int checkDayOfMonth(LocalDateTime localDateTime, int i){
|
private static int checkDayOfMonth(LocalDateTime localDateTime, int i){
|
||||||
@ -47,7 +47,7 @@ public class ChineseDateTimeUtils {
|
|||||||
int i = checkDayOfMonth(localDateTime, ChineseToAlaboUtils.getLong(c.substring(0, index)).intValue());
|
int i = checkDayOfMonth(localDateTime, ChineseToAlaboUtils.getLong(c.substring(0, index)).intValue());
|
||||||
|
|
||||||
|
|
||||||
return getDateWithCodeAndLocalDateTime(
|
return getDateTime(
|
||||||
c.substring(index + key.length()),
|
c.substring(index + key.length()),
|
||||||
localDateTime.withDayOfMonth(i).withHour(0).withMinute(0).withSecond(0),
|
localDateTime.withDayOfMonth(i).withHour(0).withMinute(0).withSecond(0),
|
||||||
ampm,
|
ampm,
|
||||||
@ -93,8 +93,8 @@ public class ChineseDateTimeUtils {
|
|||||||
* @param localDateTime 时间基础
|
* @param localDateTime 时间基础
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static LocalDateTime getDateWithCodeAndLocalDateTime(String c, LocalDateTime localDateTime){
|
public static LocalDateTime getDateWithStringAndLocalDateTime(String c, LocalDateTime localDateTime){
|
||||||
return getDateWithCodeAndLocalDateTime(c, localDateTime, 0, 0);
|
return getDateTime(c.replace("的", ""), localDateTime, 0, 0);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* 汉语时间字符串转时间
|
* 汉语时间字符串转时间
|
||||||
@ -104,14 +104,18 @@ public class ChineseDateTimeUtils {
|
|||||||
* @param type 0:无感 1:月 2:时 3:分
|
* @param type 0:无感 1:月 2:时 3:分
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static LocalDateTime getDateWithCodeAndLocalDateTime(String c, LocalDateTime localDateTime, int ampm, int type){
|
public static LocalDateTime getDateWithStringAndLocalDateTime(String c, LocalDateTime localDateTime, int ampm, int type){
|
||||||
|
return getDateTime(c.replace("的", ""), localDateTime, ampm, type);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static LocalDateTime getDateTime(String c, LocalDateTime localDateTime, int ampm, int type){
|
||||||
DateEnum dateEnu = null;
|
DateEnum dateEnu = null;
|
||||||
for(DateEnum enum1 : DateEnum.values()){
|
for(DateEnum enum1 : DateEnum.values()){
|
||||||
if(c.startsWith(enum1.getCode())){
|
if(c.startsWith(enum1.getCode())){
|
||||||
dateEnu = enum1;
|
dateEnu = enum1;
|
||||||
localDateTime = dateEnu.getDateTime(localDateTime);
|
localDateTime = dateEnu.getDateTime(localDateTime);
|
||||||
c = c.substring(enum1.getCode().length());
|
c = c.substring(enum1.getCode().length());
|
||||||
localDateTime = getDateWithCodeAndLocalDateTime(c, localDateTime, dateEnu.getAmPm(), 0);
|
localDateTime = getDateTime(c, localDateTime, dateEnu.getAmPm(), 0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -264,7 +268,7 @@ public class ChineseDateTimeUtils {
|
|||||||
private static LocalDateTime setYear(String c, String key, LocalDateTime localDateTime, int ampm) {
|
private static LocalDateTime setYear(String c, String key, LocalDateTime localDateTime, int ampm) {
|
||||||
int index = c.indexOf(key);
|
int index = c.indexOf(key);
|
||||||
int i = ChineseToAlaboUtils.getLong(c.substring(0, index)).intValue();
|
int i = ChineseToAlaboUtils.getLong(c.substring(0, index)).intValue();
|
||||||
return getDateWithCodeAndLocalDateTime(
|
return getDateTime(
|
||||||
c.substring(index + key.length()),
|
c.substring(index + key.length()),
|
||||||
localDateTime.withYear(i),
|
localDateTime.withYear(i),
|
||||||
ampm,
|
ampm,
|
||||||
@ -305,7 +309,7 @@ public class ChineseDateTimeUtils {
|
|||||||
private static LocalDateTime setMonth(String c, String key, LocalDateTime localDateTime, int ampm) {
|
private static LocalDateTime setMonth(String c, String key, LocalDateTime localDateTime, int ampm) {
|
||||||
int index = c.indexOf(key);
|
int index = c.indexOf(key);
|
||||||
int i = checkMonth(ChineseToAlaboUtils.getLong(c.substring(0, index)).intValue());
|
int i = checkMonth(ChineseToAlaboUtils.getLong(c.substring(0, index)).intValue());
|
||||||
return getDateWithCodeAndLocalDateTime(
|
return getDateTime(
|
||||||
c.substring(index + key.length()),
|
c.substring(index + key.length()),
|
||||||
localDateTime.withMonth(i),
|
localDateTime.withMonth(i),
|
||||||
ampm,
|
ampm,
|
||||||
@ -324,7 +328,7 @@ public class ChineseDateTimeUtils {
|
|||||||
private static LocalDateTime setMinute(String c, String key, LocalDateTime localDateTime, int ampm) {
|
private static LocalDateTime setMinute(String c, String key, LocalDateTime localDateTime, int ampm) {
|
||||||
int index = c.indexOf(key);
|
int index = c.indexOf(key);
|
||||||
int i = checkMinuteAndSecond(ChineseToAlaboUtils.getLong(c.substring(0, index)).intValue());
|
int i = checkMinuteAndSecond(ChineseToAlaboUtils.getLong(c.substring(0, index)).intValue());
|
||||||
return getDateWithCodeAndLocalDateTime(
|
return getDateTime(
|
||||||
c.substring(index + key.length()),
|
c.substring(index + key.length()),
|
||||||
localDateTime.withMinute(i),
|
localDateTime.withMinute(i),
|
||||||
ampm,
|
ampm,
|
||||||
@ -352,7 +356,7 @@ public class ChineseDateTimeUtils {
|
|||||||
localDateTime = localDateTime.plusDays(1);
|
localDateTime = localDateTime.plusDays(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return getDateWithCodeAndLocalDateTime(
|
return getDateTime(
|
||||||
c.substring(index + key.length()),
|
c.substring(index + key.length()),
|
||||||
localDateTime.withHour(i).withMinute(0).withSecond(0),
|
localDateTime.withHour(i).withMinute(0).withSecond(0),
|
||||||
ampm,
|
ampm,
|
||||||
|
|||||||
@ -99,4 +99,8 @@ public class DeviceUserBindEntity extends GenericEntity<Long> {
|
|||||||
@Column(name = "scence_id", length = 11)
|
@Column(name = "scence_id", length = 11)
|
||||||
private Long scenceId;
|
private Long scenceId;
|
||||||
|
|
||||||
|
@Comment("语音合成音色标识")
|
||||||
|
@Column(name = "tts", length = 11)
|
||||||
|
private String tts;
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -79,5 +79,10 @@ public class DeviceUserBindRequest implements java.io.Serializable {
|
|||||||
*/
|
*/
|
||||||
private Integer onLine;
|
private Integer onLine;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 语音合成音色标识
|
||||||
|
*/
|
||||||
|
private String tts;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -35,6 +35,7 @@ public class DeviceUserBindResp {
|
|||||||
categoryCode = entity.getCategoryCode();
|
categoryCode = entity.getCategoryCode();
|
||||||
u3dId = entity.getU3dId();
|
u3dId = entity.getU3dId();
|
||||||
scenceId = entity.getScenceId();
|
scenceId = entity.getScenceId();
|
||||||
|
tts = entity.getTts();
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
private Long id;
|
private Long id;
|
||||||
@ -92,4 +93,10 @@ public class DeviceUserBindResp {
|
|||||||
* 最后离线时间
|
* 最后离线时间
|
||||||
*/
|
*/
|
||||||
private Date lastOffLineTime;
|
private Date lastOffLineTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 语音合成音色标识
|
||||||
|
*/
|
||||||
|
private String tts;
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -109,6 +109,9 @@ public class DeviceUserBindService extends GenericReactiveCrudService<DeviceUser
|
|||||||
if(request.getScenceId() != null){
|
if(request.getScenceId() != null){
|
||||||
reactiveQuery = reactiveQuery.and(DeviceUserBindRequest::getScenceId, request.getScenceId());
|
reactiveQuery = reactiveQuery.and(DeviceUserBindRequest::getScenceId, request.getScenceId());
|
||||||
}
|
}
|
||||||
|
if(StringUtils.isNotEmpty(request.getTts())){
|
||||||
|
reactiveQuery = reactiveQuery.and(DeviceUserBindRequest::getTts, request.getTts());
|
||||||
|
}
|
||||||
SortOrder sortOrder = null;
|
SortOrder sortOrder = null;
|
||||||
if(StringUtils.isNotEmpty(request.getOrder())){
|
if(StringUtils.isNotEmpty(request.getOrder())){
|
||||||
if(StringUtils.isNotEmpty(request.getSort()) && request.getSort().compareTo("0") == 0){
|
if(StringUtils.isNotEmpty(request.getSort()) && request.getSort().compareTo("0") == 0){
|
||||||
@ -200,6 +203,9 @@ public class DeviceUserBindService extends GenericReactiveCrudService<DeviceUser
|
|||||||
if(request.getScenceId() != null){
|
if(request.getScenceId() != null){
|
||||||
reactiveQuery = reactiveQuery.and(DeviceUserBindRequest::getScenceId, request.getScenceId());
|
reactiveQuery = reactiveQuery.and(DeviceUserBindRequest::getScenceId, request.getScenceId());
|
||||||
}
|
}
|
||||||
|
if(StringUtils.isNotEmpty(request.getTts())){
|
||||||
|
reactiveQuery = reactiveQuery.and(DeviceUserBindRequest::getTts, request.getTts());
|
||||||
|
}
|
||||||
QueryParamEntity param = QueryParamEntity.of(reactiveQuery.getParam());
|
QueryParamEntity param = QueryParamEntity.of(reactiveQuery.getParam());
|
||||||
if(StringUtils.isNotEmpty(request.getOrder())){
|
if(StringUtils.isNotEmpty(request.getOrder())){
|
||||||
Sort sort = new Sort();
|
Sort sort = new Sort();
|
||||||
@ -295,6 +301,9 @@ public class DeviceUserBindService extends GenericReactiveCrudService<DeviceUser
|
|||||||
if(entity.getScenceId() != null){
|
if(entity.getScenceId() != null){
|
||||||
update = update.set(DeviceUserBindEntity::getScenceId, entity.getScenceId());
|
update = update.set(DeviceUserBindEntity::getScenceId, entity.getScenceId());
|
||||||
}
|
}
|
||||||
|
if(StringUtils.isNotEmpty(entity.getTts())){
|
||||||
|
update = update.set(DeviceUserBindEntity::getTts, entity.getTts());
|
||||||
|
}
|
||||||
return update.where(DeviceUserBindEntity::getId, entity.getId()).and("is_delete", 0).execute();
|
return update.where(DeviceUserBindEntity::getId, entity.getId()).and("is_delete", 0).execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -321,6 +330,7 @@ public class DeviceUserBindService extends GenericReactiveCrudService<DeviceUser
|
|||||||
update = update.set(DeviceUserBindEntity::getCategoryCode, entity.getCategoryCode());
|
update = update.set(DeviceUserBindEntity::getCategoryCode, entity.getCategoryCode());
|
||||||
update = update.set(DeviceUserBindEntity::getU3dId, entity.getU3dId());
|
update = update.set(DeviceUserBindEntity::getU3dId, entity.getU3dId());
|
||||||
update = update.set(DeviceUserBindEntity::getScenceId, entity.getScenceId());
|
update = update.set(DeviceUserBindEntity::getScenceId, entity.getScenceId());
|
||||||
|
update = update.set(DeviceUserBindEntity::getTts, entity.getTts());
|
||||||
return update.where(DeviceUserBindEntity::getId, entity.getId()).and("is_delete", 0).execute();
|
return update.where(DeviceUserBindEntity::getId, entity.getId()).and("is_delete", 0).execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,15 +1,11 @@
|
|||||||
package com.qiuguo.iot.third.nlp.action;
|
package com.qiuguo.iot.third.nlp.action;
|
||||||
|
|
||||||
import com.qiuguo.iot.base.date.DateEnum;
|
|
||||||
import com.qiuguo.iot.base.utils.ChineseDateTimeUtils;
|
import com.qiuguo.iot.base.utils.ChineseDateTimeUtils;
|
||||||
import com.qiuguo.iot.base.utils.ChineseToAlaboUtils;
|
|
||||||
import com.qiuguo.iot.base.utils.StringUtils;
|
import com.qiuguo.iot.base.utils.StringUtils;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
public class ActionTime {
|
public class ActionTime {
|
||||||
@ -52,7 +48,7 @@ public class ActionTime {
|
|||||||
|
|
||||||
DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||||||
DateTimeFormatter df1 = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
DateTimeFormatter df1 = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
||||||
localDateTime = ChineseDateTimeUtils.getDateWithCodeAndLocalDateTime(t, localDateTime);
|
localDateTime = ChineseDateTimeUtils.getDateWithStringAndLocalDateTime(t, localDateTime);
|
||||||
detailTime = localDateTime;
|
detailTime = localDateTime;
|
||||||
dateTime = localDateTime.format(df);
|
dateTime = localDateTime.format(df);
|
||||||
dateDetailTime = localDateTime.format(df1);
|
dateDetailTime = localDateTime.format(df1);
|
||||||
|
|||||||
@ -62,8 +62,10 @@ public class LacNlpService implements INlp {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Mono<Nlp> geSingletNlp(String value) {
|
public Mono<Nlp> geSingletNlp(String value) {
|
||||||
|
if(SpringUtil.getProperty("lac.type").equals("suanfa")){
|
||||||
return getHubFaLac(value);
|
return getHubFaLac(value);
|
||||||
|
}
|
||||||
|
return getSuanFaLac(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
package com.qiuguo.iot.user.api.controller.device;
|
package com.qiuguo.iot.user.api.controller.device;
|
||||||
|
|
||||||
import cn.hutool.crypto.digest.MD5;
|
import cn.hutool.crypto.digest.MD5;
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.alibaba.fastjson.JSONArray;
|
import com.alibaba.fastjson.JSONArray;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.qiuguo.iot.base.constans.RedisConstans;
|
import com.qiuguo.iot.base.constans.RedisConstans;
|
||||||
@ -164,8 +165,8 @@ public class DeviceController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pagerResult.setData(list);
|
pagerResult.setData(list);
|
||||||
|
|
||||||
return pagerResult;
|
return pagerResult;
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -99,14 +99,15 @@ public class LogWebFilter implements WebFilter {
|
|||||||
joinBuffer.read(returnContent);
|
joinBuffer.read(returnContent);
|
||||||
DataBufferUtils.release(joinBuffer);
|
DataBufferUtils.release(joinBuffer);
|
||||||
String returnStr = new String(returnContent, StandardCharsets.UTF_8);
|
String returnStr = new String(returnContent, StandardCharsets.UTF_8);
|
||||||
log.info("response:{}", returnStr);
|
log.info("flux response:{}", returnStr);
|
||||||
return response.bufferFactory().wrap(returnContent);
|
return response.bufferFactory().wrap(returnContent);
|
||||||
}));
|
}));
|
||||||
}else if(body instanceof Mono){
|
}else if(body instanceof Mono){
|
||||||
Mono<DataBuffer> monoBody = Mono.from(body);
|
Mono<DataBuffer> monoBody = Mono.from(body);
|
||||||
return super.writeWith(monoBody.map(dataBuffer -> {
|
return super.writeWith(monoBody.map(dataBuffer -> {
|
||||||
log.info("response:{}", dataBuffer.toString(StandardCharsets.UTF_8));
|
String returnStr = dataBuffer.toString(StandardCharsets.UTF_8);
|
||||||
return response.bufferFactory().wrap(dataBuffer.toString(StandardCharsets.UTF_8).getBytes());
|
log.info("mono response:{}", returnStr);
|
||||||
|
return response.bufferFactory().wrap(returnStr.getBytes());
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
return super.writeWith(body);
|
return super.writeWith(body);
|
||||||
|
|||||||
@ -44,6 +44,7 @@ import org.springframework.amqp.core.Message;
|
|||||||
import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
||||||
import org.springframework.beans.BeanUtils;
|
import org.springframework.beans.BeanUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.web.reactive.socket.WebSocketSession;
|
import org.springframework.web.reactive.socket.WebSocketSession;
|
||||||
import reactor.core.publisher.Mono;
|
import reactor.core.publisher.Mono;
|
||||||
import reactor.core.scheduler.Schedulers;
|
import reactor.core.scheduler.Schedulers;
|
||||||
@ -89,6 +90,9 @@ public class BaseWebSocketProcess {
|
|||||||
@Autowired
|
@Autowired
|
||||||
AudioService audioService;
|
AudioService audioService;
|
||||||
|
|
||||||
|
@Value("${tts.suanfa")
|
||||||
|
Boolean ttsSuanfa;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
protected SystemTalkBindU3dService systemTalkBindU3dService;
|
protected SystemTalkBindU3dService systemTalkBindU3dService;
|
||||||
|
|
||||||
@ -672,20 +676,19 @@ public class BaseWebSocketProcess {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void sendMsg(BaseSession baseSession, BaseMessageResp baseMessageResp) {
|
private void sendMsg(BaseSession baseSession, BaseMessageResp baseMessageResp) {
|
||||||
|
if(ttsSuanfa && this instanceof BoxWebSocketHandler){
|
||||||
sendMsg(baseSession, JSONObject.toJSONString(baseMessageResp));
|
|
||||||
/* if(this instanceof BoxWebSocketHandler){
|
|
||||||
audioService.getAudioUrl(baseMessageResp.getText()).map(s ->{
|
audioService.getAudioUrl(baseMessageResp.getText()).map(s ->{
|
||||||
log.info("音频地址:{}", s);
|
log.info("音频地址:{}", s);
|
||||||
BoxMessageResp boxMessageResp = new BoxMessageResp();
|
BoxMessageResp boxMessageResp = new BoxMessageResp();
|
||||||
BeanUtils.copyProperties(baseMessageResp, boxMessageResp);
|
BeanUtils.copyProperties(baseMessageResp, boxMessageResp);
|
||||||
boxMessageResp.setAudio(s);
|
boxMessageResp.setAudio(s);
|
||||||
sendMsg(baseSession, JSONObject.toJSONString(boxMessageResp));======
|
sendMsg(baseSession, JSONObject.toJSONString(boxMessageResp));
|
||||||
return s;
|
return s;
|
||||||
}).subscribeOn(Schedulers.single()).subscribe();
|
}).subscribeOn(Schedulers.single()).subscribe();
|
||||||
}else{
|
}else{
|
||||||
sendMsg(baseSession, JSONObject.toJSONString(baseMessageResp));
|
sendMsg(baseSession, JSONObject.toJSONString(baseMessageResp));
|
||||||
}*/
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sendMsg(BaseSession baseSession, String msg) {
|
private void sendMsg(BaseSession baseSession, String msg) {
|
||||||
|
|||||||
@ -40,7 +40,10 @@ tianqiapi:
|
|||||||
qiuguo:
|
qiuguo:
|
||||||
checktoken:
|
checktoken:
|
||||||
url: https://exper.qiuguojihua.com/data/api.auth.center/get
|
url: https://exper.qiuguojihua.com/data/api.auth.center/get
|
||||||
|
tts:
|
||||||
|
suanfa: true
|
||||||
lac:
|
lac:
|
||||||
|
type: suanfa
|
||||||
hub:
|
hub:
|
||||||
url: http://192.168.8.175:8866/predict/lac
|
url: http://192.168.8.175:8866/predict/lac
|
||||||
suanfa:
|
suanfa:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user