mirror of
https://github.com/Andrewcpu/elevenlabs-api.git
synced 2026-05-06 03:00:23 -04:00
Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
95cf38c620 | ||
|
|
6968219c55 | ||
|
|
e6279b689f | ||
|
|
3462385f3d | ||
|
|
0bca63fd50 | ||
|
|
f7998ee0f9 | ||
|
|
22cdc7146c | ||
|
|
e746eeaea9 |
4
.github/workflows/build.yml
vendored
4
.github/workflows/build.yml
vendored
@@ -17,11 +17,11 @@ jobs:
|
|||||||
- name: Set up Java
|
- name: Set up Java
|
||||||
uses: actions/setup-java@v2
|
uses: actions/setup-java@v2
|
||||||
with:
|
with:
|
||||||
java-version: '17'
|
java-version: '11'
|
||||||
distribution: 'zulu'
|
distribution: 'zulu'
|
||||||
|
|
||||||
- name: Build with Maven
|
- name: Build with Maven
|
||||||
run: mvn clean package
|
run: mvn clean package -Dmaven.test.skip
|
||||||
|
|
||||||
- name: Read version from POM file
|
- name: Read version from POM file
|
||||||
id: version
|
id: version
|
||||||
|
|||||||
9
pom.xml
9
pom.xml
@@ -34,7 +34,7 @@
|
|||||||
|
|
||||||
<groupId>net.andrewcpu</groupId>
|
<groupId>net.andrewcpu</groupId>
|
||||||
<artifactId>elevenlabs-api</artifactId>
|
<artifactId>elevenlabs-api</artifactId>
|
||||||
<version>1.1-SNAPSHOT</version>
|
<version>2.0-SNAPSHOT</version>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<maven.compiler.source>11</maven.compiler.source>
|
<maven.compiler.source>11</maven.compiler.source>
|
||||||
@@ -51,21 +51,16 @@
|
|||||||
</licenses>
|
</licenses>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind -->
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.fasterxml.jackson.core</groupId>
|
<groupId>com.fasterxml.jackson.core</groupId>
|
||||||
<artifactId>jackson-databind</artifactId>
|
<artifactId>jackson-databind</artifactId>
|
||||||
<version>2.13.4.1</version>
|
<version>2.13.4.1</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-annotations -->
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.fasterxml.jackson.core</groupId>
|
<groupId>com.fasterxml.jackson.core</groupId>
|
||||||
<artifactId>jackson-annotations</artifactId>
|
<artifactId>jackson-annotations</artifactId>
|
||||||
<version>2.13.4</version>
|
<version>2.13.4</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-core -->
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.fasterxml.jackson.core</groupId>
|
<groupId>com.fasterxml.jackson.core</groupId>
|
||||||
<artifactId>jackson-core</artifactId>
|
<artifactId>jackson-core</artifactId>
|
||||||
@@ -91,7 +86,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>junit</groupId>
|
<groupId>junit</groupId>
|
||||||
<artifactId>junit</artifactId>
|
<artifactId>junit</artifactId>
|
||||||
<version>4.12</version>
|
<version>4.13.1</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|||||||
@@ -2,11 +2,17 @@ package net.andrewcpu.elevenlabs.model.history;
|
|||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import net.andrewcpu.elevenlabs.ElevenLabs;
|
||||||
import net.andrewcpu.elevenlabs.model.ElevenModel;
|
import net.andrewcpu.elevenlabs.model.ElevenModel;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class History extends ElevenModel {
|
public class History extends ElevenModel {
|
||||||
|
|
||||||
|
public static History get() {
|
||||||
|
return ElevenLabs.getHistory();
|
||||||
|
}
|
||||||
|
|
||||||
@JsonProperty("history")
|
@JsonProperty("history")
|
||||||
private List<HistoryItem> historyItems;
|
private List<HistoryItem> historyItems;
|
||||||
|
|
||||||
@@ -23,6 +29,16 @@ public class History extends ElevenModel {
|
|||||||
public History() {
|
public History() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
public HistoryItem getHistoryItem(String id) {
|
||||||
|
for(HistoryItem item : historyItems) {
|
||||||
|
if(item.getHistoryItemId().equals(id)){
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
public List<HistoryItem> getHistoryItems() {
|
public List<HistoryItem> getHistoryItems() {
|
||||||
return historyItems;
|
return historyItems;
|
||||||
|
|||||||
@@ -2,8 +2,10 @@ package net.andrewcpu.elevenlabs.model.history;
|
|||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import net.andrewcpu.elevenlabs.ElevenLabs;
|
||||||
import net.andrewcpu.elevenlabs.model.ElevenModel;
|
import net.andrewcpu.elevenlabs.model.ElevenModel;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class HistoryItem extends ElevenModel {
|
public class HistoryItem extends ElevenModel {
|
||||||
@@ -121,6 +123,14 @@ public class HistoryItem extends ElevenModel {
|
|||||||
return feedback;
|
return feedback;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String delete() {
|
||||||
|
return ElevenLabs.deleteHistoryItem(historyItemId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public File downloadAudio() {
|
||||||
|
return ElevenLabs.getHistoryItemAudio(historyItemId);
|
||||||
|
}
|
||||||
|
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
|
|||||||
@@ -2,9 +2,15 @@ package net.andrewcpu.elevenlabs.model.user;
|
|||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import net.andrewcpu.elevenlabs.ElevenLabs;
|
||||||
import net.andrewcpu.elevenlabs.model.ElevenModel;
|
import net.andrewcpu.elevenlabs.model.ElevenModel;
|
||||||
|
|
||||||
public class Subscription extends ElevenModel {
|
public class Subscription extends ElevenModel {
|
||||||
|
@JsonIgnore
|
||||||
|
public static Subscription get() {
|
||||||
|
return ElevenLabs.getSubscription();
|
||||||
|
}
|
||||||
|
|
||||||
@JsonProperty("tier")
|
@JsonProperty("tier")
|
||||||
private String tier;
|
private String tier;
|
||||||
|
|
||||||
|
|||||||
@@ -2,9 +2,15 @@ package net.andrewcpu.elevenlabs.model.user;
|
|||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import net.andrewcpu.elevenlabs.ElevenLabs;
|
||||||
import net.andrewcpu.elevenlabs.model.ElevenModel;
|
import net.andrewcpu.elevenlabs.model.ElevenModel;
|
||||||
|
|
||||||
public class User extends ElevenModel {
|
public class User extends ElevenModel {
|
||||||
|
|
||||||
|
public static User get() {
|
||||||
|
return ElevenLabs.getUser();
|
||||||
|
}
|
||||||
|
|
||||||
@JsonProperty("subscription")
|
@JsonProperty("subscription")
|
||||||
private Subscription subscription;
|
private Subscription subscription;
|
||||||
|
|
||||||
|
|||||||
@@ -2,8 +2,11 @@ package net.andrewcpu.elevenlabs.model.voice;
|
|||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import net.andrewcpu.elevenlabs.ElevenLabs;
|
||||||
import net.andrewcpu.elevenlabs.model.ElevenModel;
|
import net.andrewcpu.elevenlabs.model.ElevenModel;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
public class Sample extends ElevenModel {
|
public class Sample extends ElevenModel {
|
||||||
@JsonProperty("sample_id")
|
@JsonProperty("sample_id")
|
||||||
private String sampleId;
|
private String sampleId;
|
||||||
@@ -20,6 +23,9 @@ public class Sample extends ElevenModel {
|
|||||||
@JsonProperty("hash")
|
@JsonProperty("hash")
|
||||||
private String hash;
|
private String hash;
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
public Voice voice;
|
||||||
|
|
||||||
public Sample(String sampleId, String fileName, String mimeType, long sizeBytes, String hash) {
|
public Sample(String sampleId, String fileName, String mimeType, long sizeBytes, String hash) {
|
||||||
this.sampleId = sampleId;
|
this.sampleId = sampleId;
|
||||||
this.fileName = fileName;
|
this.fileName = fileName;
|
||||||
@@ -56,6 +62,17 @@ public class Sample extends ElevenModel {
|
|||||||
return hash;
|
return hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public File downloadAudio() {
|
||||||
|
return ElevenLabs.getAudioSample(voice.getVoiceId(), sampleId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Warning! This will delete the sample.
|
||||||
|
*/
|
||||||
|
public String delete() {
|
||||||
|
return ElevenLabs.deleteSample(voice.getVoiceId(), sampleId);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
public String toString() {
|
public String toString() {
|
||||||
|
|||||||
@@ -2,13 +2,27 @@ package net.andrewcpu.elevenlabs.model.voice;
|
|||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import net.andrewcpu.elevenlabs.ElevenLabs;
|
||||||
import net.andrewcpu.elevenlabs.model.ElevenModel;
|
import net.andrewcpu.elevenlabs.model.ElevenModel;
|
||||||
import net.andrewcpu.elevenlabs.model.tuning.FineTuning;
|
import net.andrewcpu.elevenlabs.model.tuning.FineTuning;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class Voice extends ElevenModel {
|
public class Voice extends ElevenModel {
|
||||||
|
public static List<Voice> getVoices() {
|
||||||
|
return ElevenLabs.getVoices();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Voice getVoice(String voiceId) {
|
||||||
|
return ElevenLabs.getVoice(voiceId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Voice getVoice(String voiceId, boolean withSettings) {
|
||||||
|
return ElevenLabs.getVoice(voiceId, withSettings);
|
||||||
|
}
|
||||||
|
|
||||||
@JsonProperty("voice_id")
|
@JsonProperty("voice_id")
|
||||||
private String voiceId;
|
private String voiceId;
|
||||||
|
|
||||||
@@ -54,7 +68,7 @@ public class Voice extends ElevenModel {
|
|||||||
|
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
public List<Sample> getSamples() {
|
public List<Sample> getSamples() {
|
||||||
return samples;
|
return samples.stream().peek(s -> s.voice = this).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
@@ -97,6 +111,39 @@ public class Voice extends ElevenModel {
|
|||||||
return sharing;
|
return sharing;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Warning! This will delete the voice.
|
||||||
|
*/
|
||||||
|
public String delete() {
|
||||||
|
return ElevenLabs.deleteVoice(voiceId);
|
||||||
|
}
|
||||||
|
public VoiceSettings fetchSettings() {
|
||||||
|
this.settings = ElevenLabs.getVoiceSettings(voiceId);
|
||||||
|
return settings;
|
||||||
|
}
|
||||||
|
|
||||||
|
public VoiceSettings updateVoiceSettings(VoiceSettings voiceSettings) {
|
||||||
|
ElevenLabs.editVoiceSettings(voiceId, voiceSettings);
|
||||||
|
this.settings = voiceSettings;
|
||||||
|
return settings;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Voice refresh() {
|
||||||
|
Voice refreshedData = Voice.getVoice(voiceId, true);
|
||||||
|
this.name = refreshedData.name;
|
||||||
|
this.settings = refreshedData.settings;
|
||||||
|
this.voiceId = refreshedData.voiceId;
|
||||||
|
this.labels = refreshedData.labels;
|
||||||
|
this.description = refreshedData.description;
|
||||||
|
this.samples = refreshedData.samples;
|
||||||
|
this.fineTuning = refreshedData.fineTuning;
|
||||||
|
this.availableForTiers = refreshedData.availableForTiers;
|
||||||
|
this.sharing = refreshedData.sharing;
|
||||||
|
this.previewUrl = refreshedData.previewUrl;
|
||||||
|
this.category = refreshedData.category;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
|
|||||||
@@ -0,0 +1,93 @@
|
|||||||
|
package net.andrewcpu.elevenlabs.model.voice;
|
||||||
|
|
||||||
|
import net.andrewcpu.elevenlabs.ElevenLabs;
|
||||||
|
import net.andrewcpu.elevenlabs.model.response.CreateVoiceResponse;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class VoiceBuilder {
|
||||||
|
public static VoiceBuilder fromVoice(Voice voice) {
|
||||||
|
VoiceBuilder voiceBuilder = new VoiceBuilder(voice);
|
||||||
|
return voiceBuilder;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Voice voice;
|
||||||
|
private String name;
|
||||||
|
private String description;
|
||||||
|
private Map<String, String> labels;
|
||||||
|
private List<File> files;
|
||||||
|
|
||||||
|
public VoiceBuilder() {
|
||||||
|
this.labels = new HashMap<>();
|
||||||
|
this.files = new ArrayList<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public VoiceBuilder(Voice voice) {
|
||||||
|
this();
|
||||||
|
this.voice = voice;
|
||||||
|
this.name = voice.getName();
|
||||||
|
this.description = voice.getDescription();
|
||||||
|
this.labels = voice.getLabels();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public VoiceBuilder withName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDescription() {
|
||||||
|
return description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public VoiceBuilder withDescription(String description) {
|
||||||
|
this.description = description;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<String, String> getLabels() {
|
||||||
|
return labels;
|
||||||
|
}
|
||||||
|
|
||||||
|
public VoiceBuilder withLabels(Map<String, String> labels) {
|
||||||
|
this.labels = labels;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public VoiceBuilder withLabel(String key, String value) {
|
||||||
|
this.labels.put(key, value);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<File> getFiles() {
|
||||||
|
return files;
|
||||||
|
}
|
||||||
|
|
||||||
|
public VoiceBuilder withFile(File file) {
|
||||||
|
this.files.add(file);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public VoiceBuilder withFiles(List<File> files) {
|
||||||
|
this.files = files;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Voice create() {
|
||||||
|
CreateVoiceResponse createVoiceResponse = ElevenLabs.createVoice(name, files.toArray(File[]::new), description, labels);
|
||||||
|
return Voice.getVoice(createVoiceResponse.getVoiceId(), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Voice edit() {
|
||||||
|
ElevenLabs.editVoice(voice.getVoiceId(), name, files.toArray(File[]::new), description, labels);
|
||||||
|
voice = voice.refresh();
|
||||||
|
return voice;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,9 +2,13 @@ package net.andrewcpu.elevenlabs.model.voice;
|
|||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import net.andrewcpu.elevenlabs.ElevenLabs;
|
||||||
import net.andrewcpu.elevenlabs.model.ElevenModel;
|
import net.andrewcpu.elevenlabs.model.ElevenModel;
|
||||||
|
|
||||||
public class VoiceSettings extends ElevenModel {
|
public class VoiceSettings extends ElevenModel {
|
||||||
|
public static VoiceSettings getDefaultVoiceSettings() {
|
||||||
|
return ElevenLabs.getDefaultVoiceSettings();
|
||||||
|
}
|
||||||
@JsonProperty("stability")
|
@JsonProperty("stability")
|
||||||
private double stability;
|
private double stability;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user