xf 维语转语音

This commit is contained in:
ran.shang
2025-08-22 15:52:49 +08:00
parent cc8c388925
commit 5effd9bcf4
5 changed files with 76 additions and 17 deletions

View File

@@ -22,6 +22,7 @@ import com.newyetai.component.file.util.FileUtils;
import com.newyetai.config.service.ConfigService;
import com.newyetai.sdk.xf.config.XfProperties;
import com.newyetai.sdk.xf.dto.InterviewContentDTO;
import com.newyetai.sdk.xf.dto.TtsReqDTO;
import com.newyetai.sdk.xf.model.ChatReq;
import com.newyetai.sdk.xf.model.MessageDTO;
import com.newyetai.sdk.xf.service.XfSparkProvider;
@@ -123,15 +124,14 @@ public class XfUtils {
}
/**
* 语音合成
* @return
* @author sr on 2025-01-09
*/
public static String tts(String text) {
public static String tts(TtsReqDTO ttsReq) {
try(ByteArrayOutputStream outputStream = new ByteArrayOutputStream()){
AlitaResult<Void> result = WebTtsWS.execute(text, xfProperties, outputStream);
AlitaResult<Void> result = WebTtsWS.execute(ttsReq, xfProperties, outputStream);
Assert.isTrue(result.getSuccess(), result.getMsg());
FileRecord fileRecord = fileService.upload("语音合成.mp3", outputStream.toByteArray());
return fileRecord.getFileCode();