xf实时语音转写
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
package com.newyetai.sdk.xf.util;
|
||||
|
||||
import com.newyetai.sdk.xf.dto.RtasrReqDTO;
|
||||
import com.newyetai.sdk.xf.model.TranslateReq;
|
||||
import com.newyetai.sdk.xf.service.RtasrClientApp;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
@@ -99,7 +101,7 @@ public class XfUtils {
|
||||
|
||||
/**
|
||||
* 语音听写
|
||||
* @param filePath
|
||||
* @param fileCode
|
||||
* @return
|
||||
* @author sr on 2025-01-09
|
||||
*/
|
||||
@@ -117,7 +119,6 @@ public class XfUtils {
|
||||
|
||||
/**
|
||||
* 语音合成
|
||||
* @param filePath
|
||||
* @return
|
||||
* @author sr on 2025-01-09
|
||||
*/
|
||||
@@ -230,16 +231,42 @@ public class XfUtils {
|
||||
return result.getData();
|
||||
}
|
||||
|
||||
/**
|
||||
* 对话
|
||||
* @param req
|
||||
* @return
|
||||
*/
|
||||
public static String chat(ChatReq req) {
|
||||
AlitaResult<String> result = XfSparkProvider.httpChat(req);
|
||||
Assert.isTrue(result.getSuccess(), result.getMsg());
|
||||
return result.getData();
|
||||
}
|
||||
|
||||
/**
|
||||
* 翻译
|
||||
* @param req
|
||||
* @return
|
||||
*/
|
||||
public static String translate(TranslateReq req) {
|
||||
AlitaResult<String> result = XfSparkProvider.translate(req);
|
||||
Assert.isTrue(result.getSuccess(), result.getMsg());
|
||||
return result.getData();
|
||||
}
|
||||
|
||||
/**
|
||||
* 实时语音转写
|
||||
* @param reqDTO
|
||||
* @return
|
||||
*/
|
||||
public static String rtasr(RtasrReqDTO reqDTO) {
|
||||
try (InputStream is = fileRecordService.getFile(reqDTO.getFileCode())){
|
||||
AlitaResult<String> result = RtasrClientApp.execute(is, reqDTO.getFrom(), xfProperties);
|
||||
Assert.isTrue(result.getSuccess(), result.getMsg());
|
||||
return result.getData();
|
||||
} catch (Exception e) {
|
||||
throw new BusinessException("语音听写异常:" + e.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user