3 Commits
v63 ... v66

Author SHA1 Message Date
Andrew Stein
a8630ceeb0 Simplified some code 2023-11-24 14:45:02 -05:00
andrewstein
7593f3a3f1 Added getDownloadUrl() support for HistoryItem's. 2023-11-24 14:40:30 -05:00
Andrew Stein
5288fde44e Fixed bug in speech to speech code. 2023-11-16 17:44:39 -05:00
13 changed files with 28 additions and 12 deletions

View File

@@ -60,7 +60,7 @@
<groupId>net.andrewcpu</groupId>
<artifactId>elevenlabs-api</artifactId>
<version>2.7.4-SNAPSHOT</version>
<version>2.7.6-SNAPSHOT</version>
<properties>
<maven.compiler.source>11</maven.compiler.source>

View File

@@ -4,6 +4,7 @@ import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import net.andrewcpu.elevenlabs.ElevenLabs;
import net.andrewcpu.elevenlabs.model.ElevenModel;
import net.andrewcpu.elevenlabs.util.ElevenNetworkUtil;
import java.io.File;
import java.util.Map;
@@ -131,6 +132,10 @@ public class HistoryItem extends ElevenModel {
return ElevenLabs.getHistoryAPI().getHistoryItemAudio(historyItemId);
}
public String getDownloadUrl() {
return ElevenNetworkUtil.getHistoryItemUrl(historyItemId);
}
@JsonIgnore
@Override
public String toString() {

View File

@@ -37,6 +37,4 @@ public abstract class ElevenLabsRequest<T> {
}
public abstract Object getPayload();
}

View File

@@ -3,7 +3,6 @@ package net.andrewcpu.elevenlabs.requests.projects;
import net.andrewcpu.elevenlabs.requests.DeleteRequest;
public class DeleteChapterByIdRequest extends DeleteRequest<String> {
public DeleteChapterByIdRequest(String projectId, String chapterId) {
super("v1/projects/" + projectId + "/chapters/" + chapterId, String.class);
}

View File

@@ -7,5 +7,4 @@ public class GetChapterSnapshotsRequest extends GetRequest<ChapterSnapshotsModel
public GetChapterSnapshotsRequest(String projectId, String chapterId) {
super("v1/projects/" + projectId + "/chapters/" + chapterId + "/snapshots", ChapterSnapshotsModelResponse.class);
}
}

View File

@@ -6,5 +6,4 @@ public class PostConvertChapterRequest extends PostRequest<String> {
public PostConvertChapterRequest(String projectId, String chapterId) {
super("v1/projects/" + projectId + "/chapters/" + chapterId + "/convert", String.class);
}
}

View File

@@ -6,5 +6,4 @@ public class PostConvertProjectRequest extends PostRequest<String> {
public PostConvertProjectRequest(String projectId) {
super("v1/projects/" + projectId + "/convert", String.class);
}
}

View File

@@ -8,5 +8,4 @@ public class PostStreamChapterSnapshotAudioRequest extends PostRequest<InputStre
public PostStreamChapterSnapshotAudioRequest(String projectId, String chapterId, String chapterSnapshotId) {
super("v1/projects/" + projectId + "/chapters/" + chapterId + "/snapshots/" + chapterSnapshotId + "/stream", InputStream.class);
}
}

View File

@@ -8,5 +8,4 @@ public class PostStreamProjectSnapshotAudioRequest extends PostRequest<InputStre
public PostStreamProjectSnapshotAudioRequest(String projectId, String snapshotId) {
super("v1/projects/" + projectId + "/snapshots/" + snapshotId + "/stream", InputStream.class);
}
}

View File

@@ -1,5 +1,7 @@
package net.andrewcpu.elevenlabs.requests.sts;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import net.andrewcpu.elevenlabs.enums.StreamLatencyOptimization;
import net.andrewcpu.elevenlabs.model.voice.VoiceSettings;
import net.andrewcpu.elevenlabs.requests.PostRequest;
@@ -31,9 +33,15 @@ public class PostSpeechToSpeechRequest extends PostRequest<File> {
@Override
public Object getPayload() {
Map<String, Object> body = new HashMap<>();
String voiceSettingsString;
try {
voiceSettingsString = new ObjectMapper().writeValueAsString(voiceSettings);
} catch (JsonProcessingException e) {
throw new RuntimeException(e);
}
body.put("audio", audio);
body.put("model_id", modelId);
body.put("voice_settings", voiceSettings);
body.put("voice_settings", voiceSettingsString);
return body;
}
}

View File

@@ -1,5 +1,7 @@
package net.andrewcpu.elevenlabs.requests.sts;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import net.andrewcpu.elevenlabs.enums.StreamLatencyOptimization;
import net.andrewcpu.elevenlabs.model.voice.VoiceSettings;
import net.andrewcpu.elevenlabs.requests.PostRequest;
@@ -32,9 +34,15 @@ public class PostSpeechToSpeechStreamedRequest extends PostRequest<InputStream>
@Override
public Object getPayload() {
Map<String, Object> body = new HashMap<>();
String voiceSettingsString;
try {
voiceSettingsString = new ObjectMapper().writeValueAsString(voiceSettings);
} catch (JsonProcessingException e) {
throw new RuntimeException(e);
}
body.put("audio", audio);
body.put("model_id", modelId);
body.put("voice_settings", voiceSettings);
body.put("voice_settings", voiceSettingsString);
return body;
}
}

View File

@@ -25,5 +25,4 @@ public class GetVoiceRequest extends GetRequest<Voice> {
payload.put("with_settings", String.valueOf(withSettings));
return payload;
}
}

View File

@@ -137,6 +137,10 @@ public class ElevenNetworkUtil {
return request;
}
public static String getHistoryItemUrl(String historyItemId) {
return BASE_URL + "v1/history/" + historyItemId + "/audio";
}
public static <T> T sendRequest(HttpRequestType method, String path, Object payload, Class<T> responseType) {
ObjectMapper objectMapper = new ObjectMapper();
path = BASE_URL + path;