6 Commits
v63 ... v68

Author SHA1 Message Date
Andrew Stein
cc360a258e Merge pull request #12 from Andrewcpu/Andrewcpu-patch-1
Update README.md
2023-11-24 20:18:01 -05:00
Andrew Stein
9c7fffbb9a Update README.md
PSA About speech to speech and version update
2023-11-24 20:17:42 -05:00
Andrew Stein
4cfd14fb95 Updated POM 2023-11-24 14:45:31 -05:00
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
14 changed files with 31 additions and 13 deletions

View File

@@ -4,6 +4,8 @@
## Getting Started
So you wanna make custom voices, huh? Well you've come to the right place.
This library should cover all the ElevenLabs API endpoints as of 11/15/23.
**Update**
It seems I jumped the gun (or happened to bump into an accidental push of the speech to speech API docs), but the original documentation that my implementation was based on has now been removed or hidden. It may reappear as is, or will require changes.
### Installation
**Maven**
@@ -13,7 +15,7 @@ To add `elevenlabs-api` to your Maven project, use:
<dependency>
<groupId>net.andrewcpu</groupId>
<artifactId>elevenlabs-api</artifactId>
<version>2.7.2</version>
<version>2.7.7</version>
</dependency>
```
**JAR**

View File

@@ -60,7 +60,7 @@
<groupId>net.andrewcpu</groupId>
<artifactId>elevenlabs-api</artifactId>
<version>2.7.4-SNAPSHOT</version>
<version>2.7.7-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;