语音优化
This commit is contained in:
@@ -38,7 +38,7 @@ public class AiCommonController extends BaseController
|
||||
@GetMapping("/handleTextToVice")
|
||||
public AjaxResult handleTextToVice()
|
||||
{
|
||||
elevenLabsClient.handleTextToVoice("我只是测试的文本转换成语音","/Users/wangxiangshun/Desktop/临时文件/output.mp3");
|
||||
elevenLabsClient.handleTextToVoice("我只是测试的文本转换成语音","/Users/wangxiangshun/Desktop/临时文件/output1112.mp3");
|
||||
return success();
|
||||
}
|
||||
|
||||
|
||||
@@ -160,7 +160,7 @@ whisper:
|
||||
chatGpt:
|
||||
apiKey: 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
|
||||
apiUrl: https://api.openai.com/v1/chat/completions
|
||||
model: gpt-3.5-turbo
|
||||
model: gpt-4
|
||||
role: user
|
||||
|
||||
|
||||
|
||||
@@ -158,7 +158,7 @@ whisper:
|
||||
chatGpt:
|
||||
apiKey: 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
|
||||
apiUrl: https://api.openai.com/v1/chat/completions
|
||||
model: gpt-3.5-turbo
|
||||
model: gpt-4
|
||||
role: user
|
||||
|
||||
|
||||
|
||||
@@ -158,7 +158,7 @@ whisper:
|
||||
chatGpt:
|
||||
apiKey: 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
|
||||
apiUrl: https://api.openai.com/v1/chat/completions
|
||||
model: gpt-3.5-turbo
|
||||
model: gpt-4
|
||||
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.7, 0.5));
|
||||
payload.put("voice_settings", new VoiceSettings(0.8, 0.5,1));
|
||||
Gson gson = new Gson();
|
||||
StringEntity entity = new StringEntity(gson.toJson(payload), ContentType.APPLICATION_JSON);
|
||||
httpPost.setEntity(entity);
|
||||
@@ -107,7 +107,8 @@ public class ElevenLabsClient {
|
||||
if (voicesResponse != null && voicesResponse.getVoices() != null
|
||||
&& voicesResponse.getVoices().length > 0) {
|
||||
// 使用第一个可用语音进行文本转语音
|
||||
String firstVoiceId = voicesResponse.getVoices()[0].getVoice_id();
|
||||
// String firstVoiceId = voicesResponse.getVoices()[0].getVoice_id();
|
||||
String firstVoiceId = "21m00Tcm4TlvDq8ikWAM";
|
||||
textToSpeech(inputText, firstVoiceId, outputFile,httpClient);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
|
||||
@@ -5,12 +5,19 @@ package com.vetti.common.ai.elevenLabs.vo;
|
||||
*/
|
||||
public class VoiceSettings {
|
||||
|
||||
/**
|
||||
* 设置语速
|
||||
*/
|
||||
private double speed;
|
||||
// 可选:其他语音配置(如稳定性stability、相似度boost,默认无需设置)
|
||||
private double stability;
|
||||
|
||||
private double similarity_boost;
|
||||
|
||||
public VoiceSettings(double stability, double similarity_boost) {
|
||||
public VoiceSettings(double stability, double similarity_boost, double speed) {
|
||||
this.stability = stability;
|
||||
this.similarity_boost = similarity_boost;
|
||||
this.speed = speed;
|
||||
}
|
||||
|
||||
// getter方法
|
||||
@@ -22,4 +29,6 @@ public class VoiceSettings {
|
||||
return similarity_boost;
|
||||
}
|
||||
|
||||
public double getSpeed() { return speed; }
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user