模型调整以及业务流程处理
This commit is contained in:
@@ -10,6 +10,7 @@ import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
@@ -38,7 +39,12 @@ public class AiCommonController extends BaseController
|
||||
@GetMapping("/handleTextToVice")
|
||||
public AjaxResult handleTextToVice()
|
||||
{
|
||||
elevenLabsClient.handleTextToVoice("Hello ! I can","/Users/wangxiangshun/Desktop/临时文件/output1112.wav");
|
||||
//你好,我是本次的面试官Vetti,请点击开始按钮后,做一段自我介绍.
|
||||
elevenLabsClient.handleTextToVoice("Hello, I am Vetti, the interviewer for this interview. Please click the start button and give a self introduction","/Users/wangxiangshun/Desktop/临时文件/opening2.wav");
|
||||
|
||||
elevenLabsClient.handleTextToVoice("Good","/Users/wangxiangshun/Desktop/临时文件/good.wav");
|
||||
|
||||
|
||||
return success();
|
||||
}
|
||||
|
||||
@@ -47,9 +53,9 @@ public class AiCommonController extends BaseController
|
||||
*/
|
||||
@ApiOperation("AI 聊天")
|
||||
@GetMapping("/handleAiChat")
|
||||
public AjaxResult handleAiChat()
|
||||
public AjaxResult handleAiChat(@RequestParam String text)
|
||||
{
|
||||
String resultMsg = chatGPTClient.handleAiChat("你好,我叫wangxiangshun");
|
||||
String resultMsg = chatGPTClient.handleAiChat(text);
|
||||
return AjaxResult.success(resultMsg);
|
||||
}
|
||||
|
||||
|
||||
@@ -159,7 +159,7 @@ whisper:
|
||||
chatGpt:
|
||||
apiKey: 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
|
||||
apiUrl: https://api.openai.com/v1/chat/completions
|
||||
model: gpt-3.5-turbo
|
||||
model: ft:gpt-3.5-turbo-0125:vetti:construction-labourer-test:CTIvLD5n
|
||||
role: user
|
||||
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ public class ElevenLabsClient {
|
||||
Map<String, Object> payload = new HashMap<>();
|
||||
payload.put("text", text);
|
||||
payload.put("model_id", modelId);
|
||||
payload.put("voice_settings", new VoiceSettings(0.85, 0.5,1.1,0,0.9));
|
||||
payload.put("voice_settings", new VoiceSettings(0.85, 0.5,0.1,0,0.9,0.8));
|
||||
Gson gson = new Gson();
|
||||
StringEntity entity = new StringEntity(gson.toJson(payload), ContentType.APPLICATION_JSON);
|
||||
httpPost.setEntity(entity);
|
||||
@@ -102,12 +102,6 @@ public class ElevenLabsClient {
|
||||
public String handleTextToVoice(String inputText,String outputFile){
|
||||
CloseableHttpClient httpClient = HttpClients.createDefault();
|
||||
try {
|
||||
// // 获取可用语音
|
||||
// VoicesResponse voicesResponse = getVoices(httpClient);
|
||||
// if (voicesResponse != null && voicesResponse.getVoices() != null
|
||||
// && voicesResponse.getVoices().length > 0) {
|
||||
//
|
||||
// }
|
||||
// 使用第一个可用语音进行文本转语音(澳洲本地女声)
|
||||
String firstVoiceId = "21m00Tcm4TlvDq8ikWAM";
|
||||
textToSpeech(inputText, firstVoiceId, outputFile,httpClient);
|
||||
|
||||
@@ -18,12 +18,15 @@ public class VoiceSettings {
|
||||
|
||||
private double clarity;
|
||||
|
||||
public VoiceSettings(double stability, double similarity_boost, double rate,double start_time,double clarity) {
|
||||
private double speed;
|
||||
|
||||
public VoiceSettings(double stability, double similarity_boost, double rate,double start_time,double clarity, double speed) {
|
||||
this.stability = stability;
|
||||
this.similarity_boost = similarity_boost;
|
||||
this.rate = rate;
|
||||
this.start_time = start_time;
|
||||
this.clarity = clarity;
|
||||
this.speed = speed;
|
||||
}
|
||||
|
||||
// getter方法
|
||||
@@ -45,4 +48,9 @@ public class VoiceSettings {
|
||||
public double getClarity() {
|
||||
return clarity;
|
||||
}
|
||||
|
||||
public double getSpeed() {
|
||||
return speed;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user