6 Commits
v36 ... v40

Author SHA1 Message Date
Andrew Stein
6968219c55 Updated action 2023-06-11 18:28:05 -04:00
Andrew Stein
e6279b689f Updated action 2023-06-11 18:26:50 -04:00
Andrew Stein
3462385f3d Updated models to include static retrieval & action functions. 2023-06-11 18:19:25 -04:00
Andrew Stein
0bca63fd50 Updated POM. 2023-06-11 18:00:51 -04:00
Andrew Stein
f7998ee0f9 Merge branch 'main' of https://github.com/AndrewCPU/elevenlabs-api 2023-06-11 18:00:18 -04:00
Andrew Stein
22cdc7146c Updated POM version. 2023-06-11 17:59:56 -04:00
10 changed files with 205 additions and 8 deletions

View File

@@ -23,6 +23,9 @@ jobs:
- name: Build with Maven
run: mvn clean package -Dmaven.test.skip
- name: Deploy with Maven
run: mvn deploy -Dmaven.test.skip=true
- name: Read version from POM file
id: version
run: echo ::set-output name=version::$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)

View File

@@ -34,7 +34,7 @@
<groupId>net.andrewcpu</groupId>
<artifactId>elevenlabs-api</artifactId>
<version>1.1-SNAPSHOT</version>
<version>2.0-SNAPSHOT</version>
<properties>
<maven.compiler.source>11</maven.compiler.source>
@@ -51,21 +51,16 @@
</licenses>
<dependencies>
<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.13.4.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-annotations -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>2.13.4</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-core -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
@@ -91,7 +86,7 @@
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<version>4.13.1</version>
<scope>test</scope>
</dependency>
</dependencies>

View File

@@ -2,11 +2,17 @@ package net.andrewcpu.elevenlabs.model.history;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import net.andrewcpu.elevenlabs.ElevenLabs;
import net.andrewcpu.elevenlabs.model.ElevenModel;
import java.util.List;
public class History extends ElevenModel {
public static History get() {
return ElevenLabs.getHistory();
}
@JsonProperty("history")
private List<HistoryItem> historyItems;
@@ -23,6 +29,16 @@ public class History extends ElevenModel {
public History() {
}
@JsonIgnore
public HistoryItem getHistoryItem(String id) {
for(HistoryItem item : historyItems) {
if(item.getHistoryItemId().equals(id)){
return item;
}
}
return null;
}
@JsonIgnore
public List<HistoryItem> getHistoryItems() {
return historyItems;

View File

@@ -2,8 +2,10 @@ package net.andrewcpu.elevenlabs.model.history;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import net.andrewcpu.elevenlabs.ElevenLabs;
import net.andrewcpu.elevenlabs.model.ElevenModel;
import java.io.File;
import java.util.Map;
public class HistoryItem extends ElevenModel {
@@ -121,6 +123,14 @@ public class HistoryItem extends ElevenModel {
return feedback;
}
public String delete() {
return ElevenLabs.deleteHistoryItem(historyItemId);
}
public File downloadAudio() {
return ElevenLabs.getHistoryItemAudio(historyItemId);
}
@JsonIgnore
@Override
public String toString() {

View File

@@ -2,9 +2,15 @@ package net.andrewcpu.elevenlabs.model.user;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import net.andrewcpu.elevenlabs.ElevenLabs;
import net.andrewcpu.elevenlabs.model.ElevenModel;
public class Subscription extends ElevenModel {
@JsonIgnore
public static Subscription get() {
return ElevenLabs.getSubscription();
}
@JsonProperty("tier")
private String tier;

View File

@@ -2,9 +2,15 @@ package net.andrewcpu.elevenlabs.model.user;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import net.andrewcpu.elevenlabs.ElevenLabs;
import net.andrewcpu.elevenlabs.model.ElevenModel;
public class User extends ElevenModel {
public static User get() {
return ElevenLabs.getUser();
}
@JsonProperty("subscription")
private Subscription subscription;

View File

@@ -2,8 +2,11 @@ package net.andrewcpu.elevenlabs.model.voice;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import net.andrewcpu.elevenlabs.ElevenLabs;
import net.andrewcpu.elevenlabs.model.ElevenModel;
import java.io.File;
public class Sample extends ElevenModel {
@JsonProperty("sample_id")
private String sampleId;
@@ -20,6 +23,9 @@ public class Sample extends ElevenModel {
@JsonProperty("hash")
private String hash;
@JsonIgnore
public Voice voice;
public Sample(String sampleId, String fileName, String mimeType, long sizeBytes, String hash) {
this.sampleId = sampleId;
this.fileName = fileName;
@@ -56,6 +62,17 @@ public class Sample extends ElevenModel {
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
@JsonIgnore
public String toString() {

View File

@@ -2,13 +2,27 @@ package net.andrewcpu.elevenlabs.model.voice;
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.model.tuning.FineTuning;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
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")
private String voiceId;
@@ -54,7 +68,7 @@ public class Voice extends ElevenModel {
@JsonIgnore
public List<Sample> getSamples() {
return samples;
return samples.stream().peek(s -> s.voice = this).collect(Collectors.toList());
}
@JsonIgnore
@@ -97,6 +111,39 @@ public class Voice extends ElevenModel {
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
@Override
public String toString() {

View File

@@ -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;
}
}

View File

@@ -2,9 +2,13 @@ package net.andrewcpu.elevenlabs.model.voice;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import net.andrewcpu.elevenlabs.ElevenLabs;
import net.andrewcpu.elevenlabs.model.ElevenModel;
public class VoiceSettings extends ElevenModel {
public static VoiceSettings getDefaultVoiceSettings() {
return ElevenLabs.getDefaultVoiceSettings();
}
@JsonProperty("stability")
private double stability;