|
@@ -1,73 +0,0 @@ |
|
|
package com.iformall.sm; |
|
|
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSON; |
|
|
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
|
|
import com.iformall.utils.Base64Util; |
|
|
|
|
|
import com.iformall.utils.HttpUtil; |
|
|
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
|
|
import org.springframework.beans.factory.annotation.Value; |
|
|
|
|
|
import org.springframework.stereotype.Component; |
|
|
|
|
|
|
|
|
|
|
|
@Slf4j |
|
|
|
|
|
@Component |
|
|
|
|
|
public class AiTtsHelper { |
|
|
|
|
|
|
|
|
|
|
|
public static String huibo_tts_wav; |
|
|
|
|
|
@Value("${suimang.huibo_tts_wav}") |
|
|
|
|
|
public void setHuiboTtsWav(String huibo_tts_wav) { |
|
|
|
|
|
this.huibo_tts_wav = huibo_tts_wav; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static String doPost(String url, String params) { |
|
|
|
|
|
return HttpUtil.doAiVideoPost(url,params); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//慧播预览 |
|
|
|
|
|
public static AiPreviewResult voicePreview(AiPreviewParam param) { |
|
|
|
|
|
String response = doPost(huibo_tts_wav + "/tts_wav", JSONObject.toJSONString(param)); |
|
|
|
|
|
log.info("TTS音色预览 end response:" + response); |
|
|
|
|
|
AiPreviewResult result = new AiPreviewResult(); |
|
|
|
|
|
|
|
|
|
|
|
if (StringUtils.isBlank(response)) { |
|
|
|
|
|
result.setSuccess(false); |
|
|
|
|
|
result.setMsg("(MetaService) no result"); |
|
|
|
|
|
return result; |
|
|
|
|
|
} |
|
|
|
|
|
JSONObject jsonObject = JSON.parseObject(response); |
|
|
|
|
|
JSONObject status = jsonObject.getJSONObject("status"); |
|
|
|
|
|
|
|
|
|
|
|
Integer code = status.getInteger("code"); |
|
|
|
|
|
String msg = status.getString("msg"); |
|
|
|
|
|
if (code == null) { |
|
|
|
|
|
result.setSuccess(false); |
|
|
|
|
|
result.setMsg("(MetaService) error."+msg); |
|
|
|
|
|
return result; |
|
|
|
|
|
} |
|
|
|
|
|
if (code.intValue() == 3000) { |
|
|
|
|
|
JSONObject data = jsonObject.getJSONObject("data"); |
|
|
|
|
|
String strURL = data.getString("url"); |
|
|
|
|
|
String time = data.getString("time"); |
|
|
|
|
|
|
|
|
|
|
|
result.setCode(200); |
|
|
|
|
|
result.setSuccess(true); |
|
|
|
|
|
result.setUrl(huibo_tts_wav + strURL); |
|
|
|
|
|
result.setTime(Double.valueOf(time)); |
|
|
|
|
|
result.setMsg("(MetaService) error."+msg); |
|
|
|
|
|
} else { |
|
|
|
|
|
result.setCode(code); |
|
|
|
|
|
result.setSuccess(false); |
|
|
|
|
|
result.setMsg("(MetaService) error."+msg); |
|
|
|
|
|
} |
|
|
|
|
|
return result; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static void main(String[] args) { |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|