|
|
@ -1,6 +1,7 @@
|
|
|
|
package com.supervision.util;
|
|
|
|
package com.supervision.util;
|
|
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
|
|
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
|
import cn.hutool.http.HttpUtil;
|
|
|
|
import cn.hutool.http.HttpUtil;
|
|
|
|
import cn.hutool.json.JSONUtil;
|
|
|
|
import cn.hutool.json.JSONUtil;
|
|
|
|
import com.fasterxml.jackson.core.type.TypeReference;
|
|
|
|
import com.fasterxml.jackson.core.type.TypeReference;
|
|
|
@ -9,8 +10,10 @@ import com.supervision.exception.BusinessException;
|
|
|
|
import com.supervision.pojo.paddlespeech.req.TtsReqDTO;
|
|
|
|
import com.supervision.pojo.paddlespeech.req.TtsReqDTO;
|
|
|
|
import com.supervision.pojo.paddlespeech.res.PaddleSpeechResDTO;
|
|
|
|
import com.supervision.pojo.paddlespeech.res.PaddleSpeechResDTO;
|
|
|
|
import com.supervision.pojo.paddlespeech.res.TtsResultDTO;
|
|
|
|
import com.supervision.pojo.paddlespeech.res.TtsResultDTO;
|
|
|
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
import org.springframework.core.env.Environment;
|
|
|
|
import org.springframework.core.env.Environment;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Slf4j
|
|
|
|
public class TtsUtil {
|
|
|
|
public class TtsUtil {
|
|
|
|
|
|
|
|
|
|
|
|
private static final String TTS_URL = SpringBeanUtil.getBean(Environment.class).getProperty("paddle-speech.tts");
|
|
|
|
private static final String TTS_URL = SpringBeanUtil.getBean(Environment.class).getProperty("paddle-speech.tts");
|
|
|
@ -18,6 +21,11 @@ public class TtsUtil {
|
|
|
|
private static final ObjectMapper objectMapper = new ObjectMapper();
|
|
|
|
private static final ObjectMapper objectMapper = new ObjectMapper();
|
|
|
|
|
|
|
|
|
|
|
|
public static String ttsTransform(String str) {
|
|
|
|
public static String ttsTransform(String str) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (StrUtil.isEmpty(str)){
|
|
|
|
|
|
|
|
log.info("ttsTransform: str is empty");
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
}
|
|
|
|
// 构建
|
|
|
|
// 构建
|
|
|
|
String post = HttpUtil.post(TTS_URL, JSONUtil.toJsonStr(new TtsReqDTO(str)));
|
|
|
|
String post = HttpUtil.post(TTS_URL, JSONUtil.toJsonStr(new TtsReqDTO(str)));
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|