TTS 返回语音优化
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.8, 0.5,1));
|
||||
payload.put("voice_settings", new VoiceSettings(0.8, 0.5,1,0));
|
||||
Gson gson = new Gson();
|
||||
StringEntity entity = new StringEntity(gson.toJson(payload), ContentType.APPLICATION_JSON);
|
||||
httpPost.setEntity(entity);
|
||||
@@ -102,14 +102,15 @@ 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);
|
||||
}
|
||||
// // 获取可用语音
|
||||
// VoicesResponse voicesResponse = getVoices(httpClient);
|
||||
// if (voicesResponse != null && voicesResponse.getVoices() != null
|
||||
// && voicesResponse.getVoices().length > 0) {
|
||||
//
|
||||
// }
|
||||
// 使用第一个可用语音进行文本转语音(澳洲本地女声)
|
||||
String firstVoiceId = "21m00Tcm4TlvDq8ikWAM";
|
||||
textToSpeech(inputText, firstVoiceId, outputFile,httpClient);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
|
||||
@@ -14,10 +14,13 @@ public class VoiceSettings {
|
||||
|
||||
private double similarity_boost;
|
||||
|
||||
public VoiceSettings(double stability, double similarity_boost, double speed) {
|
||||
private double start_time;
|
||||
|
||||
public VoiceSettings(double stability, double similarity_boost, double speed,double start_time) {
|
||||
this.stability = stability;
|
||||
this.similarity_boost = similarity_boost;
|
||||
this.speed = speed;
|
||||
this.start_time = start_time;
|
||||
}
|
||||
|
||||
// getter方法
|
||||
|
||||
Reference in New Issue
Block a user