语音优化
This commit is contained in:
@@ -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