增加算法语音合成
This commit is contained in:
parent
15e654c897
commit
ef5cbad1ef
@ -1,6 +1,8 @@
|
|||||||
package com.qiuguo.iot.base.date;
|
package com.qiuguo.iot.base.date;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
public enum DateEnum implements IDate{
|
public enum DateEnum implements IDate{
|
||||||
//现在,今天,明天,后天,昨天,前天,*天后,*天,
|
//现在,今天,明天,后天,昨天,前天,*天后,*天,
|
||||||
@ -11,6 +13,106 @@ public enum DateEnum implements IDate{
|
|||||||
//*小时
|
//*小时
|
||||||
//*秒
|
//*秒
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 早上
|
||||||
|
*/
|
||||||
|
MONRING("早上"){
|
||||||
|
@Override
|
||||||
|
public LocalDateTime getDateTime(LocalDateTime localDateTime){
|
||||||
|
return localDateTime.withHour(6);
|
||||||
|
}
|
||||||
|
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* 早晨
|
||||||
|
*/
|
||||||
|
MONRING_M("早晨"){
|
||||||
|
@Override
|
||||||
|
public LocalDateTime getDateTime(LocalDateTime localDateTime){
|
||||||
|
return MONRING.getDateTime(localDateTime);
|
||||||
|
}
|
||||||
|
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* 拂晓
|
||||||
|
*/
|
||||||
|
DAWN("拂晓"){
|
||||||
|
@Override
|
||||||
|
public LocalDateTime getDateTime(LocalDateTime localDateTime){
|
||||||
|
return MONRING.getDateTime(localDateTime);
|
||||||
|
}
|
||||||
|
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* 上午
|
||||||
|
*/
|
||||||
|
AM("上午"){
|
||||||
|
@Override
|
||||||
|
public LocalDateTime getDateTime(LocalDateTime localDateTime){
|
||||||
|
return localDateTime.withHour(9);
|
||||||
|
}
|
||||||
|
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* 中午
|
||||||
|
*/
|
||||||
|
NOON("中午"){
|
||||||
|
@Override
|
||||||
|
public LocalDateTime getDateTime(LocalDateTime localDateTime){
|
||||||
|
return localDateTime.withHour(12);
|
||||||
|
}
|
||||||
|
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* 下午
|
||||||
|
*/
|
||||||
|
PM("下午"){
|
||||||
|
@Override
|
||||||
|
public LocalDateTime getDateTime(LocalDateTime localDateTime){
|
||||||
|
return localDateTime.withMonth(15);
|
||||||
|
}
|
||||||
|
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* 傍晚
|
||||||
|
*/
|
||||||
|
EVENING("傍晚"){
|
||||||
|
@Override
|
||||||
|
public LocalDateTime getDateTime(LocalDateTime localDateTime){
|
||||||
|
return localDateTime.withMonth(18);
|
||||||
|
}
|
||||||
|
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* 晚上
|
||||||
|
*/
|
||||||
|
NIGHT("晚上"){
|
||||||
|
@Override
|
||||||
|
public LocalDateTime getDateTime(LocalDateTime localDateTime){
|
||||||
|
return localDateTime.withHour(21);
|
||||||
|
}
|
||||||
|
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* 深夜
|
||||||
|
*/
|
||||||
|
DEEP_NIGHT("深夜"){
|
||||||
|
@Override
|
||||||
|
public LocalDateTime getDateTime(LocalDateTime localDateTime){
|
||||||
|
return localDateTime.withHour(23);
|
||||||
|
}
|
||||||
|
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* 凌晨
|
||||||
|
*/
|
||||||
|
BEFORE_DAWN("凌晨"){
|
||||||
|
@Override
|
||||||
|
public LocalDateTime getDateTime(LocalDateTime localDateTime){
|
||||||
|
return localDateTime.withHour(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
},
|
||||||
/**
|
/**
|
||||||
* 今天
|
* 今天
|
||||||
*/
|
*/
|
||||||
@ -53,7 +155,7 @@ public enum DateEnum implements IDate{
|
|||||||
|
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* 明天
|
* 前天
|
||||||
*/
|
*/
|
||||||
BEFOR_YESTERDAY("前天"){
|
BEFOR_YESTERDAY("前天"){
|
||||||
@Override
|
@Override
|
||||||
@ -71,6 +173,147 @@ public enum DateEnum implements IDate{
|
|||||||
return localDateTime.minusDays(-2);
|
return localDateTime.minusDays(-2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* 今年
|
||||||
|
*/
|
||||||
|
THIS_YEAR("今年"){
|
||||||
|
@Override
|
||||||
|
public LocalDateTime getDateTime(LocalDateTime localDateTime){
|
||||||
|
return localDateTime.withMonth(3);
|
||||||
|
}
|
||||||
|
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* 下半年
|
||||||
|
*/
|
||||||
|
NEXT_HALF_YEAR("下半年"){
|
||||||
|
@Override
|
||||||
|
public LocalDateTime getDateTime(LocalDateTime localDateTime){
|
||||||
|
return localDateTime.withMonth(10);
|
||||||
|
}
|
||||||
|
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* 上半年
|
||||||
|
*/
|
||||||
|
LAST_HALF_YEAR("上半年"){
|
||||||
|
@Override
|
||||||
|
public LocalDateTime getDateTime(LocalDateTime localDateTime){
|
||||||
|
return localDateTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 明年
|
||||||
|
*/
|
||||||
|
NEXT_YEAR("明年"){
|
||||||
|
@Override
|
||||||
|
public LocalDateTime getDateTime(LocalDateTime localDateTime){
|
||||||
|
return localDateTime.minusYears(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* 去年
|
||||||
|
*/
|
||||||
|
LAST_YEAR("去年"){
|
||||||
|
@Override
|
||||||
|
public LocalDateTime getDateTime(LocalDateTime localDateTime){
|
||||||
|
return localDateTime.minusYears(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* 下个年
|
||||||
|
*/
|
||||||
|
NEXT_Y_YEAR("下个年"){
|
||||||
|
@Override
|
||||||
|
public LocalDateTime getDateTime(LocalDateTime localDateTime){
|
||||||
|
return NEXT_YEAR.getDateTime(localDateTime);
|
||||||
|
}
|
||||||
|
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* 下年
|
||||||
|
*/
|
||||||
|
NEXT__YEAR("下年"){
|
||||||
|
@Override
|
||||||
|
public LocalDateTime getDateTime(LocalDateTime localDateTime){
|
||||||
|
return NEXT_YEAR.getDateTime(localDateTime);
|
||||||
|
}
|
||||||
|
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* 上个年
|
||||||
|
*/
|
||||||
|
LAST_Y_YEAR("上个年"){
|
||||||
|
@Override
|
||||||
|
public LocalDateTime getDateTime(LocalDateTime localDateTime){
|
||||||
|
return LAST_YEAR.getDateTime(localDateTime);
|
||||||
|
}
|
||||||
|
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* 前年
|
||||||
|
*/
|
||||||
|
BEFOR_YEAR("前年"){
|
||||||
|
@Override
|
||||||
|
public LocalDateTime getDateTime(LocalDateTime localDateTime){
|
||||||
|
return localDateTime.minusYears(2);
|
||||||
|
}
|
||||||
|
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* 后年
|
||||||
|
*/
|
||||||
|
AFTER_YEAR("后年"){
|
||||||
|
@Override
|
||||||
|
public LocalDateTime getDateTime(LocalDateTime localDateTime){
|
||||||
|
return localDateTime.minusYears(-2);
|
||||||
|
}
|
||||||
|
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* 下月
|
||||||
|
*/
|
||||||
|
NEXT_MONTH("下月"){
|
||||||
|
@Override
|
||||||
|
public LocalDateTime getDateTime(LocalDateTime localDateTime){
|
||||||
|
return localDateTime.minusMonths(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* 上月
|
||||||
|
*/
|
||||||
|
LAST_MONTH("上月"){
|
||||||
|
@Override
|
||||||
|
public LocalDateTime getDateTime(LocalDateTime localDateTime){
|
||||||
|
return LAST_MONTH.getDateTime(localDateTime);
|
||||||
|
}
|
||||||
|
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* 下个月
|
||||||
|
*/
|
||||||
|
NEXT_M_MONTH("下个月"){
|
||||||
|
@Override
|
||||||
|
public LocalDateTime getDateTime(LocalDateTime localDateTime){
|
||||||
|
return NEXT_MONTH.getDateTime(localDateTime);
|
||||||
|
}
|
||||||
|
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* 上个年
|
||||||
|
*/
|
||||||
|
LAST_M_MONTH("去年"){
|
||||||
|
@Override
|
||||||
|
public LocalDateTime getDateTime(LocalDateTime localDateTime){
|
||||||
|
return localDateTime.minusYears(1);
|
||||||
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* n天后
|
* n天后
|
||||||
@ -83,112 +326,82 @@ public enum DateEnum implements IDate{
|
|||||||
|
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* n天
|
* 国庆节
|
||||||
*/
|
*/
|
||||||
N_DAY("天"){
|
GUO_QING_JIE("国庆节"){
|
||||||
@Override
|
@Override
|
||||||
public LocalDateTime getDateTime(LocalDateTime localDateTime){
|
public LocalDateTime getDateTime(LocalDateTime localDateTime){
|
||||||
return localDateTime.minusDays(-2);
|
return localDateTime.withMonth(10).withDayOfMonth(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* N月后
|
* 国庆
|
||||||
*/
|
*/
|
||||||
N_AFTER_MONTH("月后"){
|
GUO_QIN("国庆"){
|
||||||
@Override
|
@Override
|
||||||
public LocalDateTime getDateTime(LocalDateTime localDateTime){
|
public LocalDateTime getDateTime(LocalDateTime localDateTime){
|
||||||
return localDateTime.minusDays(-2);
|
return GUO_QING_JIE.getDateTime(localDateTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* N月
|
* 元旦节
|
||||||
*/
|
*/
|
||||||
N_MONTH("月"){
|
NEW_YEAR("元旦节"){
|
||||||
@Override
|
@Override
|
||||||
public LocalDateTime getDateTime(LocalDateTime localDateTime){
|
public LocalDateTime getDateTime(LocalDateTime localDateTime){
|
||||||
return localDateTime.minusDays(-2);
|
return localDateTime.withMonth(1).withDayOfMonth(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* N年后
|
* 元旦
|
||||||
*/
|
*/
|
||||||
N_AFTER_YEAR("年后"){
|
NEW_Y_YEAR("元旦"){
|
||||||
@Override
|
@Override
|
||||||
public LocalDateTime getDateTime(LocalDateTime localDateTime){
|
public LocalDateTime getDateTime(LocalDateTime localDateTime){
|
||||||
return localDateTime.minusDays(-2);
|
return NEW_Y_YEAR.getDateTime(localDateTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* N年
|
* 五一
|
||||||
*/
|
*/
|
||||||
N_YEAR("年"){
|
WU_YI("五一"){
|
||||||
@Override
|
@Override
|
||||||
public LocalDateTime getDateTime(LocalDateTime localDateTime){
|
public LocalDateTime getDateTime(LocalDateTime localDateTime){
|
||||||
return localDateTime.minusDays(-2);
|
return localDateTime.withMonth(5).withDayOfMonth(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* N小时后
|
* 五一劳动节
|
||||||
*/
|
*/
|
||||||
N_AFTER_HOUR("小时后"){
|
WU_Y_YI("五一劳动节"){
|
||||||
@Override
|
@Override
|
||||||
public LocalDateTime getDateTime(LocalDateTime localDateTime){
|
public LocalDateTime getDateTime(LocalDateTime localDateTime){
|
||||||
return localDateTime.minusDays(-2);
|
return WU_YI.getDateTime(localDateTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* N小时
|
* 六一
|
||||||
*/
|
*/
|
||||||
N_HOUR("小时"){
|
LIU_YI("六一"){
|
||||||
@Override
|
@Override
|
||||||
public LocalDateTime getDateTime(LocalDateTime localDateTime){
|
public LocalDateTime getDateTime(LocalDateTime localDateTime){
|
||||||
return localDateTime.minusDays(-2);
|
return localDateTime.withMonth(6).withDayOfMonth(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* N分钟后
|
* 六一儿童节
|
||||||
*/
|
*/
|
||||||
N_AFTER_MINUTE("分钟后"){
|
LIU_Y_YI("六一儿童节"){
|
||||||
@Override
|
@Override
|
||||||
public LocalDateTime getDateTime(LocalDateTime localDateTime){
|
public LocalDateTime getDateTime(LocalDateTime localDateTime){
|
||||||
return localDateTime.minusDays(-2);
|
return LIU_YI.getDateTime(localDateTime);
|
||||||
}
|
|
||||||
|
|
||||||
},
|
|
||||||
/**
|
|
||||||
* N分钟
|
|
||||||
*/
|
|
||||||
N_MINUTE("分钟"){
|
|
||||||
@Override
|
|
||||||
public LocalDateTime getDateTime(LocalDateTime localDateTime){
|
|
||||||
return localDateTime.minusDays(-2);
|
|
||||||
}
|
|
||||||
|
|
||||||
},
|
|
||||||
/**
|
|
||||||
* N秒后
|
|
||||||
*/
|
|
||||||
N_AFTER_SECOND("秒后"){
|
|
||||||
@Override
|
|
||||||
public LocalDateTime getDateTime(LocalDateTime localDateTime){
|
|
||||||
return localDateTime.minusDays(-2);
|
|
||||||
}
|
|
||||||
|
|
||||||
},
|
|
||||||
/**
|
|
||||||
* N秒
|
|
||||||
*/
|
|
||||||
N_SECOND("秒"){
|
|
||||||
@Override
|
|
||||||
public LocalDateTime getDateTime(LocalDateTime localDateTime){
|
|
||||||
return localDateTime.minusDays(-2);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
@ -203,6 +416,8 @@ public enum DateEnum implements IDate{
|
|||||||
;
|
;
|
||||||
Date date;
|
Date date;
|
||||||
String code;
|
String code;
|
||||||
|
|
||||||
|
String time;
|
||||||
DateEnum(String c) {
|
DateEnum(String c) {
|
||||||
code = c;
|
code = c;
|
||||||
}
|
}
|
||||||
@ -214,6 +429,102 @@ public enum DateEnum implements IDate{
|
|||||||
return dateEnum;
|
return dateEnum;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(c.contains("天后")){
|
||||||
|
c = c.replace("天后", "");
|
||||||
|
}else if(c.contains("天前")){
|
||||||
|
c = c.replace("天前", "");
|
||||||
|
}else if(c.contains("天")){
|
||||||
|
c = c.replace("天", "");
|
||||||
|
}else if(c.contains("个月后")){
|
||||||
|
c = c.replace("个月后", "");
|
||||||
|
}else if(c.contains("个月前")){
|
||||||
|
c = c.replace("个月前", "");
|
||||||
|
}else if(c.contains("个月")){
|
||||||
|
c = c.replace("个月", "");
|
||||||
|
}else if(c.contains("月后")){
|
||||||
|
c = c.replace("月后", "");
|
||||||
|
}else if(c.contains("月前")){
|
||||||
|
c = c.replace("月前", "");
|
||||||
|
}else if(c.contains("月份")){
|
||||||
|
c = c.replace("月份", "");
|
||||||
|
}else if(c.contains("月")){
|
||||||
|
c = c.replace("月", "");
|
||||||
|
}else if(c.contains("年后")){
|
||||||
|
c = c.replace("年后", "");
|
||||||
|
}else if(c.contains("年前")){
|
||||||
|
c = c.replace("年前", "");
|
||||||
|
}else if(c.contains("年")){
|
||||||
|
c = c.replace("年", "");
|
||||||
|
}else if(c.contains("小时后")){
|
||||||
|
c = c.replace("小时后", "");
|
||||||
|
}else if(c.contains("小时前")){
|
||||||
|
c = c.replace("小时前", "");
|
||||||
|
}else if(c.contains("小时")){
|
||||||
|
c = c.replace("小时", "");
|
||||||
|
}else if(c.contains("点钟后")){
|
||||||
|
c = c.replace("点钟后", "");
|
||||||
|
}else if(c.contains("点钟前")){
|
||||||
|
c = c.replace("点钟前", "");
|
||||||
|
}else if(c.contains("点钟")){
|
||||||
|
c = c.replace("点钟", "");
|
||||||
|
}else if(c.contains("点前")){
|
||||||
|
c = c.replace("点前", "");
|
||||||
|
}else if(c.contains("点后")){
|
||||||
|
c = c.replace("点后", "");
|
||||||
|
}else if(c.contains("点")){
|
||||||
|
c = c.replace("点", "");
|
||||||
|
}else if(c.contains("时后")){
|
||||||
|
c = c.replace("时后", "");
|
||||||
|
}else if(c.contains("时前")){
|
||||||
|
c = c.replace("时前", "");
|
||||||
|
}else if(c.contains("时")){
|
||||||
|
c = c.replace("时", "");
|
||||||
|
}else if(c.contains("分钟后")){
|
||||||
|
c = c.replace("分钟后", "");
|
||||||
|
}else if(c.contains("分钟前")){
|
||||||
|
c = c.replace("分钟前", "");
|
||||||
|
}else if(c.contains("分钟")){
|
||||||
|
c = c.replace("分钟", "");
|
||||||
|
}else if(c.contains("秒后")){
|
||||||
|
c = c.replace("秒后", "");
|
||||||
|
}else if(c.contains("秒前")){
|
||||||
|
c = c.replace("秒前", "");
|
||||||
|
}else if(c.contains("秒")){
|
||||||
|
c = c.replace("秒", "");
|
||||||
|
}else if(c.contains("周")){//一周,周一
|
||||||
|
c = c.replace("周", "");
|
||||||
|
}else if(c.contains("星期")){//一星期 星期一
|
||||||
|
c = c.replace("星期", "");
|
||||||
|
}else{
|
||||||
|
//24节气,调用网络接口
|
||||||
|
}
|
||||||
|
Integer n = 1;
|
||||||
|
try{
|
||||||
|
n = Integer.parseInt(c);
|
||||||
|
}catch(Exception e){
|
||||||
|
//含有中文
|
||||||
|
Map<String, Integer> chineseToArib = new HashMap<>();
|
||||||
|
chineseToArib.put("个", 1);
|
||||||
|
chineseToArib.put("十", 10);
|
||||||
|
chineseToArib.put("百", 100);
|
||||||
|
chineseToArib.put("千", 1000);
|
||||||
|
chineseToArib.put("万", 10000);
|
||||||
|
chineseToArib.put("亿", 100000000);
|
||||||
|
chineseToArib.put("一", 1);
|
||||||
|
chineseToArib.put("二", 2);
|
||||||
|
chineseToArib.put("三", 3);
|
||||||
|
chineseToArib.put("四", 4);
|
||||||
|
chineseToArib.put("五", 5);
|
||||||
|
chineseToArib.put("六", 6);
|
||||||
|
chineseToArib.put("七", 7);
|
||||||
|
chineseToArib.put("八", 8);
|
||||||
|
chineseToArib.put("九", 9);
|
||||||
|
char[] ch = new char[c.length()];
|
||||||
|
c.getChars(0, c.length(), ch, 0);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//中英文数字
|
||||||
return DEFAULT;
|
return DEFAULT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,11 +1,16 @@
|
|||||||
package com.qiuguo.iot.third.nlp.action;
|
package com.qiuguo.iot.third.nlp.action;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import com.alibaba.fastjson.JSONArray;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.qiuguo.iot.base.date.DateEnum;
|
import com.qiuguo.iot.base.date.DateEnum;
|
||||||
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 +57,101 @@ public class ActionTime {
|
|||||||
detailTime = localDateTime;
|
detailTime = localDateTime;
|
||||||
dateTime = localDateTime.format(df);
|
dateTime = localDateTime.format(df);
|
||||||
dateDetailTime = localDateTime.format(df1);
|
dateDetailTime = localDateTime.format(df1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
JSONObject json = JSON.parseObject("{\"data\":[\"Success\",{\"name\":\"/data/wzg/vits_results/089135a743d4d438ecda93263174ab0cfe5dff0a/audio.wav\",\"data\":null,\"is_file\":true}],\"is_generating\":false,\"duration\":0.3392457962036133,\"average_duration\":0.5043019453684489}");
|
||||||
|
JSONArray array = json.getJSONArray("data");
|
||||||
|
json = array.getJSONObject(1);
|
||||||
|
String m = json.getString("name");
|
||||||
|
DateTimeFormatter df1 = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
||||||
|
LocalDateTime localDateTime = LocalDateTime.now();
|
||||||
|
localDateTime = DateEnum.getWithCode("国庆").getDateTime(DateEnum.getWithCode("拂晓").getDateTime(localDateTime));
|
||||||
|
System.out.println(localDateTime.format(df1));
|
||||||
|
|
||||||
|
int n = 1;
|
||||||
|
Map<String, Integer> chineseToArib1 = new HashMap<>();
|
||||||
|
chineseToArib1.put("个", 1);
|
||||||
|
chineseToArib1.put("十", 10);
|
||||||
|
chineseToArib1.put("百", 100);
|
||||||
|
chineseToArib1.put("千", 1000);
|
||||||
|
chineseToArib1.put("万", 10000);
|
||||||
|
chineseToArib1.put("亿", 100000000);
|
||||||
|
|
||||||
|
Map<String, Integer> chineseToArib = new HashMap<>();
|
||||||
|
chineseToArib.put("一", 1);
|
||||||
|
chineseToArib.put("二", 2);
|
||||||
|
chineseToArib.put("三", 3);
|
||||||
|
chineseToArib.put("四", 4);
|
||||||
|
chineseToArib.put("五", 5);
|
||||||
|
chineseToArib.put("六", 6);
|
||||||
|
chineseToArib.put("七", 7);
|
||||||
|
chineseToArib.put("八", 8);
|
||||||
|
chineseToArib.put("九", 9);
|
||||||
|
chineseToArib.put("零", 0);
|
||||||
|
chineseToArib.put("1", 1);
|
||||||
|
chineseToArib.put("2", 2);
|
||||||
|
chineseToArib.put("3", 3);
|
||||||
|
chineseToArib.put("4", 4);
|
||||||
|
chineseToArib.put("5", 5);
|
||||||
|
chineseToArib.put("6", 6);
|
||||||
|
chineseToArib.put("7", 7);
|
||||||
|
chineseToArib.put("8", 8);
|
||||||
|
chineseToArib.put("9", 9);
|
||||||
|
chineseToArib.put("0", 0);
|
||||||
|
String c = "一";
|
||||||
|
char[] ch = new char[c.length()];
|
||||||
|
c.getChars(0, c.length(), ch, 0);
|
||||||
|
Integer p = 1;
|
||||||
|
String v = String.valueOf(n);
|
||||||
|
String key;
|
||||||
|
for(char h : ch){
|
||||||
|
key = String.valueOf(h);
|
||||||
|
if(chineseToArib1.containsKey(key)){
|
||||||
|
p = chineseToArib.get(key);
|
||||||
|
}else if(chineseToArib.containsKey(key)){
|
||||||
|
n *= p;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
c = "一十二";
|
||||||
|
ch = new char[c.length()];
|
||||||
|
c.getChars(0, c.length(), ch, 0);
|
||||||
|
p = 1;
|
||||||
|
n = 1;
|
||||||
|
v = String.valueOf(n);
|
||||||
|
for(char h : ch){
|
||||||
|
if(chineseToArib1.containsKey(String.valueOf(h))){
|
||||||
|
p = chineseToArib.get(String.valueOf(h));
|
||||||
|
}else if(chineseToArib.containsKey(String.valueOf(h))){
|
||||||
|
n *= p;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
c = "十一";
|
||||||
|
ch = new char[c.length()];
|
||||||
|
c.getChars(0, c.length(), ch, 0);
|
||||||
|
p = 1;
|
||||||
|
n = 1;
|
||||||
|
v = String.valueOf(n);
|
||||||
|
for(char h : ch){
|
||||||
|
if(chineseToArib1.containsKey(h)){
|
||||||
|
p = chineseToArib.get(h);
|
||||||
|
}else if(chineseToArib.containsKey(h)){
|
||||||
|
n *= p;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
c = "一百零三";
|
||||||
|
ch = new char[c.length()];
|
||||||
|
c.getChars(0, c.length(), ch, 0);
|
||||||
|
p = 1;
|
||||||
|
n = 1;
|
||||||
|
v = String.valueOf(n);
|
||||||
|
for(char h : ch){
|
||||||
|
if(chineseToArib1.containsKey(h)){
|
||||||
|
p = chineseToArib.get(h);
|
||||||
|
}else if(chineseToArib.containsKey(h)){
|
||||||
|
n *= p;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
System.out.println(v);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,12 @@
|
|||||||
|
package com.qiuguo.iot.third.request;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class AudioRequest {
|
||||||
|
|
||||||
|
List<Object> data;
|
||||||
|
Integer fn_index = 0;
|
||||||
|
}
|
||||||
@ -0,0 +1,55 @@
|
|||||||
|
package com.qiuguo.iot.third.service;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONArray;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.qiuguo.iot.base.enums.DeviceTypeEnum;
|
||||||
|
import com.qiuguo.iot.base.enums.KeyTypeEnum;
|
||||||
|
import com.qiuguo.iot.base.utils.StringUtils;
|
||||||
|
import com.qiuguo.iot.base.utils.WebClientUtils;
|
||||||
|
import com.qiuguo.iot.data.entity.device.DeviceUserBindEntity;
|
||||||
|
import com.qiuguo.iot.data.entity.system.SystemTalkAnswerConfigEntity;
|
||||||
|
import com.qiuguo.iot.data.request.device.DeviceUserBindRequest;
|
||||||
|
import com.qiuguo.iot.data.service.device.DeviceUserBindService;
|
||||||
|
import com.qiuguo.iot.data.service.system.SystemTalkAnswerConfigService;
|
||||||
|
import com.qiuguo.iot.third.enums.ChinesePartSpeechEnum;
|
||||||
|
import com.qiuguo.iot.third.nlp.NlpKey;
|
||||||
|
import com.qiuguo.iot.third.nlp.action.Action;
|
||||||
|
import com.qiuguo.iot.third.nlp.action.Actions;
|
||||||
|
import com.qiuguo.iot.third.nlp.entity.SystemTalkKeyAndDeviceName;
|
||||||
|
import com.qiuguo.iot.third.request.AudioRequest;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import reactor.core.publisher.Mono;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Comparator;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 算法提供的语音合成
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
@Slf4j
|
||||||
|
public class AudioService {
|
||||||
|
public Mono<String> getAudioUrl(String v){
|
||||||
|
AudioRequest request = new AudioRequest();
|
||||||
|
request.setData(new ArrayList<>(4));
|
||||||
|
request.getData().add(v);
|
||||||
|
request.getData().add("zxo");
|
||||||
|
request.getData().add("简体中文");
|
||||||
|
request.getData().add(1);
|
||||||
|
/*String[] data = new String[3];
|
||||||
|
data[0] = v;
|
||||||
|
data[1] = "zxo";
|
||||||
|
data[2] = "简体中文";
|
||||||
|
request.setData(data);*/
|
||||||
|
|
||||||
|
return WebClientUtils.post("http://192.168.8.211:18000/run/predict", (JSONObject)JSONObject.toJSON(request)).flatMap(jsonObject -> {
|
||||||
|
JSONArray array = jsonObject.getJSONArray("data");
|
||||||
|
jsonObject = array.getJSONObject(1);
|
||||||
|
String m = jsonObject.getString("name").replaceAll("/data/wzg/vits_results", "http://192.168.8.211:8880");
|
||||||
|
return Mono.just(m);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -123,6 +123,10 @@ public class NlpService {
|
|||||||
|
|
||||||
for (NlpKey key : nlp.getKeys()
|
for (NlpKey key : nlp.getKeys()
|
||||||
) {
|
) {
|
||||||
|
if(key.getKey().equals(" ")){
|
||||||
|
//空格跳过
|
||||||
|
continue;
|
||||||
|
}
|
||||||
action = ChinesePartSpeechEnum.getEnumWithCode(key.getType()).getAction(systemTalkAnswerConfigService.getSystemTalkWithKeyGroup(),
|
action = ChinesePartSpeechEnum.getEnumWithCode(key.getType()).getAction(systemTalkAnswerConfigService.getSystemTalkWithKeyGroup(),
|
||||||
key.getKey(),
|
key.getKey(),
|
||||||
actions,
|
actions,
|
||||||
|
|||||||
@ -24,4 +24,9 @@ public class BoxMessageResp extends BaseMessageResp {
|
|||||||
* 时间
|
* 时间
|
||||||
*/
|
*/
|
||||||
DateTimeResp time;
|
DateTimeResp time;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 音频播放地址
|
||||||
|
*/
|
||||||
|
String audio;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -85,6 +85,9 @@ public class BaseWebSocketProcess {
|
|||||||
@Autowired
|
@Autowired
|
||||||
protected MqService mqService;
|
protected MqService mqService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
AudioService audioService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
protected SystemTalkBindU3dService systemTalkBindU3dService;
|
protected SystemTalkBindU3dService systemTalkBindU3dService;
|
||||||
|
|
||||||
@ -708,7 +711,18 @@ public class BaseWebSocketProcess {
|
|||||||
|
|
||||||
private void sendMsg(BaseSession baseSession, String msg) {
|
private void sendMsg(BaseSession baseSession, String msg) {
|
||||||
log.info("推到终端:{},SN:{},userId:{},消息内容:{}", baseSession.getSessionType(), baseSession.getSn(), baseSession.getUserId(), msg);
|
log.info("推到终端:{},SN:{},userId:{},消息内容:{}", baseSession.getSessionType(), baseSession.getSn(), baseSession.getUserId(), msg);
|
||||||
baseSession.getSink().next(baseSession.getSession().textMessage(msg));
|
if(this instanceof BoxWebSocketHandler){
|
||||||
|
BoxMessageResp boxMessageResp = JSONObject.parseObject(msg, BoxMessageResp.class);
|
||||||
|
audioService.getAudioUrl(boxMessageResp.getText()).map(s ->{
|
||||||
|
log.info("音频地址:{}", s);
|
||||||
|
boxMessageResp.setAudio(s);
|
||||||
|
baseSession.getSink().next(baseSession.getSession().textMessage(JSONObject.toJSONString(boxMessageResp)));
|
||||||
|
return s;
|
||||||
|
}).subscribe();
|
||||||
|
}else{
|
||||||
|
baseSession.getSink().next(baseSession.getSession().textMessage(msg));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user