mirror of
https://github.com/Andrewcpu/elevenlabs-api.git
synced 2026-05-06 03:00:23 -04:00
Compare commits
14 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
81cdf05152 | ||
|
|
6e5ae633a6 | ||
|
|
a6163fd67f | ||
|
|
26a4ab1fa4 | ||
|
|
72f35c14b7 | ||
|
|
90a092aa81 | ||
|
|
02d7ec0685 | ||
|
|
75f1c40f59 | ||
|
|
3ac42a330b | ||
|
|
f4fe38166b | ||
|
|
3e2458b482 | ||
|
|
334a903c83 | ||
|
|
d7a710e197 | ||
|
|
15db53e81e |
252
README.md
252
README.md
@@ -16,7 +16,7 @@ To add `elevenlabs-api` to your Maven project, use:
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>net.andrewcpu</groupId>
|
<groupId>net.andrewcpu</groupId>
|
||||||
<artifactId>elevenlabs-api</artifactId>
|
<artifactId>elevenlabs-api</artifactId>
|
||||||
<version>2.1</version>
|
<version>2.7.2</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
```
|
```
|
||||||
The most up-to date package information can be found on the [Packages tab](https://github.com/AndrewCPU/elevenlabs-api/packages/)
|
The most up-to date package information can be found on the [Packages tab](https://github.com/AndrewCPU/elevenlabs-api/packages/)
|
||||||
@@ -32,50 +32,13 @@ To access your ElevenLabs API key, head to the [official website](https://eleven
|
|||||||
To set up your ElevenLabs API key, you must register it with the ElevenLabsAPI Java API like below:
|
To set up your ElevenLabs API key, you must register it with the ElevenLabsAPI Java API like below:
|
||||||
```java
|
```java
|
||||||
ElevenLabs.setApiKey("YOUR_API_KEY_HERE");
|
ElevenLabs.setApiKey("YOUR_API_KEY_HERE");
|
||||||
|
|
||||||
|
|
||||||
|
ElevenLabs.setDefaultModel("eleven_monolingual_v1"); // Optional, defaults to: "eleven_monolingual_v1"
|
||||||
```
|
```
|
||||||
*For any public repository security, you should store your API key in an environment variable, or external from your source code.*
|
*For any public repository security, you should store your API key in an environment variable, or external from your source code.*
|
||||||
|
|
||||||
- - -
|
- - -
|
||||||
|
|
||||||
<!-- TOC -->
|
|
||||||
### Table of Contents
|
|
||||||
* [Getting Started](#getting-started)
|
|
||||||
* [Installation](#installation)
|
|
||||||
* [Setting up your API Key](#setting-up-your-api-key)
|
|
||||||
* [Voices](#voices)
|
|
||||||
* [Accessing your List of Available Voices](#accessing-your-list-of-available-voices)
|
|
||||||
* [Accessing the Default Voice Settings](#accessing-the-default-voice-settings)
|
|
||||||
* [Getting a Voice by ID](#getting-a-voice-by-id)
|
|
||||||
* [Deleting a voice](#deleting-a-voice)
|
|
||||||
* [Retrieving an Updated VoiceSettings for a Voice](#retrieving-an-updated-voicesettings-for-a-voice)
|
|
||||||
* [Updating the VoiceSettings for a Voice](#updating-the-voicesettings-for-a-voice)
|
|
||||||
* [Editing a Voice](#editing-a-voice)
|
|
||||||
* [Creating a Voice](#creating-a-voice)
|
|
||||||
* [Generating Audio](#generating-audio)
|
|
||||||
* [Samples](#samples)
|
|
||||||
* [Accessing Voice Samples](#accessing-voice-samples)
|
|
||||||
* [Downloading a Sample](#downloading-a-sample)
|
|
||||||
* [Deleting a Sample](#deleting-a-sample)
|
|
||||||
* [History](#history)
|
|
||||||
* [Getting Generation History](#getting-generation-history)
|
|
||||||
* [Getting a History Item](#getting-a-history-item)
|
|
||||||
* [Downloading History](#downloading-history)
|
|
||||||
* [Deleting a HistoryItem](#deleting-a-historyitem)
|
|
||||||
* [Requesting the Voice for a HistoryItem](#requesting-the-voice-for-a-historyitem)
|
|
||||||
* [Downloading a HistoryItem Audio](#downloading-a-historyitem-audio)
|
|
||||||
* [User Management](#user-management)
|
|
||||||
* [Getting your Subscription](#getting-your-subscription)
|
|
||||||
* [Getting your User](#getting-your-user)
|
|
||||||
* [Exceptions](#exceptions)
|
|
||||||
* [*ElevenLabsAPINotInitiatedException*](#elevenlabsapinotinitiatedexception)
|
|
||||||
* [*ElevenLabsValidationException*](#elevenlabsvalidationexception)
|
|
||||||
* [Misc](#misc)
|
|
||||||
|
|
||||||
* [Links to ElevenLabs](#links-to-elevenlabs)
|
|
||||||
* [**ElevenLabs Website**: https://elevenlabs.io](#elevenlabs-website--httpselevenlabsio)
|
|
||||||
* [**ElevenLabs API Documentation**: https://api.elevenlabs.io/docs](#elevenlabs-api-documentation--httpsapielevenlabsiodocs)
|
|
||||||
<!-- TOC -->
|
|
||||||
|
|
||||||
## Links to ElevenLabs
|
## Links to ElevenLabs
|
||||||
### **ElevenLabs Website**: https://elevenlabs.io
|
### **ElevenLabs Website**: https://elevenlabs.io
|
||||||
### **ElevenLabs API Documentation**: https://api.elevenlabs.io/docs
|
### **ElevenLabs API Documentation**: https://api.elevenlabs.io/docs
|
||||||
@@ -163,23 +126,201 @@ builder.withLabel("accent", "American");
|
|||||||
voice = builder.create();
|
voice = builder.create();
|
||||||
```
|
```
|
||||||
|
|
||||||
### Generating Audio
|
### Generating Audio (TTS + STS)
|
||||||
To generate an audio file with a given `Voice`, you can utilize the `Voice#generate(...)` functions.
|
To generate an audio file with a given `Voice`, you can utilize the `Voice#generate(...)` functions.
|
||||||
Depending on how you access your `Voice`, (with or without settings), will decide whether you can use the implicit `voiceSettings` or if you have to specify the `VoiceSettings` object to use. Unless explicitly requesting the `Voice` without settings, every `Voice` object SHOULD contain its default `VoiceSettings`.
|
Depending on how you access your `Voice`, (with or without settings), will decide whether you can use the implicit `voiceSettings` or if you have to specify the `VoiceSettings` object to use. Unless explicitly requesting the `Voice` without settings, every `Voice` object SHOULD contain its default `VoiceSettings`.
|
||||||
```java
|
```java
|
||||||
Voice voice;
|
|
||||||
File file = voice.generate(String text);
|
|
||||||
File file = voice.generate(String text, VoiceSettings settings);
|
|
||||||
File file = voice.generate(String text, String model, VoiceSettings settings);
|
|
||||||
File file = voice.generate(String text, String model);
|
|
||||||
|
|
||||||
InputStream inputStream = voice.generateStream(String text);
|
Voice voice;
|
||||||
InputStream inputStream = voice.generateStream(String text, VoiceSettings settings);
|
|
||||||
InputStream inputStream = voice.generateStream(String text, String model, VoiceSettings settings);
|
File file = voice.generate("Hello world!", "my_favorite_model");
|
||||||
InputStream inputStream = voice.generateStream(String text, String model);
|
...
|
||||||
|
//Available Functions:
|
||||||
|
public File generate(String text, String model);
|
||||||
|
|
||||||
|
public File generate(String text, String model, VoiceSettings settings);
|
||||||
|
|
||||||
|
public File generate(String text, String model, VoiceSettings settings, GeneratedAudioOutputFormat outputFormat, StreamLatencyOptimization streamLatencyOptimization);
|
||||||
|
|
||||||
|
public File generate(String text, String model, VoiceSettings settings, GeneratedAudioOutputFormat outputFormat);
|
||||||
|
|
||||||
|
public File generate(String text, VoiceSettings settings, GeneratedAudioOutputFormat outputFormat);
|
||||||
|
|
||||||
|
public File generate(String text, VoiceSettings settings, StreamLatencyOptimization streamLatencyOptimization);
|
||||||
|
|
||||||
|
public File generate(String text, VoiceSettings settings, GeneratedAudioOutputFormat outputFormat, StreamLatencyOptimization streamLatencyOptimization);
|
||||||
|
|
||||||
|
public File generate(String text, GeneratedAudioOutputFormat outputFormat, StreamLatencyOptimization streamLatencyOptimization);
|
||||||
|
|
||||||
|
public File generate(String text, StreamLatencyOptimization streamLatencyOptimization);
|
||||||
|
|
||||||
|
public File generate(String text, VoiceSettings settings);
|
||||||
|
|
||||||
|
public File generate(String text);
|
||||||
|
|
||||||
|
public InputStream generateStream(String text, String model);
|
||||||
|
|
||||||
|
public InputStream generateStream(String text, String model, VoiceSettings settings);
|
||||||
|
|
||||||
|
public InputStream generateStream(String text, VoiceSettings settings);
|
||||||
|
|
||||||
|
public InputStream generateStream(String text);
|
||||||
|
|
||||||
|
public InputStream generateStream(String text, String model, GeneratedAudioOutputFormat generatedAudioOutputFormat, StreamLatencyOptimization streamLatencyOptimization);
|
||||||
|
|
||||||
|
public InputStream generateStream(String text, String model, GeneratedAudioOutputFormat generatedAudioOutputFormat, StreamLatencyOptimization streamLatencyOptimization, VoiceSettings settings);
|
||||||
|
|
||||||
|
public InputStream generateStream(String text, VoiceSettings settings, GeneratedAudioOutputFormat generatedAudioOutputFormat, StreamLatencyOptimization streamLatencyOptimization);
|
||||||
|
|
||||||
|
public InputStream generateStream(String text, GeneratedAudioOutputFormat generatedAudioOutputFormat, StreamLatencyOptimization streamLatencyOptimization);
|
||||||
|
|
||||||
|
public InputStream generateStream(String text, String model, StreamLatencyOptimization streamLatencyOptimization);
|
||||||
|
|
||||||
|
public InputStream generateStream(String text, String model, StreamLatencyOptimization streamLatencyOptimization, VoiceSettings settings);
|
||||||
|
|
||||||
|
public InputStream generateStream(String text, VoiceSettings settings, StreamLatencyOptimization streamLatencyOptimization);
|
||||||
|
|
||||||
|
public InputStream generateStream(String text, StreamLatencyOptimization streamLatencyOptimization);
|
||||||
|
|
||||||
|
public File speechToSpeech(File audioFile, StreamLatencyOptimization latencyOptimization, String modelId, VoiceSettings voiceSettings);
|
||||||
|
|
||||||
|
public File speechToSpeech(File audioFile, StreamLatencyOptimization latencyOptimization, String modelId);
|
||||||
|
|
||||||
|
public File speechToSpeech(File audioFile, String modelId);
|
||||||
|
|
||||||
|
public InputStream speechToSpeechStream(File audioFile, StreamLatencyOptimization latencyOptimization, String modelId, VoiceSettings voiceSettings);
|
||||||
|
|
||||||
|
public InputStream speechToSpeechStream(File audioFile, StreamLatencyOptimization latencyOptimization, String modelId);
|
||||||
|
|
||||||
|
public InputStream speechToSpeechStream(File audioFile, String modelId);
|
||||||
|
|
||||||
```
|
```
|
||||||
- - -
|
- - -
|
||||||
|
## Audio Native Projects
|
||||||
|
### Creating an Audio Native Project
|
||||||
|
You can create audio native projects using the AudioNative API.
|
||||||
|
```java
|
||||||
|
CreateAudioEnabledProjectRequest request = new CreateAudioEnabledProjectRequest()
|
||||||
|
.setName("Project name")
|
||||||
|
.setImage("https://...com/img.png")
|
||||||
|
.setAuthor("Andrew")
|
||||||
|
.setSmall(true)
|
||||||
|
.setTextColor("red")
|
||||||
|
.setBackgroundColor("black")
|
||||||
|
.setSessionization(3)
|
||||||
|
.setVoiceId("aso23809")
|
||||||
|
.setModelId("my_favorite_model")
|
||||||
|
.setFile(new File("input.dat"))
|
||||||
|
.setAutoConvert(true);
|
||||||
|
|
||||||
|
CreateAudioEnabledProjectModelResponse response = ElevenLabs.getAudioNativeAPI()
|
||||||
|
.createAudioEnabledProject(request);
|
||||||
|
```
|
||||||
|
|
||||||
|
- - -
|
||||||
|
## Projects
|
||||||
|
## Create a project
|
||||||
|
You can create a new project using the AddProjectRequest builder.
|
||||||
|
```java
|
||||||
|
AddProjectRequest request = new AddProjectRequest()
|
||||||
|
.setName("name")
|
||||||
|
.setFromUrl("...")
|
||||||
|
.setFromDocument(new File("file.dat"))
|
||||||
|
.setDefaultTitleVoiceId("voiceA")
|
||||||
|
.setDefaultParagraphVoiceId("voiceB")
|
||||||
|
.setDefaultModelId("the_default_model_of_your_dreams")
|
||||||
|
.setProjectOutputQuality(ProjectOutputQuality.STANDARD)
|
||||||
|
.setTitle("Big Title")
|
||||||
|
.setAuthor("Best Author")
|
||||||
|
.setIsbnNumber("THE. ISBN.")
|
||||||
|
.setAcxVolumeNormalization(true);
|
||||||
|
|
||||||
|
Project project = Project.addProject(request);
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
## Get a Project
|
||||||
|
Get a project by it's specific project ID.
|
||||||
|
```java
|
||||||
|
Project project = Project.getProjectById(projectId);
|
||||||
|
```
|
||||||
|
|
||||||
|
## Get all Projects
|
||||||
|
Get all of the projects associated with your account.
|
||||||
|
```java
|
||||||
|
List<Project> projects = Project.getProjects();
|
||||||
|
```
|
||||||
|
|
||||||
|
## Interacting with Projects
|
||||||
|
```java
|
||||||
|
Project project;
|
||||||
|
// Delete a project
|
||||||
|
String deleteResult = project.delete();
|
||||||
|
|
||||||
|
// Convert a project
|
||||||
|
String conversionResult = project.convertProject();
|
||||||
|
|
||||||
|
//Get the project's snapshots.
|
||||||
|
List<ProjectSnapshot> snapshots = project.getSnapshots();
|
||||||
|
|
||||||
|
// Access your chapters from memory
|
||||||
|
List<Chapter> chapters = project.getChapters();
|
||||||
|
|
||||||
|
// Refresh your local Project's chapters from the API
|
||||||
|
chapters = project.fetchUpdatedChapters(); // This will update the existing project object and return the list of new chapters
|
||||||
|
|
||||||
|
// Get a chapter by ID
|
||||||
|
Chapter chapter = project.getChapterById(chapterId);
|
||||||
|
|
||||||
|
// Delete a chapter
|
||||||
|
String result = project.deleteChapter(chapter);
|
||||||
|
|
||||||
|
// Convert a chapter
|
||||||
|
String result = project.convertChapter(chapter);
|
||||||
|
|
||||||
|
// Get chapter snapshots
|
||||||
|
List<ChapterSnapshot> snapshots = project.getChapterSnapshots(chapter);
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
## Interacting with Chapters
|
||||||
|
```java
|
||||||
|
Project project;
|
||||||
|
Chapter chapter = project.getChapterById("chapter_id");
|
||||||
|
|
||||||
|
// Delete a chapter
|
||||||
|
chapter.deleteChapter(project.getProjectId());
|
||||||
|
|
||||||
|
// Convert a chapter
|
||||||
|
chapter.convertChapter(project.getProjectId());
|
||||||
|
|
||||||
|
// Get a chapter's snapshots
|
||||||
|
List<ChapterSnapshot> snapshots = chapter.getChapterSnapshots(project.getProjectId());
|
||||||
|
|
||||||
|
//
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
## Accessing Snapshot Audio
|
||||||
|
Accessing a ProjectSnapshot audio stream:
|
||||||
|
```java
|
||||||
|
Project project;
|
||||||
|
List<ProjectSnapshot> projectSnapshots = project.getSnapshots();
|
||||||
|
ProjectSnapshot first = projectSnapshots.get(0);
|
||||||
|
InputStream audio = first.getAudioStream();
|
||||||
|
```
|
||||||
|
|
||||||
|
Accessing a ChapterSnapshot audio stream:
|
||||||
|
```java
|
||||||
|
Project project;
|
||||||
|
Chapter chapter;
|
||||||
|
List<ChapterSnapshot> chapterSnapshots = project.getChapterSnapshots(chapter);
|
||||||
|
ChapterSnapshot first = chapterSnapshots.get(0);
|
||||||
|
InputStream audio = first.getAudioStream();
|
||||||
|
```
|
||||||
|
|
||||||
|
Both ProjectSnapshot and ChapterSnapshot are of type Snapshot.
|
||||||
|
- - -
|
||||||
## Samples
|
## Samples
|
||||||
A `Sample` is used as the training data for a given `Voice` model.
|
A `Sample` is used as the training data for a given `Voice` model.
|
||||||
### Accessing Voice Samples
|
### Accessing Voice Samples
|
||||||
@@ -248,6 +389,10 @@ A `HistoryItem` is a previous TTS generation. You can download the generation as
|
|||||||
HistoryItem item;
|
HistoryItem item;
|
||||||
File file = item.downloadAudio();
|
File file = item.downloadAudio();
|
||||||
```
|
```
|
||||||
|
- - -
|
||||||
|
### Projects
|
||||||
|
The `Projects`
|
||||||
|
|
||||||
- - -
|
- - -
|
||||||
|
|
||||||
## User Management
|
## User Management
|
||||||
@@ -278,6 +423,11 @@ If you like what you see, give it a star! :)
|
|||||||
|
|
||||||
- - -
|
- - -
|
||||||
|
|
||||||
|
## Todo
|
||||||
|
I will probably rework the 2 new builders I added when I added projects support. Their usage should be more clear, though the documentation covers their use cases I believe.
|
||||||
|
|
||||||
|
- - -
|
||||||
|
|
||||||
#### Unit Testing
|
#### Unit Testing
|
||||||
Unit tests have been created, these endpoints are destructive and not included in the testing:
|
Unit tests have been created, these endpoints are destructive and not included in the testing:
|
||||||
* deleteHistoryItem - WONT TEST
|
* deleteHistoryItem - WONT TEST
|
||||||
|
|||||||
9
pom.xml
9
pom.xml
@@ -60,7 +60,7 @@
|
|||||||
|
|
||||||
<groupId>net.andrewcpu</groupId>
|
<groupId>net.andrewcpu</groupId>
|
||||||
<artifactId>elevenlabs-api</artifactId>
|
<artifactId>elevenlabs-api</artifactId>
|
||||||
<version>2.4</version>
|
<version>2.7.3-SNAPSHOT</version>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<maven.compiler.source>11</maven.compiler.source>
|
<maven.compiler.source>11</maven.compiler.source>
|
||||||
@@ -80,17 +80,17 @@
|
|||||||
<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.15.3</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<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.15.3</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.fasterxml.jackson.core</groupId>
|
<groupId>com.fasterxml.jackson.core</groupId>
|
||||||
<artifactId>jackson-core</artifactId>
|
<artifactId>jackson-core</artifactId>
|
||||||
<version>2.13.4</version>
|
<version>2.15.3</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.slf4j</groupId>
|
<groupId>org.slf4j</groupId>
|
||||||
@@ -194,7 +194,6 @@
|
|||||||
</execution>
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
</project>
|
</project>
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package net.andrewcpu.elevenlabs;
|
package net.andrewcpu.elevenlabs;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
import net.andrewcpu.elevenlabs.api.impl.*;
|
import net.andrewcpu.elevenlabs.api.impl.*;
|
||||||
|
|
||||||
public class ElevenLabs {
|
public class ElevenLabs {
|
||||||
@@ -17,6 +18,15 @@ public class ElevenLabs {
|
|||||||
public static String getApiKey() {
|
public static String getApiKey() {
|
||||||
return API_KEY;
|
return API_KEY;
|
||||||
}
|
}
|
||||||
|
private static String defaultModel = "eleven_monolingual_v1";
|
||||||
|
|
||||||
|
public static String getDefaultModel() {
|
||||||
|
return defaultModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setDefaultModel(String defaultModel) {
|
||||||
|
ElevenLabs.defaultModel = defaultModel;
|
||||||
|
}
|
||||||
|
|
||||||
public static void setApiKey(String apiKey) {
|
public static void setApiKey(String apiKey) {
|
||||||
API_KEY = apiKey;
|
API_KEY = apiKey;
|
||||||
|
|||||||
@@ -1,9 +1,27 @@
|
|||||||
package net.andrewcpu.elevenlabs.model.projects;
|
package net.andrewcpu.elevenlabs.model.projects;
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
public class Chapter extends ElevenModel {
|
public class Chapter extends ElevenModel {
|
||||||
|
|
||||||
|
public String deleteChapter(String projectId) {
|
||||||
|
return ElevenLabs.getProjectsAPI().deleteChapter(projectId, chapterId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String convertChapter(String projectId) {
|
||||||
|
return ElevenLabs.getProjectsAPI().convertChapter(projectId, chapterId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ChapterSnapshot> getChapterSnapshots(String projectId) {
|
||||||
|
return ElevenLabs.getProjectsAPI().getChapterSnapshots(projectId, chapterId);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@JsonProperty("chapter_id")
|
@JsonProperty("chapter_id")
|
||||||
private String chapterId;
|
private String chapterId;
|
||||||
|
|
||||||
@@ -24,4 +42,66 @@ public class Chapter extends ElevenModel {
|
|||||||
|
|
||||||
@JsonProperty("statistics")
|
@JsonProperty("statistics")
|
||||||
private Statistics statistics;
|
private Statistics statistics;
|
||||||
|
|
||||||
|
public Chapter() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public Chapter(String chapterId, String name, long lastConversionDateUnix, double conversionProgress, boolean canBeDownloaded, String state, Statistics statistics) {
|
||||||
|
this.chapterId = chapterId;
|
||||||
|
this.name = name;
|
||||||
|
this.lastConversionDateUnix = lastConversionDateUnix;
|
||||||
|
this.conversionProgress = conversionProgress;
|
||||||
|
this.canBeDownloaded = canBeDownloaded;
|
||||||
|
this.state = state;
|
||||||
|
this.statistics = statistics;
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
public String getChapterId() {
|
||||||
|
return chapterId;
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
public long getLastConversionDateUnix() {
|
||||||
|
return lastConversionDateUnix;
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
public double getConversionProgress() {
|
||||||
|
return conversionProgress;
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
public boolean isCanBeDownloaded() {
|
||||||
|
return canBeDownloaded;
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
public String getState() {
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
public Statistics getStatistics() {
|
||||||
|
return statistics;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@JsonIgnore
|
||||||
|
public String toString() {
|
||||||
|
return "Chapter{" +
|
||||||
|
"chapterId='" + chapterId + '\'' +
|
||||||
|
", name='" + name + '\'' +
|
||||||
|
", lastConversionDateUnix=" + lastConversionDateUnix +
|
||||||
|
", conversionProgress=" + conversionProgress +
|
||||||
|
", canBeDownloaded=" + canBeDownloaded +
|
||||||
|
", state='" + state + '\'' +
|
||||||
|
", statistics=" + statistics +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,34 +2,34 @@ package net.andrewcpu.elevenlabs.model.projects;
|
|||||||
|
|
||||||
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 ChapterSnapshot extends ElevenModel {
|
import java.io.InputStream;
|
||||||
|
|
||||||
|
public class ChapterSnapshot extends Snapshot {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public InputStream getAudioStream() {
|
||||||
|
return ElevenLabs.getProjectsAPI().getChapterSnapshotAudioStream(projectId, chapterId, chapterSnapshotId);
|
||||||
|
}
|
||||||
|
|
||||||
public ChapterSnapshot() {
|
public ChapterSnapshot() {
|
||||||
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ChapterSnapshot(String chapterSnapshotId, String projectId, String chapterId, long createdAtUnix, String name) {
|
public ChapterSnapshot(String chapterSnapshotId, String projectId, String chapterId, long createdAtUnix, String name) {
|
||||||
|
super(projectId, createdAtUnix, name);
|
||||||
this.chapterSnapshotId = chapterSnapshotId;
|
this.chapterSnapshotId = chapterSnapshotId;
|
||||||
this.projectId = projectId;
|
|
||||||
this.chapterId = chapterId;
|
this.chapterId = chapterId;
|
||||||
this.createdAtUnix = createdAtUnix;
|
|
||||||
this.name = name;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@JsonProperty("chapter_snapshot_id")
|
@JsonProperty("chapter_snapshot_id")
|
||||||
private String chapterSnapshotId;
|
private String chapterSnapshotId;
|
||||||
|
|
||||||
@JsonProperty("project_id")
|
|
||||||
private String projectId;
|
|
||||||
|
|
||||||
@JsonProperty("chapter_id")
|
@JsonProperty("chapter_id")
|
||||||
private String chapterId;
|
private String chapterId;
|
||||||
|
|
||||||
@JsonProperty("created_at_unix")
|
|
||||||
private long createdAtUnix;
|
|
||||||
|
|
||||||
@JsonProperty("name")
|
|
||||||
private String name;
|
|
||||||
|
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
public String getChapterSnapshotId() {
|
public String getChapterSnapshotId() {
|
||||||
@@ -40,20 +40,6 @@ public class ChapterSnapshot extends ElevenModel {
|
|||||||
return chapterId;
|
return chapterId;
|
||||||
}
|
}
|
||||||
|
|
||||||
@JsonIgnore
|
|
||||||
public String getProjectId() {
|
|
||||||
return projectId;
|
|
||||||
}
|
|
||||||
|
|
||||||
@JsonIgnore
|
|
||||||
public long getCreatedAtUnix() {
|
|
||||||
return createdAtUnix;
|
|
||||||
}
|
|
||||||
|
|
||||||
@JsonIgnore
|
|
||||||
public String getName() {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ 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.ElevenLabs;
|
||||||
import net.andrewcpu.elevenlabs.model.ElevenModel;
|
import net.andrewcpu.elevenlabs.model.ElevenModel;
|
||||||
|
import net.andrewcpu.elevenlabs.model.request.AddProjectRequest;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -13,6 +14,63 @@ public class Project extends ElevenModel {
|
|||||||
return ElevenLabs.getProjectsAPI().getProjects();
|
return ElevenLabs.getProjectsAPI().getProjects();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Project addProject(AddProjectRequest builder) {
|
||||||
|
return ElevenLabs.getProjectsAPI().addProject(builder);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Project getProjectById(String projectId) {
|
||||||
|
return ElevenLabs.getProjectsAPI().getProject(projectId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Chapter> fetchUpdatedChapters() {
|
||||||
|
this.chapters = ElevenLabs.getProjectsAPI().getChapters(projectId);
|
||||||
|
return this.chapters;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String deleteChapter(Chapter chapter) {
|
||||||
|
return chapter.deleteChapter(projectId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String convertChapter(Chapter chapter) {
|
||||||
|
return chapter.convertChapter(projectId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ChapterSnapshot> getChapterSnapshots(Chapter chapter) {
|
||||||
|
return chapter.getChapterSnapshots(projectId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String deleteProject() {
|
||||||
|
return ElevenLabs.getProjectsAPI().deleteProject(projectId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String convertProject() {
|
||||||
|
return ElevenLabs.getProjectsAPI().convertProject(projectId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ProjectSnapshot> getSnapshots() {
|
||||||
|
return ElevenLabs.getProjectsAPI().getProjectSnapshots(projectId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Chapter getChapterById(String chapterId) {
|
||||||
|
return ElevenLabs.getProjectsAPI().getChapterById(projectId, chapterId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Project(String projectId, String name, long unixCreateDate, String defaultTitleVoiceId, String defaultParagraphVoiceId, String defaultModelId, long lastConversionDateUnix, boolean canBeDownloaded, String state, List<Chapter> chapters) {
|
||||||
|
this.projectId = projectId;
|
||||||
|
this.name = name;
|
||||||
|
this.unixCreateDate = unixCreateDate;
|
||||||
|
this.defaultTitleVoiceId = defaultTitleVoiceId;
|
||||||
|
this.defaultParagraphVoiceId = defaultParagraphVoiceId;
|
||||||
|
this.defaultModelId = defaultModelId;
|
||||||
|
this.lastConversionDateUnix = lastConversionDateUnix;
|
||||||
|
this.canBeDownloaded = canBeDownloaded;
|
||||||
|
this.state = state;
|
||||||
|
this.chapters = chapters;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Project() {
|
||||||
|
}
|
||||||
|
|
||||||
@JsonProperty("project_id")
|
@JsonProperty("project_id")
|
||||||
private String projectId;
|
private String projectId;
|
||||||
|
|
||||||
|
|||||||
@@ -2,55 +2,40 @@ package net.andrewcpu.elevenlabs.model.projects;
|
|||||||
|
|
||||||
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 ProjectSnapshot extends ElevenModel {
|
import java.io.InputStream;
|
||||||
|
|
||||||
|
public class ProjectSnapshot extends Snapshot {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public InputStream getAudioStream() {
|
||||||
|
return ElevenLabs.getProjectsAPI().getProjectSnapshotAudioStream(projectId, projectSnapshotId);
|
||||||
|
}
|
||||||
|
|
||||||
public ProjectSnapshot() {
|
public ProjectSnapshot() {
|
||||||
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ProjectSnapshot(String projectSnapshotId, String projectId, long createdAtUnix, String name) {
|
public ProjectSnapshot(String projectSnapshotId, String projectId, long createdAtUnix, String name) {
|
||||||
|
super(projectId, createdAtUnix, name);
|
||||||
this.projectSnapshotId = projectSnapshotId;
|
this.projectSnapshotId = projectSnapshotId;
|
||||||
this.projectId = projectId;
|
|
||||||
this.createdAtUnix = createdAtUnix;
|
|
||||||
this.name = name;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@JsonProperty("project_snapshot_id")
|
@JsonProperty("project_snapshot_id")
|
||||||
private String projectSnapshotId;
|
private String projectSnapshotId;
|
||||||
|
|
||||||
@JsonProperty("project_id")
|
|
||||||
private String projectId;
|
|
||||||
|
|
||||||
@JsonProperty("created_at_unix")
|
|
||||||
private long createdAtUnix;
|
|
||||||
|
|
||||||
@JsonProperty("name")
|
|
||||||
private String name;
|
|
||||||
|
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
public String getProjectSnapshotId() {
|
public String getProjectSnapshotId() {
|
||||||
return projectSnapshotId;
|
return projectSnapshotId;
|
||||||
}
|
}
|
||||||
|
|
||||||
@JsonIgnore
|
|
||||||
public String getProjectId() {
|
|
||||||
return projectId;
|
|
||||||
}
|
|
||||||
|
|
||||||
@JsonIgnore
|
|
||||||
public long getCreatedAtUnix() {
|
|
||||||
return createdAtUnix;
|
|
||||||
}
|
|
||||||
|
|
||||||
@JsonIgnore
|
|
||||||
public String getName() {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@JsonIgnore
|
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "Snapshot{" +
|
return "ProjectSnapshot{" +
|
||||||
"projectSnapshotId='" + projectSnapshotId + '\'' +
|
"projectSnapshotId='" + projectSnapshotId + '\'' +
|
||||||
", projectId='" + projectId + '\'' +
|
", projectId='" + projectId + '\'' +
|
||||||
", createdAtUnix=" + createdAtUnix +
|
", createdAtUnix=" + createdAtUnix +
|
||||||
|
|||||||
@@ -0,0 +1,54 @@
|
|||||||
|
package net.andrewcpu.elevenlabs.model.projects;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import net.andrewcpu.elevenlabs.model.ElevenModel;
|
||||||
|
|
||||||
|
import java.io.InputStream;
|
||||||
|
|
||||||
|
public abstract class Snapshot extends ElevenModel {
|
||||||
|
@JsonProperty("project_id")
|
||||||
|
protected String projectId;
|
||||||
|
|
||||||
|
@JsonProperty("created_at_unix")
|
||||||
|
protected long createdAtUnix;
|
||||||
|
|
||||||
|
@JsonProperty("name")
|
||||||
|
protected String name;
|
||||||
|
|
||||||
|
public Snapshot(String projectId, long createdAtUnix, String name) {
|
||||||
|
this.projectId = projectId;
|
||||||
|
this.createdAtUnix = createdAtUnix;
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Snapshot() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract InputStream getAudioStream();
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
public String getProjectId() {
|
||||||
|
return projectId;
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
public long getCreatedAtUnix() {
|
||||||
|
return createdAtUnix;
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@JsonIgnore
|
||||||
|
public String toString() {
|
||||||
|
return "Snapshot{" +
|
||||||
|
"projectId='" + projectId + '\'' +
|
||||||
|
", createdAtUnix=" + createdAtUnix +
|
||||||
|
", name='" + name + '\'' +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -167,28 +167,28 @@ public class Voice extends ElevenModel {
|
|||||||
return ElevenLabs.getTextToSpeechAPI().generateTextToSpeech(voiceId,text, model, outputFormat,StreamLatencyOptimization.getDefault(), settings);
|
return ElevenLabs.getTextToSpeechAPI().generateTextToSpeech(voiceId,text, model, outputFormat,StreamLatencyOptimization.getDefault(), settings);
|
||||||
}
|
}
|
||||||
public File generate(String text, VoiceSettings settings, GeneratedAudioOutputFormat outputFormat) {
|
public File generate(String text, VoiceSettings settings, GeneratedAudioOutputFormat outputFormat) {
|
||||||
return ElevenLabs.getTextToSpeechAPI().generateTextToSpeech(voiceId, text, "eleven_monolingual_v1", outputFormat,StreamLatencyOptimization.getDefault(), settings);
|
return ElevenLabs.getTextToSpeechAPI().generateTextToSpeech(voiceId, text, ElevenLabs.getDefaultModel(), outputFormat,StreamLatencyOptimization.getDefault(), settings);
|
||||||
}
|
}
|
||||||
public File generate(String text, VoiceSettings settings, StreamLatencyOptimization streamLatencyOptimization) {
|
public File generate(String text, VoiceSettings settings, StreamLatencyOptimization streamLatencyOptimization) {
|
||||||
return ElevenLabs.getTextToSpeechAPI().generateTextToSpeech(voiceId, text, "eleven_monolingual_v1", GeneratedAudioOutputFormat.getDefault(),streamLatencyOptimization, settings);
|
return ElevenLabs.getTextToSpeechAPI().generateTextToSpeech(voiceId, text, ElevenLabs.getDefaultModel(), GeneratedAudioOutputFormat.getDefault(),streamLatencyOptimization, settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
public File generate(String text, VoiceSettings settings, GeneratedAudioOutputFormat outputFormat, StreamLatencyOptimization streamLatencyOptimization) {
|
public File generate(String text, VoiceSettings settings, GeneratedAudioOutputFormat outputFormat, StreamLatencyOptimization streamLatencyOptimization) {
|
||||||
return ElevenLabs.getTextToSpeechAPI().generateTextToSpeech(voiceId, text, "eleven_monolingual_v1", outputFormat,streamLatencyOptimization, settings);
|
return ElevenLabs.getTextToSpeechAPI().generateTextToSpeech(voiceId, text, ElevenLabs.getDefaultModel(), outputFormat,streamLatencyOptimization, settings);
|
||||||
}
|
}
|
||||||
public File generate(String text, GeneratedAudioOutputFormat outputFormat, StreamLatencyOptimization streamLatencyOptimization) {
|
public File generate(String text, GeneratedAudioOutputFormat outputFormat, StreamLatencyOptimization streamLatencyOptimization) {
|
||||||
return ElevenLabs.getTextToSpeechAPI().generateTextToSpeech(voiceId, text, "eleven_monolingual_v1", outputFormat,streamLatencyOptimization, settings);
|
return ElevenLabs.getTextToSpeechAPI().generateTextToSpeech(voiceId, text, ElevenLabs.getDefaultModel(), outputFormat,streamLatencyOptimization, settings);
|
||||||
}
|
}
|
||||||
public File generate(String text, StreamLatencyOptimization streamLatencyOptimization) {
|
public File generate(String text, StreamLatencyOptimization streamLatencyOptimization) {
|
||||||
return ElevenLabs.getTextToSpeechAPI().generateTextToSpeech(voiceId, text, "eleven_monolingual_v1", GeneratedAudioOutputFormat.getDefault(), streamLatencyOptimization, settings);
|
return ElevenLabs.getTextToSpeechAPI().generateTextToSpeech(voiceId, text, ElevenLabs.getDefaultModel(), GeneratedAudioOutputFormat.getDefault(), streamLatencyOptimization, settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
public File generate(String text, VoiceSettings settings) {
|
public File generate(String text, VoiceSettings settings) {
|
||||||
return ElevenLabs.getTextToSpeechAPI().generateTextToSpeech(voiceId, text, "eleven_monolingual_v1", settings);
|
return ElevenLabs.getTextToSpeechAPI().generateTextToSpeech(voiceId, text, ElevenLabs.getDefaultModel(), settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
public File generate(String text) {
|
public File generate(String text) {
|
||||||
return ElevenLabs.getTextToSpeechAPI().generateTextToSpeech(voiceId, text, "eleven_monolingual_v1", settings);
|
return ElevenLabs.getTextToSpeechAPI().generateTextToSpeech(voiceId, text, ElevenLabs.getDefaultModel(), settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -202,11 +202,11 @@ public class Voice extends ElevenModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public InputStream generateStream(String text, VoiceSettings settings) {
|
public InputStream generateStream(String text, VoiceSettings settings) {
|
||||||
return ElevenLabs.getTextToSpeechAPI().generateTextToSpeechStreamed(voiceId, text, "eleven_monolingual_v1", settings);
|
return ElevenLabs.getTextToSpeechAPI().generateTextToSpeechStreamed(voiceId, text, ElevenLabs.getDefaultModel(), settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
public InputStream generateStream(String text) {
|
public InputStream generateStream(String text) {
|
||||||
return ElevenLabs.getTextToSpeechAPI().generateTextToSpeechStreamed(voiceId, text, "eleven_monolingual_v1", settings);
|
return ElevenLabs.getTextToSpeechAPI().generateTextToSpeechStreamed(voiceId, text, ElevenLabs.getDefaultModel(), settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
public InputStream generateStream(String text, String model, GeneratedAudioOutputFormat generatedAudioOutputFormat, StreamLatencyOptimization streamLatencyOptimization) {
|
public InputStream generateStream(String text, String model, GeneratedAudioOutputFormat generatedAudioOutputFormat, StreamLatencyOptimization streamLatencyOptimization) {
|
||||||
@@ -218,11 +218,11 @@ public class Voice extends ElevenModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public InputStream generateStream(String text, VoiceSettings settings, GeneratedAudioOutputFormat generatedAudioOutputFormat, StreamLatencyOptimization streamLatencyOptimization) {
|
public InputStream generateStream(String text, VoiceSettings settings, GeneratedAudioOutputFormat generatedAudioOutputFormat, StreamLatencyOptimization streamLatencyOptimization) {
|
||||||
return ElevenLabs.getTextToSpeechAPI().generateTextToSpeechStreamed(voiceId, text, "eleven_monolingual_v1", generatedAudioOutputFormat, streamLatencyOptimization, settings);
|
return ElevenLabs.getTextToSpeechAPI().generateTextToSpeechStreamed(voiceId, text, ElevenLabs.getDefaultModel(), generatedAudioOutputFormat, streamLatencyOptimization, settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
public InputStream generateStream(String text, GeneratedAudioOutputFormat generatedAudioOutputFormat, StreamLatencyOptimization streamLatencyOptimization) {
|
public InputStream generateStream(String text, GeneratedAudioOutputFormat generatedAudioOutputFormat, StreamLatencyOptimization streamLatencyOptimization) {
|
||||||
return ElevenLabs.getTextToSpeechAPI().generateTextToSpeechStreamed(voiceId, text, "eleven_monolingual_v1", generatedAudioOutputFormat, streamLatencyOptimization, settings);
|
return ElevenLabs.getTextToSpeechAPI().generateTextToSpeechStreamed(voiceId, text, ElevenLabs.getDefaultModel(), generatedAudioOutputFormat, streamLatencyOptimization, settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
public InputStream generateStream(String text, String model, StreamLatencyOptimization streamLatencyOptimization) {
|
public InputStream generateStream(String text, String model, StreamLatencyOptimization streamLatencyOptimization) {
|
||||||
@@ -234,11 +234,11 @@ public class Voice extends ElevenModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public InputStream generateStream(String text, VoiceSettings settings, StreamLatencyOptimization streamLatencyOptimization) {
|
public InputStream generateStream(String text, VoiceSettings settings, StreamLatencyOptimization streamLatencyOptimization) {
|
||||||
return ElevenLabs.getTextToSpeechAPI().generateTextToSpeechStreamed(voiceId, text, "eleven_monolingual_v1", GeneratedAudioOutputFormat.getDefault(), streamLatencyOptimization, settings);
|
return ElevenLabs.getTextToSpeechAPI().generateTextToSpeechStreamed(voiceId, text, ElevenLabs.getDefaultModel(), GeneratedAudioOutputFormat.getDefault(), streamLatencyOptimization, settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
public InputStream generateStream(String text, StreamLatencyOptimization streamLatencyOptimization) {
|
public InputStream generateStream(String text, StreamLatencyOptimization streamLatencyOptimization) {
|
||||||
return ElevenLabs.getTextToSpeechAPI().generateTextToSpeechStreamed(voiceId, text, "eleven_monolingual_v1", GeneratedAudioOutputFormat.getDefault(), streamLatencyOptimization, settings);
|
return ElevenLabs.getTextToSpeechAPI().generateTextToSpeechStreamed(voiceId, text, ElevenLabs.getDefaultModel(), GeneratedAudioOutputFormat.getDefault(), streamLatencyOptimization, settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
public File speechToSpeech(File audioFile, StreamLatencyOptimization latencyOptimization, String modelId, VoiceSettings voiceSettings) {
|
public File speechToSpeech(File audioFile, StreamLatencyOptimization latencyOptimization, String modelId, VoiceSettings voiceSettings) {
|
||||||
|
|||||||
@@ -6,4 +6,9 @@ public abstract class DeleteRequest<T> extends ElevenLabsRequest<T> {
|
|||||||
public DeleteRequest(String endpoint, Class<T> clazz) {
|
public DeleteRequest(String endpoint, Class<T> clazz) {
|
||||||
super(HttpRequestType.DELETE, endpoint, clazz);
|
super(HttpRequestType.DELETE, endpoint, clazz);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object getPayload() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,6 +23,8 @@ public abstract class ElevenLabsRequest<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String getEndpoint() {
|
public String getEndpoint() {
|
||||||
|
Map<String, String> params = getQueryParameters();
|
||||||
|
if(params.isEmpty()) return endpoint;
|
||||||
return endpoint + "?" + buildQueryParameters(getQueryParameters());
|
return endpoint + "?" + buildQueryParameters(getQueryParameters());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,4 +6,9 @@ public abstract class GetRequest<T> extends ElevenLabsRequest<T> {
|
|||||||
public GetRequest(String endpoint, Class<T> clazz) {
|
public GetRequest(String endpoint, Class<T> clazz) {
|
||||||
super(HttpRequestType.GET, endpoint, clazz);
|
super(HttpRequestType.GET, endpoint, clazz);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object getPayload() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,9 +6,4 @@ public class DeleteHistoryItemRequest extends DeleteRequest<String> {
|
|||||||
public DeleteHistoryItemRequest(String historyItemId) {
|
public DeleteHistoryItemRequest(String historyItemId) {
|
||||||
super("v1/history/" + historyItemId, String.class);
|
super("v1/history/" + historyItemId, String.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getPayload() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,9 +8,4 @@ public class GetHistoryItemAudioRequest extends GetRequest<File> {
|
|||||||
public GetHistoryItemAudioRequest(String historyItemId) {
|
public GetHistoryItemAudioRequest(String historyItemId) {
|
||||||
super("v1/history/" + historyItemId + "/audio", File.class);
|
super("v1/history/" + historyItemId + "/audio", File.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getPayload() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,9 +7,4 @@ public class GetHistoryItemByIdRequest extends GetRequest<HistoryItem> {
|
|||||||
public GetHistoryItemByIdRequest(String historyId) {
|
public GetHistoryItemByIdRequest(String historyId) {
|
||||||
super("v1/history/" + historyId, HistoryItem.class);
|
super("v1/history/" + historyId, HistoryItem.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getPayload() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,9 +7,4 @@ public class GetHistoryRequest extends GetRequest<History> {
|
|||||||
public GetHistoryRequest() {
|
public GetHistoryRequest() {
|
||||||
super("v1/history", History.class);
|
super("v1/history", History.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getPayload() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,9 +7,4 @@ public class GetModelsRequest extends GetRequest<GenerationTypeModel[]> {
|
|||||||
public GetModelsRequest() {
|
public GetModelsRequest() {
|
||||||
super("v1/models", GenerationTypeModel[].class);
|
super("v1/models", GenerationTypeModel[].class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getPayload() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,9 +7,4 @@ public class DeleteChapterByIdRequest extends DeleteRequest<String> {
|
|||||||
public DeleteChapterByIdRequest(String projectId, String chapterId) {
|
public DeleteChapterByIdRequest(String projectId, String chapterId) {
|
||||||
super("v1/projects/" + projectId + "/chapters/" + chapterId, String.class);
|
super("v1/projects/" + projectId + "/chapters/" + chapterId, String.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getPayload() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,9 +6,4 @@ public class DeleteProjectByIdRequest extends DeleteRequest<String> {
|
|||||||
public DeleteProjectByIdRequest(String projectId) {
|
public DeleteProjectByIdRequest(String projectId) {
|
||||||
super("v1/projects/" + projectId, String.class);
|
super("v1/projects/" + projectId, String.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getPayload() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,9 +7,4 @@ public class GetChapterByIdRequest extends GetRequest<Chapter> {
|
|||||||
public GetChapterByIdRequest(String projectId, String chapterId) {
|
public GetChapterByIdRequest(String projectId, String chapterId) {
|
||||||
super("v1/projects/" + projectId + "/chapters/" + chapterId, Chapter.class);
|
super("v1/projects/" + projectId + "/chapters/" + chapterId, Chapter.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getPayload() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,8 +8,4 @@ public class GetChapterSnapshotsRequest extends GetRequest<ChapterSnapshotsModel
|
|||||||
super("v1/projects/" + projectId + "/chapters/" + chapterId + "/snapshots", ChapterSnapshotsModelResponse.class);
|
super("v1/projects/" + projectId + "/chapters/" + chapterId + "/snapshots", ChapterSnapshotsModelResponse.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getPayload() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,9 +7,4 @@ public class GetProjectByIdRequest extends GetRequest<Project> {
|
|||||||
public GetProjectByIdRequest(String projectId) {
|
public GetProjectByIdRequest(String projectId) {
|
||||||
super("v1/projects/" + projectId, Project.class);
|
super("v1/projects/" + projectId, Project.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getPayload() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,9 +7,4 @@ public class GetProjectChaptersRequest extends GetRequest<ChaptersModelResponse>
|
|||||||
public GetProjectChaptersRequest(String projectId) {
|
public GetProjectChaptersRequest(String projectId) {
|
||||||
super("v1/projects/" + projectId + "/chapters", ChaptersModelResponse.class);
|
super("v1/projects/" + projectId + "/chapters", ChaptersModelResponse.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getPayload() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,9 +7,4 @@ public class GetProjectSnapshotsRequest extends GetRequest<ProjectSnapshotsModel
|
|||||||
public GetProjectSnapshotsRequest(String projectId) {
|
public GetProjectSnapshotsRequest(String projectId) {
|
||||||
super("v1/projects/" + projectId + "/snapshots", ProjectSnapshotsModelResponse.class);
|
super("v1/projects/" + projectId + "/snapshots", ProjectSnapshotsModelResponse.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getPayload() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,9 +7,4 @@ public class GetProjectsRequest extends GetRequest<ProjectsModelResponse> {
|
|||||||
public GetProjectsRequest() {
|
public GetProjectsRequest() {
|
||||||
super("v1/projects", ProjectsModelResponse.class);
|
super("v1/projects", ProjectsModelResponse.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getPayload() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,9 +6,4 @@ public class DeleteSampleRequest extends DeleteRequest<String> {
|
|||||||
public DeleteSampleRequest(String voiceId, String sampleId) {
|
public DeleteSampleRequest(String voiceId, String sampleId) {
|
||||||
super("v1/voices/" + voiceId + "/samples/" + sampleId, String.class);
|
super("v1/voices/" + voiceId + "/samples/" + sampleId, String.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getPayload() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,9 +8,4 @@ public class GetSampleRequest extends GetRequest<File> {
|
|||||||
public GetSampleRequest(String voiceId, String sampleId) {
|
public GetSampleRequest(String voiceId, String sampleId) {
|
||||||
super("v1/voices/" + voiceId + "/samples/" + sampleId + "/audio", File.class);
|
super("v1/voices/" + voiceId + "/samples/" + sampleId + "/audio", File.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getPayload() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ public class PostTextToSpeechRequest extends PostRequest<File> {
|
|||||||
public Map<String, String> getQueryParameters() {
|
public Map<String, String> getQueryParameters() {
|
||||||
Map<String, String> map = new HashMap<>();
|
Map<String, String> map = new HashMap<>();
|
||||||
map.put("optimize_streaming_latency", String.valueOf(streamLatencyOptimization.getValue()));
|
map.put("optimize_streaming_latency", String.valueOf(streamLatencyOptimization.getValue()));
|
||||||
map.put("output_format", outputFormat.name());
|
map.put("output_format", outputFormat.name().toLowerCase());
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ public class PostTextToSpeechStreamedRequest extends PostRequest<InputStream> {
|
|||||||
public Map<String, String> getQueryParameters() {
|
public Map<String, String> getQueryParameters() {
|
||||||
Map<String, String> map = new HashMap<>();
|
Map<String, String> map = new HashMap<>();
|
||||||
map.put("optimize_streaming_latency", String.valueOf(streamLatencyOptimization.getValue()));
|
map.put("optimize_streaming_latency", String.valueOf(streamLatencyOptimization.getValue()));
|
||||||
map.put("output_format", outputFormat.name());
|
map.put("output_format", outputFormat.name().toLowerCase());
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,9 +8,4 @@ public class GetSubscriptionRequest extends GetRequest<Subscription> {
|
|||||||
public GetSubscriptionRequest() {
|
public GetSubscriptionRequest() {
|
||||||
super("v1/user/subscription", Subscription.class);
|
super("v1/user/subscription", Subscription.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getPayload() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,9 +7,4 @@ public class GetUserRequest extends GetRequest<User> {
|
|||||||
public GetUserRequest() {
|
public GetUserRequest() {
|
||||||
super("v1/user", User.class);
|
super("v1/user", User.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getPayload() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,9 +6,4 @@ public class DeleteVoiceRequest extends DeleteRequest<String> {
|
|||||||
public DeleteVoiceRequest(String voiceId) {
|
public DeleteVoiceRequest(String voiceId) {
|
||||||
super("v1/voices/" + voiceId, String.class);
|
super("v1/voices/" + voiceId, String.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getPayload() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,9 +7,4 @@ public class GetDefaultVoiceSettingsRequest extends GetRequest<VoiceSettings> {
|
|||||||
public GetDefaultVoiceSettingsRequest() {
|
public GetDefaultVoiceSettingsRequest() {
|
||||||
super("v1/voices/settings/default", VoiceSettings.class);
|
super("v1/voices/settings/default", VoiceSettings.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getPayload() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,15 +12,18 @@ public class GetVoiceRequest extends GetRequest<Voice> {
|
|||||||
this(voiceId, true);
|
this(voiceId, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public GetVoiceRequest(String voiceId, boolean withSettings) {
|
public GetVoiceRequest(String voiceId, boolean withSettings) {
|
||||||
super( "v1/voices/" + voiceId, Voice.class);
|
super( "v1/voices/" + voiceId, Voice.class);
|
||||||
this.withSettings = withSettings;
|
this.withSettings = withSettings;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getPayload() {
|
public Map<String, String> getQueryParameters() {
|
||||||
Map<String, Object> payload = new HashMap<>();
|
Map<String, String> payload = new HashMap<>();
|
||||||
payload.put("with_settings", withSettings);
|
payload.put("with_settings", String.valueOf(withSettings));
|
||||||
return payload;
|
return payload;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,9 +7,4 @@ public class GetVoiceSettingsRequest extends GetRequest<VoiceSettings> {
|
|||||||
public GetVoiceSettingsRequest(String voiceId) {
|
public GetVoiceSettingsRequest(String voiceId) {
|
||||||
super("v1/voices/" + voiceId + "/settings", VoiceSettings.class);
|
super("v1/voices/" + voiceId + "/settings", VoiceSettings.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getPayload() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,9 +7,4 @@ public class GetVoicesRequest extends GetRequest<VoiceModelResponse> {
|
|||||||
public GetVoicesRequest() {
|
public GetVoicesRequest() {
|
||||||
super("v1/voices", VoiceModelResponse.class);
|
super("v1/voices", VoiceModelResponse.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getPayload() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -66,22 +66,10 @@ public class ElevenNetworkUtil {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static List<NameValuePair> getParameters(Object payload) {
|
private static HttpUriRequestBase handleNonBodyRequest(HttpRequestType requestType, String path) {
|
||||||
List<NameValuePair> parameters = new ArrayList<>();
|
|
||||||
if (payload instanceof Map<?, ?>) {
|
|
||||||
Map<?, ?> payloadMap = (Map<?, ?>) payload;
|
|
||||||
for (Map.Entry<?, ?> entry : payloadMap.entrySet()) {
|
|
||||||
parameters.add(new BasicNameValuePair(String.valueOf(entry.getKey()), String.valueOf(entry.getValue())));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return parameters;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static HttpUriRequestBase handleNonBodyRequest(HttpRequestType requestType, Object payload, String path) {
|
|
||||||
List<NameValuePair> parameters = getParameters(payload);
|
|
||||||
HttpUriRequestBase request = getRequest(requestType, path);
|
HttpUriRequestBase request = getRequest(requestType, path);
|
||||||
try {
|
try {
|
||||||
request.setUri(new URIBuilder(path).addParameters(parameters).build());
|
request.setUri(new URIBuilder(path).build());
|
||||||
} catch (URISyntaxException e) {
|
} catch (URISyntaxException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
@@ -141,7 +129,7 @@ public class ElevenNetworkUtil {
|
|||||||
public static HttpUriRequestBase getRequest(HttpRequestType method, String path, Object payload) throws JsonProcessingException {
|
public static HttpUriRequestBase getRequest(HttpRequestType method, String path, Object payload) throws JsonProcessingException {
|
||||||
HttpUriRequestBase request;
|
HttpUriRequestBase request;
|
||||||
if (method == HttpRequestType.GET || method == HttpRequestType.DELETE) {
|
if (method == HttpRequestType.GET || method == HttpRequestType.DELETE) {
|
||||||
request = handleNonBodyRequest(method, payload, path);
|
request = handleNonBodyRequest(method, path);
|
||||||
} else {
|
} else {
|
||||||
request = handleBodyRequest(method, payload, path);
|
request = handleBodyRequest(method, payload, path);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user