mirror of
https://github.com/Andrewcpu/elevenlabs-api.git
synced 2026-05-06 03:00:23 -04:00
Compare commits
43 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
81cdf05152 | ||
|
|
6e5ae633a6 | ||
|
|
a6163fd67f | ||
|
|
26a4ab1fa4 | ||
|
|
72f35c14b7 | ||
|
|
90a092aa81 | ||
|
|
02d7ec0685 | ||
|
|
75f1c40f59 | ||
|
|
3ac42a330b | ||
|
|
f4fe38166b | ||
|
|
3e2458b482 | ||
|
|
334a903c83 | ||
|
|
d7a710e197 | ||
|
|
15db53e81e | ||
|
|
bc6ee1306f | ||
|
|
8199e766ef | ||
|
|
688b469f6b | ||
|
|
388d059af7 | ||
|
|
1f9c48eac6 | ||
|
|
b3ea0e2a09 | ||
|
|
75eb64a077 | ||
|
|
c5706317aa | ||
|
|
0a2f6d1869 | ||
|
|
b753769a53 | ||
|
|
8162cada71 | ||
|
|
fdcc12ee41 | ||
|
|
8c526a1539 | ||
|
|
95cf38c620 | ||
|
|
6968219c55 | ||
|
|
e6279b689f | ||
|
|
3462385f3d | ||
|
|
0bca63fd50 | ||
|
|
f7998ee0f9 | ||
|
|
22cdc7146c | ||
|
|
e746eeaea9 | ||
|
|
36eac79a9c | ||
|
|
810c264ac6 | ||
|
|
6a2256d4ca | ||
|
|
a8e43af913 | ||
|
|
b8d3ae7c90 | ||
|
|
4b740d8997 | ||
|
|
78dba6753d | ||
|
|
49e2e716eb |
6
.github/workflows/build.yml
vendored
6
.github/workflows/build.yml
vendored
@@ -1,4 +1,4 @@
|
|||||||
name: Dev Build
|
name: Build
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
@@ -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
|
||||||
|
|||||||
365
README.md
365
README.md
@@ -1,86 +1,44 @@
|
|||||||
# elevenlabs-api 
|
# 🗣️🔊 elevenlabs-api 
|
||||||
### An unofficial ElevenLabs AI Voice Generation Java API
|
### An unofficial ElevenLabs AI Voice Generation Java API
|
||||||
|
|
||||||
## Getting Started
|
## Getting Started
|
||||||
So you wanna make custom voices, huh? Well you've come to the right place.
|
So you wanna make custom voices, huh? Well you've come to the right place.
|
||||||
|
|
||||||
|
### Note: This repo is undergoing an upgrade to v2.0
|
||||||
|
If any of the documentation is out of place or issues occur, please submit a PR or create an issue.
|
||||||
|
I downgraded the repo from JDK 17 to JDK 11 as well.
|
||||||
|
|
||||||
### Installation
|
### Installation
|
||||||
**Maven**
|
**Maven**
|
||||||
|
|
||||||
To add `elevenlabs-api` to your Maven project, use:
|
To add `elevenlabs-api` to your Maven project, use:
|
||||||
```xml
|
```xml
|
||||||
<dependencies>
|
<dependency>
|
||||||
...
|
<groupId>net.andrewcpu</groupId>
|
||||||
<dependency>
|
<artifactId>elevenlabs-api</artifactId>
|
||||||
<groupId>net.andrewcpu.elevenlabs</groupId>
|
<version>2.7.2</version>
|
||||||
<artifactId>elevenlabs-api</artifactId>
|
</dependency>
|
||||||
<version>CURRENT_VERSION</version>
|
|
||||||
</dependency>
|
|
||||||
...
|
|
||||||
</dependencies>
|
|
||||||
```
|
```
|
||||||
|
The most up-to date package information can be found on the [Packages tab](https://github.com/AndrewCPU/elevenlabs-api/packages/)
|
||||||
|
|
||||||
|
|
||||||
**JAR**
|
**JAR**
|
||||||
|
|
||||||
Compiled JARs are available via the [Releases tab](https://github.com/AndrewCPU/elevenlabs-api/releases)
|
Compiled JARs are available via the [Releases tab](https://github.com/AndrewCPU/elevenlabs-api/releases)
|
||||||
|
|
||||||
**Gradle**
|
|
||||||
|
|
||||||
*Todo*
|
|
||||||
|
|
||||||
### Setting up your API Key
|
### Setting up your API Key
|
||||||
To access your ElevenLabs API key, head to the [official website](https://elevenlabs.io/), you can view your `xi-api-key` using the 'Profile' tab on the website.
|
To access your ElevenLabs API key, head to the [official website](https://elevenlabs.io/), you can view your `xi-api-key` using the 'Profile' tab on the website.
|
||||||
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
|
||||||
ElevenLabsAPI.getInstance().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.*
|
||||||
|
|
||||||
Once you've injected your API Key, you can safely assume that you will not receive a `ElevenLabsAPINotInitiatedException`.
|
|
||||||
- - -
|
- - -
|
||||||
|
|
||||||
<!-- 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)
|
|
||||||
* [Built in Types](#built-in-types)
|
|
||||||
* [`Voice` Related Types](#voice-related-types)
|
|
||||||
* [`User` Related Types](#user-related-types)
|
|
||||||
* [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
|
||||||
@@ -168,16 +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;
|
Voice voice;
|
||||||
File outputFile = voice.generate(String text, VoiceSettings voiceSettings, File output);
|
|
||||||
File outputFile = voice.generate(String text, File output); // Uses default voice settings
|
File file = voice.generate("Hello world!", "my_favorite_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
|
||||||
@@ -191,7 +334,7 @@ You can download a `Sample` via the `Sample#downloadAudio(File outputFile)` func
|
|||||||
The `File` parameter of `downloadAudio()` is the location of where you want to locally download the sample.
|
The `File` parameter of `downloadAudio()` is the location of where you want to locally download the sample.
|
||||||
```java
|
```java
|
||||||
Voice voice;
|
Voice voice;
|
||||||
File file = voice.getSamples().get(0).downloadAudio(File outputFile);
|
File file = voice.getSamples().get(0).downloadAudio();
|
||||||
```
|
```
|
||||||
|
|
||||||
### Deleting a Sample
|
### Deleting a Sample
|
||||||
@@ -219,11 +362,11 @@ HistoryItem item = history.getHistoryItem("itemId");
|
|||||||
|
|
||||||
### Downloading History
|
### Downloading History
|
||||||
The official API of ElevenLabs provides an endpoint for downloading multiple `HistoryItem`'s as a ZIP file. To download such items, you can pass a `String[]` containing the `HistoryItem` IDs, OR you can provide a `List<HistoryItem>` parameter.
|
The official API of ElevenLabs provides an endpoint for downloading multiple `HistoryItem`'s as a ZIP file. To download such items, you can pass a `String[]` containing the `HistoryItem` IDs, OR you can provide a `List<HistoryItem>` parameter.
|
||||||
The second parameter is the path in which you would like to save the ZIP file.
|
|
||||||
```java
|
```java
|
||||||
History history;
|
History history;
|
||||||
File download = history.downloadHistory(new String[]{"item-id1", "item-id2"}, new File("outputFile.zip"));
|
File download = history.downloadHistory(new String[]{"item-id1", "item-id2"});
|
||||||
File download = history.downloadHistory(List<HistoryItem> historyItems, File outputFile);
|
File download = history.downloadHistory(List<HistoryItem> historyItems);
|
||||||
```
|
```
|
||||||
|
|
||||||
### Deleting a HistoryItem
|
### Deleting a HistoryItem
|
||||||
@@ -241,11 +384,15 @@ Voice voice = item.getVoice();
|
|||||||
```
|
```
|
||||||
|
|
||||||
### Downloading a HistoryItem Audio
|
### Downloading a HistoryItem Audio
|
||||||
A `HistoryItem` is a previous TTS generation. You can download the generation as an MP3 file by providing the `downloadAudio(File file)` function with the target location for the downloaded file. The return value is the same `File` provided as a parameter.
|
A `HistoryItem` is a previous TTS generation. You can download the generation as an MP3 file by executing the `downloadAudio()` function. The return value is the tmp `File` location of your download.
|
||||||
```java
|
```java
|
||||||
HistoryItem item;
|
HistoryItem item;
|
||||||
File file = item.downloadAudio(File outputFile);
|
File file = item.downloadAudio();
|
||||||
```
|
```
|
||||||
|
- - -
|
||||||
|
### Projects
|
||||||
|
The `Projects`
|
||||||
|
|
||||||
- - -
|
- - -
|
||||||
|
|
||||||
## User Management
|
## User Management
|
||||||
@@ -264,77 +411,8 @@ User user = User.get();
|
|||||||
|
|
||||||
- - -
|
- - -
|
||||||
## Exceptions
|
## Exceptions
|
||||||
You'll find most actions that make network requests also will throw `IOException`, `ElevenLabsAPINotInitiatedException`, and `ElevenLabsValidationException`.
|
|
||||||
|
|
||||||
*The only function that will make a network request **without throwing an exception is*** `HistoryItem#getVoice()`.
|
|
||||||
### *ElevenLabsAPINotInitiatedException*
|
|
||||||
This exception will be thrown if you attempt to use the library without setting an API key.
|
|
||||||
### *ElevenLabsValidationException*
|
### *ElevenLabsValidationException*
|
||||||
This error indicates a malformed request to the ElevenLabs API. The exception should provide the location of any syntactically incorrect parameters within the request.
|
This error indicates a malformed request to the ElevenLabs API. The exception should provide the location of any syntactically incorrect parameters within the request.
|
||||||
- - -
|
|
||||||
# Built in Types
|
|
||||||
|
|
||||||
There are a few objects and enums defined for this API.
|
|
||||||
## `Voice` Related Types
|
|
||||||
```java
|
|
||||||
Voice(String voiceId, String name, List<Sample> samples, String category,
|
|
||||||
Map<String, String> labels, String previewUrl, List<String> availableForTiers,
|
|
||||||
VoiceSettings settings)
|
|
||||||
```
|
|
||||||
```java
|
|
||||||
VoiceSettings(double stability, double similarityBoost)
|
|
||||||
```
|
|
||||||
```java
|
|
||||||
Sample(String sampleId, String fileName, String mimeType, long sizeBytes, String hash)
|
|
||||||
```
|
|
||||||
```java
|
|
||||||
History(List<HistoryItem> history)
|
|
||||||
```
|
|
||||||
```java
|
|
||||||
History.HistoryItem(String historyItemId, String voiceId, String voiceName, String text,
|
|
||||||
long dateUnix, int characterCountChangeFrom, int characterCountChangeTo,
|
|
||||||
String contentType, String state)
|
|
||||||
```
|
|
||||||
|
|
||||||
```java
|
|
||||||
public enum State {
|
|
||||||
CREATED,
|
|
||||||
DELETED,
|
|
||||||
PROCESSING;
|
|
||||||
}
|
|
||||||
```
|
|
||||||
- - -
|
|
||||||
## `User` Related Types
|
|
||||||
```java
|
|
||||||
User(Subscription subscription, boolean isNewUser, String xiApiKey)
|
|
||||||
```
|
|
||||||
```java
|
|
||||||
Subscription(String tier, int characterCount, int characterLimit, boolean canExtendCharacterLimit,
|
|
||||||
boolean allowedToExtendCharacterLimit, long nextCharacterCountResetUnix, int voiceLimit,
|
|
||||||
boolean canExtendVoiceLimit, boolean canUseInstantVoiceCloning, List<AvailableModel> availableModels,
|
|
||||||
String status, NextInvoice nextInvoice)
|
|
||||||
```
|
|
||||||
```java
|
|
||||||
AvailableModel(String modelId, String displayName, List<SupportedLanguage> supportedLanguages)
|
|
||||||
```
|
|
||||||
```java
|
|
||||||
SupportedLanguage(String isoCode, String displayName)
|
|
||||||
```
|
|
||||||
```java
|
|
||||||
NextInvoice(int amountDueCents, long nextPaymentAttemptUnix)
|
|
||||||
```
|
|
||||||
```java
|
|
||||||
public enum Status {
|
|
||||||
TRIALING,
|
|
||||||
ACTIVE,
|
|
||||||
INCOMPLETE,
|
|
||||||
INCOMPLETE_EXPIRED,
|
|
||||||
PAST_DUE,
|
|
||||||
CANCELED,
|
|
||||||
UNPAID,
|
|
||||||
FREE;
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
- - -
|
- - -
|
||||||
|
|
||||||
@@ -345,8 +423,21 @@ 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
|
||||||
*Todo*
|
Unit tests have been created, these endpoints are destructive and not included in the testing:
|
||||||
|
* deleteHistoryItem - WONT TEST
|
||||||
|
* deleteSample - WONT TEST
|
||||||
|
* deleteVoice - WONT TEST
|
||||||
|
* editVoiceSettings - WONT TEST
|
||||||
|
* createVoice - WONT TEST
|
||||||
|
* editVoice - WONT TEST
|
||||||
|
|
||||||
|
To run the unit tests yourself, you have to clone this repo and update the ElevenLabsTest.java file with your API key and your voice to test on.
|
||||||
|
|
||||||
|
|
||||||
Thanks to ElevenLabs for making an awesome tool 🥂
|
Thanks to ElevenLabs for making an awesome tool 🥂
|
||||||
|
|||||||
133
pom.xml
133
pom.xml
@@ -6,6 +6,7 @@
|
|||||||
|
|
||||||
<name>Unofficial Java ElevenLabs Voice API</name>
|
<name>Unofficial Java ElevenLabs Voice API</name>
|
||||||
<description>An API level interaction between Java and the ElevenLabs Voice Generation Web API.</description>
|
<description>An API level interaction between Java and the ElevenLabs Voice Generation Web API.</description>
|
||||||
|
<url>https://github.com/AndrewCPU/elevenlabs-api</url>
|
||||||
<developers>
|
<developers>
|
||||||
<developer>
|
<developer>
|
||||||
<id>Andrewcpu</id>
|
<id>Andrewcpu</id>
|
||||||
@@ -24,13 +25,46 @@
|
|||||||
<tag>HEAD</tag>
|
<tag>HEAD</tag>
|
||||||
</scm>
|
</scm>
|
||||||
|
|
||||||
|
<profiles>
|
||||||
|
<profile>
|
||||||
|
<id>github</id>
|
||||||
|
<activation>
|
||||||
|
<activeByDefault>false</activeByDefault>
|
||||||
|
</activation>
|
||||||
|
<distributionManagement>
|
||||||
|
<repository>
|
||||||
|
<id>github</id>
|
||||||
|
<name>GitHub AndrewCPU Apache Maven Packages</name>
|
||||||
|
<url>https://maven.pkg.github.com/AndrewCPU/elevenlabs-api</url>
|
||||||
|
</repository>
|
||||||
|
</distributionManagement>
|
||||||
|
</profile>
|
||||||
|
<profile>
|
||||||
|
<id>ossrh</id>
|
||||||
|
<activation>
|
||||||
|
<activeByDefault>true</activeByDefault>
|
||||||
|
</activation>
|
||||||
|
<distributionManagement>
|
||||||
|
<repository>
|
||||||
|
<id>ossrh</id>
|
||||||
|
<url>https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/</url>
|
||||||
|
</repository>
|
||||||
|
<snapshotRepository>
|
||||||
|
<id>ossrh</id>
|
||||||
|
<url>https://s01.oss.sonatype.org/content/repositories/projectSnapshots</url>
|
||||||
|
</snapshotRepository>
|
||||||
|
</distributionManagement>
|
||||||
|
</profile>
|
||||||
|
</profiles>
|
||||||
|
|
||||||
|
|
||||||
<groupId>net.andrewcpu</groupId>
|
<groupId>net.andrewcpu</groupId>
|
||||||
<artifactId>elevenlabs-api</artifactId>
|
<artifactId>elevenlabs-api</artifactId>
|
||||||
<version>1.0-SNAPSHOT</version>
|
<version>2.7.3-SNAPSHOT</version>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<maven.compiler.source>17</maven.compiler.source>
|
<maven.compiler.source>11</maven.compiler.source>
|
||||||
<maven.compiler.target>17</maven.compiler.target>
|
<maven.compiler.target>11</maven.compiler.target>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
@@ -44,15 +78,62 @@
|
|||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.googlecode.json-simple</groupId>
|
<groupId>com.fasterxml.jackson.core</groupId>
|
||||||
<artifactId>json-simple</artifactId>
|
<artifactId>jackson-databind</artifactId>
|
||||||
<version>1.1.1</version>
|
<version>2.15.3</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.fasterxml.jackson.core</groupId>
|
||||||
|
<artifactId>jackson-annotations</artifactId>
|
||||||
|
<version>2.15.3</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.fasterxml.jackson.core</groupId>
|
||||||
|
<artifactId>jackson-core</artifactId>
|
||||||
|
<version>2.15.3</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.slf4j</groupId>
|
||||||
|
<artifactId>slf4j-log4j12</artifactId>
|
||||||
|
<version>2.0.7</version>
|
||||||
|
<type>pom</type>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.slf4j</groupId>
|
||||||
|
<artifactId>slf4j-nop</artifactId>
|
||||||
|
<version>2.0.7</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.httpcomponents.client5</groupId>
|
||||||
|
<artifactId>httpclient5</artifactId>
|
||||||
|
<version>5.2.1</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>junit</groupId>
|
||||||
|
<artifactId>junit</artifactId>
|
||||||
|
<version>4.13.1</version>
|
||||||
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
<finalName>elevenlabs-api-${version}</finalName>
|
<finalName>elevenlabs-api-${version}</finalName>
|
||||||
<plugins>
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-gpg-plugin</artifactId>
|
||||||
|
<version>1.6</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>sign-artifacts</id>
|
||||||
|
<phase>verify</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>sign</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<artifactId>maven-assembly-plugin</artifactId>
|
<artifactId>maven-assembly-plugin</artifactId>
|
||||||
<version>3.3.0</version>
|
<version>3.3.0</version>
|
||||||
@@ -73,6 +154,46 @@
|
|||||||
</execution>
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
<!-- Generates JAR's source file -->
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-source-plugin</artifactId>
|
||||||
|
<version>3.2.1</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>attach-sources</id>
|
||||||
|
<goals>
|
||||||
|
<goal>jar-no-fork</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.sonatype.plugins</groupId>
|
||||||
|
<artifactId>nexus-staging-maven-plugin</artifactId>
|
||||||
|
<version>1.6.13</version>
|
||||||
|
<extensions>true</extensions>
|
||||||
|
<configuration>
|
||||||
|
<serverId>ossrh</serverId>
|
||||||
|
<nexusUrl>https://s01.oss.sonatype.org/</nexusUrl>
|
||||||
|
<autoReleaseAfterClose>true</autoReleaseAfterClose>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
|
||||||
|
<!-- Generates Javadoc JAR file -->
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-javadoc-plugin</artifactId>
|
||||||
|
<version>3.3.0</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>attach-javadocs</id>
|
||||||
|
<goals>
|
||||||
|
<goal>jar</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
</project>
|
</project>
|
||||||
|
|||||||
83
src/main/java/net/andrewcpu/elevenlabs/ElevenLabs.java
Normal file
83
src/main/java/net/andrewcpu/elevenlabs/ElevenLabs.java
Normal file
@@ -0,0 +1,83 @@
|
|||||||
|
package net.andrewcpu.elevenlabs;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
|
import net.andrewcpu.elevenlabs.api.impl.*;
|
||||||
|
|
||||||
|
public class ElevenLabs {
|
||||||
|
private static String API_KEY = null;
|
||||||
|
private static HistoryAPI historyAPI;
|
||||||
|
private static ModelsAPI modelsAPI;
|
||||||
|
private static ProjectsAPI projectsAPI;
|
||||||
|
private static SampleAPI sampleAPI;
|
||||||
|
private static SpeechToSpeechAPI speechToSpeechAPI;
|
||||||
|
private static TextToSpeechAPI textToSpeechAPI;
|
||||||
|
private static UserAPI userAPI;
|
||||||
|
private static VoiceAPI voiceAPI;
|
||||||
|
private static AudioNativeAPI audioNativeAPI;
|
||||||
|
|
||||||
|
public static String getApiKey() {
|
||||||
|
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) {
|
||||||
|
API_KEY = apiKey;
|
||||||
|
initializeSubclasses();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void initializeSubclasses() {
|
||||||
|
ElevenLabs.historyAPI = new HistoryAPI();
|
||||||
|
ElevenLabs.modelsAPI = new ModelsAPI();
|
||||||
|
ElevenLabs.projectsAPI = new ProjectsAPI();
|
||||||
|
ElevenLabs.sampleAPI = new SampleAPI();
|
||||||
|
ElevenLabs.speechToSpeechAPI = new SpeechToSpeechAPI();
|
||||||
|
ElevenLabs.textToSpeechAPI = new TextToSpeechAPI();
|
||||||
|
ElevenLabs.userAPI = new UserAPI();
|
||||||
|
ElevenLabs.voiceAPI = new VoiceAPI();
|
||||||
|
ElevenLabs.audioNativeAPI = new AudioNativeAPI();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static AudioNativeAPI getAudioNativeAPI() {
|
||||||
|
return audioNativeAPI;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static HistoryAPI getHistoryAPI() {
|
||||||
|
return historyAPI;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ModelsAPI getModelsAPI() {
|
||||||
|
return modelsAPI;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ProjectsAPI getProjectsAPI() {
|
||||||
|
return projectsAPI;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static SampleAPI getSampleAPI() {
|
||||||
|
return sampleAPI;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static SpeechToSpeechAPI getSpeechToSpeechAPI() {
|
||||||
|
return speechToSpeechAPI;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static TextToSpeechAPI getTextToSpeechAPI() {
|
||||||
|
return textToSpeechAPI;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static UserAPI getUserAPI() {
|
||||||
|
return userAPI;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static VoiceAPI getVoiceAPI() {
|
||||||
|
return voiceAPI;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,266 +0,0 @@
|
|||||||
package net.andrewcpu.elevenlabs;
|
|
||||||
|
|
||||||
import net.andrewcpu.elevenlabs.api.ElevenLabsRequest;
|
|
||||||
import net.andrewcpu.elevenlabs.api.ElevenLabsResponse;
|
|
||||||
import net.andrewcpu.elevenlabs.api.multipart.MultipartFile;
|
|
||||||
import net.andrewcpu.elevenlabs.api.multipart.MultipartFormContent;
|
|
||||||
import net.andrewcpu.elevenlabs.api.requests.history.DeleteHistoryItemRequest;
|
|
||||||
import net.andrewcpu.elevenlabs.api.requests.history.DownloadHistoryRequest;
|
|
||||||
import net.andrewcpu.elevenlabs.api.requests.history.GetHistoryAudioRequest;
|
|
||||||
import net.andrewcpu.elevenlabs.api.requests.history.GetHistoryRequest;
|
|
||||||
import net.andrewcpu.elevenlabs.api.requests.samples.DeleteSampleRequest;
|
|
||||||
import net.andrewcpu.elevenlabs.api.requests.samples.GetAudioSampleRequest;
|
|
||||||
import net.andrewcpu.elevenlabs.api.requests.user.GetSubscriptionInfoRequest;
|
|
||||||
import net.andrewcpu.elevenlabs.api.requests.user.GetUserRequest;
|
|
||||||
import net.andrewcpu.elevenlabs.api.requests.voices.*;
|
|
||||||
import net.andrewcpu.elevenlabs.api.requests.voices.settings.GetDefaultVoiceSettingsRequest;
|
|
||||||
import net.andrewcpu.elevenlabs.api.requests.voices.settings.GetVoiceSettingsRequest;
|
|
||||||
import net.andrewcpu.elevenlabs.api.requests.voices.settings.UpdateVoiceSettingsRequest;
|
|
||||||
import net.andrewcpu.elevenlabs.elements.user.Subscription;
|
|
||||||
import net.andrewcpu.elevenlabs.elements.user.User;
|
|
||||||
import net.andrewcpu.elevenlabs.elements.voice.History;
|
|
||||||
import net.andrewcpu.elevenlabs.elements.voice.Sample;
|
|
||||||
import net.andrewcpu.elevenlabs.elements.voice.Voice;
|
|
||||||
import net.andrewcpu.elevenlabs.elements.voice.VoiceSettings;
|
|
||||||
import net.andrewcpu.elevenlabs.enums.ContentType;
|
|
||||||
import net.andrewcpu.elevenlabs.exceptions.ElevenLabsAPINotInitiatedException;
|
|
||||||
import net.andrewcpu.elevenlabs.exceptions.ElevenLabsException;
|
|
||||||
import net.andrewcpu.elevenlabs.exceptions.ElevenLabsValidationException;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.net.HttpURLConnection;
|
|
||||||
import java.net.ProtocolException;
|
|
||||||
import java.net.URL;
|
|
||||||
import java.nio.charset.StandardCharsets;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import static net.andrewcpu.elevenlabs.util.MultipartUtil.addFilePart;
|
|
||||||
import static net.andrewcpu.elevenlabs.util.MultipartUtil.addFormField;
|
|
||||||
|
|
||||||
@SuppressWarnings({"unchecked", "UnusedReturnValue"})
|
|
||||||
public class ElevenLabsAPI {
|
|
||||||
//this class needs help
|
|
||||||
private static ElevenLabsAPI instance;
|
|
||||||
private static final String baseURL = "https://api.elevenlabs.io/v1/";
|
|
||||||
private static boolean debugMode = false;
|
|
||||||
|
|
||||||
public static boolean isDebugMode() {
|
|
||||||
return debugMode;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void setDebugMode(boolean enabled){
|
|
||||||
debugMode = enabled;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ElevenLabsAPI getInstance() {
|
|
||||||
if (instance == null) {
|
|
||||||
instance = new ElevenLabsAPI();
|
|
||||||
}
|
|
||||||
return instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private boolean instantiated;
|
|
||||||
private String apiKey;
|
|
||||||
|
|
||||||
public ElevenLabsAPI() {
|
|
||||||
instantiated = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAPIKey(String apiKey) {
|
|
||||||
instantiated = true;
|
|
||||||
this.apiKey = apiKey;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Subscription getSubscription() throws ElevenLabsException {
|
|
||||||
return (Subscription) getResult(new GetSubscriptionInfoRequest());
|
|
||||||
}
|
|
||||||
|
|
||||||
public User getUser() throws ElevenLabsException {
|
|
||||||
return (User) getResult(new GetUserRequest());
|
|
||||||
}
|
|
||||||
|
|
||||||
public File getTextToSpeech(String text, Voice voice, VoiceSettings settings, File outputFile) throws ElevenLabsException {
|
|
||||||
return (File)getResult(new GenerateTextToSpeechRequest(voice, settings, text, outputFile));
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<Voice> getVoices() throws ElevenLabsException {
|
|
||||||
return (List<Voice>) getResult(new GetVoicesRequest());
|
|
||||||
}
|
|
||||||
|
|
||||||
public Voice getVoice(String voiceId, boolean withSettings) throws ElevenLabsException {
|
|
||||||
return (Voice)getResult(new GetVoiceRequest(voiceId, withSettings));
|
|
||||||
}
|
|
||||||
|
|
||||||
public Voice getVoice(String voiceId) throws ElevenLabsException {
|
|
||||||
return getVoice(voiceId, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
public VoiceSettings getVoiceSettings(String voiceId) throws ElevenLabsException {
|
|
||||||
return (VoiceSettings) getResult(new GetVoiceSettingsRequest(voiceId));
|
|
||||||
}
|
|
||||||
|
|
||||||
public VoiceSettings getVoiceSettings(Voice voice) throws ElevenLabsException {
|
|
||||||
return getVoiceSettings(voice.getVoiceId());
|
|
||||||
}
|
|
||||||
|
|
||||||
public String deleteVoice(Voice voice) throws ElevenLabsException {
|
|
||||||
return deleteVoice(voice.getVoiceId());
|
|
||||||
}
|
|
||||||
|
|
||||||
public String deleteVoice(String voiceId) throws ElevenLabsException {
|
|
||||||
return (String)getResult(new DeleteVoiceRequest(voiceId));
|
|
||||||
}
|
|
||||||
|
|
||||||
public String editVoice(Voice voice, VoiceSettings voiceSettings) throws ElevenLabsException {
|
|
||||||
return editVoice(voice.getVoiceId(), voiceSettings);
|
|
||||||
}
|
|
||||||
|
|
||||||
public String editVoice(String voiceId, VoiceSettings settings) throws ElevenLabsException {
|
|
||||||
return (String)getResult(new UpdateVoiceSettingsRequest(voiceId, settings));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public String deleteSample(String voiceId, String sampleId) throws ElevenLabsException {
|
|
||||||
return (String)getResult(new DeleteSampleRequest(voiceId, sampleId));
|
|
||||||
}
|
|
||||||
|
|
||||||
public String deleteSample(Voice voice, String sampleId) throws ElevenLabsException {
|
|
||||||
return deleteSample(voice.getVoiceId(), sampleId);
|
|
||||||
}
|
|
||||||
public String deleteSample(String voiceId, Sample sample) throws ElevenLabsException {
|
|
||||||
return deleteSample(voiceId, sample.getSampleId());
|
|
||||||
}
|
|
||||||
|
|
||||||
public String deleteSample(Voice voice, Sample sample) throws ElevenLabsException {
|
|
||||||
return deleteSample(voice.getVoiceId(), sample.getSampleId());
|
|
||||||
}
|
|
||||||
|
|
||||||
public File getSampleAudio(String voiceId, String sampleId, File file) throws ElevenLabsException {
|
|
||||||
return (File)getResult(new GetAudioSampleRequest(voiceId, sampleId, file));
|
|
||||||
}
|
|
||||||
public File getSampleAudio(Voice voice, Sample sample, File file) throws ElevenLabsException {
|
|
||||||
return getSampleAudio(voice.getVoiceId(), sample.getSampleId(), file);
|
|
||||||
}
|
|
||||||
|
|
||||||
public History getHistory() throws ElevenLabsException {
|
|
||||||
return (History)getResult(new GetHistoryRequest());
|
|
||||||
}
|
|
||||||
|
|
||||||
public File downloadHistory(List<String> historyIds, File outputFile) throws ElevenLabsException {
|
|
||||||
return (File)getResult(new DownloadHistoryRequest(historyIds, outputFile));
|
|
||||||
}
|
|
||||||
|
|
||||||
public File getHistoryItemAudio(History.HistoryItem historyItem, File outputFile) throws ElevenLabsException {
|
|
||||||
return (File)getResult(new GetHistoryAudioRequest(historyItem.getHistoryItemId(), outputFile));
|
|
||||||
}
|
|
||||||
|
|
||||||
public String deleteHistoryItem(History.HistoryItem historyItem) throws ElevenLabsException {
|
|
||||||
return (String)getResult(new DeleteHistoryItemRequest(historyItem.getHistoryItemId()));
|
|
||||||
}
|
|
||||||
|
|
||||||
public VoiceSettings getDefaultVoiceSettings() throws ElevenLabsException {
|
|
||||||
return (VoiceSettings)getResult(new GetDefaultVoiceSettingsRequest());
|
|
||||||
}
|
|
||||||
|
|
||||||
public String createVoice(String name, Map<String, String> labels, List<File> files) throws ElevenLabsException {
|
|
||||||
CreateVoiceRequest request = new CreateVoiceRequest(name, files, labels);
|
|
||||||
return (String)(getResult(request));
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("UnusedReturnValue")
|
|
||||||
public String editVoice(String voiceId, String name, Map<String, String> labels, List<File> files) throws ElevenLabsException {
|
|
||||||
EditVoiceRequest editVoiceRequest = new EditVoiceRequest(voiceId,name,files,labels);
|
|
||||||
return (String)(getResult(editVoiceRequest));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private void checkOrThrow(ElevenLabsResponse<?> response) throws ElevenLabsException {
|
|
||||||
if(response == null){
|
|
||||||
throw new ElevenLabsValidationException("An error has occurred.");
|
|
||||||
}
|
|
||||||
if(!response.isSuccessful()){
|
|
||||||
throw response.getException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private Object getResult(ElevenLabsRequest<?> request) throws ElevenLabsException {
|
|
||||||
ElevenLabsResponse<?> response = sendRequest(request);
|
|
||||||
checkOrThrow(response);
|
|
||||||
return response.getResult();
|
|
||||||
}
|
|
||||||
|
|
||||||
private ElevenLabsResponse<?> sendRequest(ElevenLabsRequest<?> request) throws ElevenLabsAPINotInitiatedException {
|
|
||||||
if(!instantiated){
|
|
||||||
throw new ElevenLabsAPINotInitiatedException();
|
|
||||||
}
|
|
||||||
String formattedEndpoint = request.getFormattedEndpoint();
|
|
||||||
String boundary = "---------------------------" + System.currentTimeMillis();
|
|
||||||
|
|
||||||
URL url = null;
|
|
||||||
int responseCode = 999;
|
|
||||||
InputStream successStream = null,
|
|
||||||
errorStream = null;
|
|
||||||
|
|
||||||
try {
|
|
||||||
url = new URL(baseURL + formattedEndpoint);
|
|
||||||
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
|
||||||
setupConnection(request, boundary, connection);
|
|
||||||
|
|
||||||
if(request.getContentType() == ContentType.JSON){
|
|
||||||
handleJSON(request, connection);
|
|
||||||
}
|
|
||||||
else if(request.getContentType() == ContentType.MULTIPART){
|
|
||||||
handleMultipart(request, connection, boundary);
|
|
||||||
}
|
|
||||||
responseCode = connection.getResponseCode();
|
|
||||||
if (responseCode >= 200 && responseCode < 300) {
|
|
||||||
successStream = connection.getInputStream();
|
|
||||||
} else {
|
|
||||||
errorStream = connection.getErrorStream();
|
|
||||||
}
|
|
||||||
} catch (IOException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
return new ElevenLabsResponse<>(responseCode, errorStream, successStream, request);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setupConnection(ElevenLabsRequest<?> request, String boundary, HttpURLConnection connection) throws ProtocolException {
|
|
||||||
connection.setConnectTimeout(60000);
|
|
||||||
connection.setReadTimeout(60000);
|
|
||||||
connection.setRequestMethod(request.getMethod().name());
|
|
||||||
String contType = request.getContentType().getType();
|
|
||||||
if(request.getContentType() == ContentType.MULTIPART){
|
|
||||||
contType += "; boundary=" + boundary;
|
|
||||||
}
|
|
||||||
connection.setRequestProperty("xi-api-key", apiKey);
|
|
||||||
connection.setRequestProperty("Content-Type", contType); // this can be done better.
|
|
||||||
connection.setDoOutput(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void handleJSON(ElevenLabsRequest<?> request, HttpURLConnection connection) throws IOException {
|
|
||||||
if (request.getBody() != null) {
|
|
||||||
connection.getOutputStream().write(request.getBody().toJSONString().getBytes(StandardCharsets.UTF_8));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void handleMultipart(ElevenLabsRequest<?> request, HttpURLConnection connection, String boundary) throws IOException {
|
|
||||||
for(MultipartFormContent item : request.getMultipartForm().getItems()){
|
|
||||||
if(item instanceof MultipartFile multipartFile){
|
|
||||||
addFilePart(multipartFile.getName(),multipartFile.getFilename(), multipartFile.getFile(), boundary, connection);
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
addFormField(item.getName(), item.getValue(), boundary, connection);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
String footer = "--" + boundary + "--\r\n";
|
|
||||||
connection.getOutputStream().write(footer.getBytes(StandardCharsets.UTF_8));
|
|
||||||
connection.getOutputStream().flush();
|
|
||||||
connection.getOutputStream().close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
package net.andrewcpu.elevenlabs.api;
|
||||||
|
|
||||||
|
import net.andrewcpu.elevenlabs.requests.ElevenLabsRequest;
|
||||||
|
import net.andrewcpu.elevenlabs.util.ElevenNetworkUtil;
|
||||||
|
|
||||||
|
public abstract class ElevenLabsAPI {
|
||||||
|
public ElevenLabsAPI() {
|
||||||
|
}
|
||||||
|
|
||||||
|
protected <T> T sendRequest(ElevenLabsRequest<T> request) {
|
||||||
|
return ElevenNetworkUtil.sendRequest(request.getType(),request.getEndpoint(), request.getPayload(),request.getResponseClass());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,109 +0,0 @@
|
|||||||
package net.andrewcpu.elevenlabs.api;
|
|
||||||
|
|
||||||
import net.andrewcpu.elevenlabs.api.multipart.MultipartForm;
|
|
||||||
import net.andrewcpu.elevenlabs.api.transformers.ResultTransformer;
|
|
||||||
import net.andrewcpu.elevenlabs.enums.ContentType;
|
|
||||||
import net.andrewcpu.elevenlabs.enums.HTTPMethod;
|
|
||||||
import net.andrewcpu.elevenlabs.enums.ResponseType;
|
|
||||||
import org.json.simple.JSONObject;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public abstract class ElevenLabsRequest<T> {
|
|
||||||
protected ContentType contentType = ContentType.JSON;
|
|
||||||
protected ResponseType responseType = ResponseType.JSON;
|
|
||||||
protected final HTTPMethod method;
|
|
||||||
protected List<String> parameters;
|
|
||||||
protected ResultTransformer<T> resultTransformer;
|
|
||||||
protected JSONObject body;
|
|
||||||
protected File outputFilePath;
|
|
||||||
protected MultipartForm multipartForm;
|
|
||||||
|
|
||||||
public ElevenLabsRequest(List<String> parameters, JSONObject body, HTTPMethod method, ResultTransformer<T> resultTransformer) {
|
|
||||||
this.method = method;
|
|
||||||
this.parameters = parameters;
|
|
||||||
this.body = body;
|
|
||||||
this.resultTransformer = resultTransformer;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ElevenLabsRequest(JSONObject body, HTTPMethod method) {
|
|
||||||
this.body = body;
|
|
||||||
this.method = method;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ElevenLabsRequest(List<String> parameters, HTTPMethod method) {
|
|
||||||
this.parameters = parameters;
|
|
||||||
this.method = method;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ElevenLabsRequest(List<String> parameters, HTTPMethod method, ResultTransformer<T> resultTransformer) {
|
|
||||||
this.parameters = parameters;
|
|
||||||
this.method = method;
|
|
||||||
this.resultTransformer = resultTransformer;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ElevenLabsRequest(HTTPMethod method) {
|
|
||||||
this.method = method;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ElevenLabsRequest(HTTPMethod method, ResultTransformer<T> resultTransformer) {
|
|
||||||
this.method = method;
|
|
||||||
this.resultTransformer = resultTransformer;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ElevenLabsRequest(JSONObject body, HTTPMethod method, ResultTransformer<T> resultTransformer) {
|
|
||||||
this.resultTransformer = resultTransformer;
|
|
||||||
this.method = method;
|
|
||||||
this.body = body;
|
|
||||||
}
|
|
||||||
|
|
||||||
public abstract String getEndpoint();
|
|
||||||
|
|
||||||
|
|
||||||
public MultipartForm getMultipartForm() {
|
|
||||||
return multipartForm;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ContentType getContentType() {
|
|
||||||
return contentType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public HTTPMethod getMethod() {
|
|
||||||
return method;
|
|
||||||
}
|
|
||||||
|
|
||||||
public File getOutputFilePath() {
|
|
||||||
return outputFilePath;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public ResultTransformer<T> getResultTransformer() {
|
|
||||||
return resultTransformer;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getFormattedEndpoint(){
|
|
||||||
String endpoint = getEndpoint();
|
|
||||||
if(endpoint.startsWith("/")){
|
|
||||||
endpoint = endpoint.substring(1);
|
|
||||||
}
|
|
||||||
if(parameters != null && !parameters.isEmpty()){
|
|
||||||
for(int i = 0; i<parameters.size(); i++){
|
|
||||||
endpoint = endpoint.replaceFirst("\\{.*?}", parameters.get(i));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return endpoint;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public JSONObject getBody() {
|
|
||||||
return body;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public ResponseType getResponseType() {
|
|
||||||
return responseType;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,89 +0,0 @@
|
|||||||
package net.andrewcpu.elevenlabs.api;
|
|
||||||
|
|
||||||
import net.andrewcpu.elevenlabs.enums.ResponseType;
|
|
||||||
import net.andrewcpu.elevenlabs.exceptions.ElevenLabsExceptionBuilder;
|
|
||||||
import net.andrewcpu.elevenlabs.exceptions.ElevenLabsValidationException;
|
|
||||||
import net.andrewcpu.elevenlabs.util.DebugLogger;
|
|
||||||
import org.json.simple.JSONObject;
|
|
||||||
import org.json.simple.parser.JSONParser;
|
|
||||||
import org.json.simple.parser.ParseException;
|
|
||||||
|
|
||||||
import java.io.FileOutputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.io.OutputStream;
|
|
||||||
import java.nio.charset.StandardCharsets;
|
|
||||||
|
|
||||||
public class ElevenLabsResponse<T> {
|
|
||||||
private final int responseCode;
|
|
||||||
private final InputStream errorStream;
|
|
||||||
private final InputStream successStream;
|
|
||||||
private final ElevenLabsRequest<T> request;
|
|
||||||
private JSONObject successful;
|
|
||||||
private JSONObject error;
|
|
||||||
private T resultingObject;
|
|
||||||
|
|
||||||
public ElevenLabsResponse(int responseCode, InputStream errorStream, InputStream successStream, ElevenLabsRequest<T> request) {
|
|
||||||
this.responseCode = responseCode;
|
|
||||||
this.errorStream = errorStream;
|
|
||||||
this.successStream = successStream;
|
|
||||||
this.request = request;
|
|
||||||
try {
|
|
||||||
_buildObjects();
|
|
||||||
} catch (IOException | ParseException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private void _buildObjects() throws IOException, ParseException {
|
|
||||||
if(isSuccessful()){
|
|
||||||
if(request.getResponseType() == ResponseType.JSON){
|
|
||||||
String responseBody = new String(successStream.readAllBytes(), StandardCharsets.UTF_8);
|
|
||||||
DebugLogger.log(getClass(), responseBody);
|
|
||||||
JSONObject object = ((JSONObject) new JSONParser().parse(responseBody));
|
|
||||||
this.successful = object;
|
|
||||||
resultingObject = request.getResultTransformer().transform(object);
|
|
||||||
}
|
|
||||||
else if(request.getResponseType() == ResponseType.FILE_STREAM){
|
|
||||||
try (InputStream inputStream = successStream) {
|
|
||||||
byte[] buffer = new byte[4096];
|
|
||||||
int bytesRead;
|
|
||||||
try (OutputStream outputStream = new FileOutputStream(request.getOutputFilePath())) {
|
|
||||||
while ((bytesRead = inputStream.read(buffer)) != -1) {
|
|
||||||
outputStream.write(buffer, 0, bytesRead);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
resultingObject = request.getResultTransformer().transform();
|
|
||||||
|
|
||||||
}
|
|
||||||
else if(request.getResponseType() == ResponseType.STRING){
|
|
||||||
String responseBody = new String(successStream.readAllBytes(), StandardCharsets.UTF_8);
|
|
||||||
DebugLogger.log(getClass(), responseBody);
|
|
||||||
resultingObject = request.getResultTransformer().transform(responseBody);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
String responseBody = new String(errorStream.readAllBytes(), StandardCharsets.UTF_8);
|
|
||||||
DebugLogger.log(getClass(), responseBody);
|
|
||||||
this.error = ((JSONObject) new JSONParser().parse(responseBody));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public ElevenLabsValidationException getException() {
|
|
||||||
return ElevenLabsExceptionBuilder.build(this.error);
|
|
||||||
}
|
|
||||||
|
|
||||||
public T getResult() {
|
|
||||||
return resultingObject;
|
|
||||||
}
|
|
||||||
|
|
||||||
public JSONObject getResultJSON() {
|
|
||||||
return successful;
|
|
||||||
}
|
|
||||||
public boolean isSuccessful() {
|
|
||||||
return responseCode >= 200 && responseCode < 300;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
package net.andrewcpu.elevenlabs.api.impl;
|
||||||
|
|
||||||
|
import net.andrewcpu.elevenlabs.api.ElevenLabsAPI;
|
||||||
|
import net.andrewcpu.elevenlabs.model.request.CreateAudioNativeProjectRequest;
|
||||||
|
import net.andrewcpu.elevenlabs.model.response.CreateAudioEnabledProjectModelResponse;
|
||||||
|
import net.andrewcpu.elevenlabs.requests.audionative.PostCreateAudioNativeProjectRequest;
|
||||||
|
|
||||||
|
public class AudioNativeAPI extends ElevenLabsAPI {
|
||||||
|
public CreateAudioEnabledProjectModelResponse createAudioEnabledProject(CreateAudioNativeProjectRequest request) {
|
||||||
|
return sendRequest(new PostCreateAudioNativeProjectRequest(request));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
package net.andrewcpu.elevenlabs.api.impl;
|
||||||
|
|
||||||
|
import net.andrewcpu.elevenlabs.api.ElevenLabsAPI;
|
||||||
|
import net.andrewcpu.elevenlabs.model.history.History;
|
||||||
|
import net.andrewcpu.elevenlabs.model.history.HistoryItem;
|
||||||
|
import net.andrewcpu.elevenlabs.requests.history.*;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
|
public class HistoryAPI extends ElevenLabsAPI {
|
||||||
|
|
||||||
|
public History getHistory() {
|
||||||
|
return sendRequest(new GetHistoryRequest());
|
||||||
|
}
|
||||||
|
|
||||||
|
public HistoryItem getHistoryItem(String historyItemId) {
|
||||||
|
return sendRequest(new GetHistoryItemByIdRequest(historyItemId));
|
||||||
|
}
|
||||||
|
|
||||||
|
public String deleteHistoryItem(String historyItemId) {
|
||||||
|
return sendRequest(new DeleteHistoryItemRequest(historyItemId));
|
||||||
|
}
|
||||||
|
|
||||||
|
public File getHistoryItemAudio(String historyItemId) {
|
||||||
|
return sendRequest(new GetHistoryItemAudioRequest(historyItemId));
|
||||||
|
}
|
||||||
|
|
||||||
|
public File getHistoryItemAudio(String... historyItemIds) {
|
||||||
|
return sendRequest(new PostDownloadHistoryItemsRequest(historyItemIds));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
package net.andrewcpu.elevenlabs.api.impl;
|
||||||
|
|
||||||
|
import net.andrewcpu.elevenlabs.api.ElevenLabsAPI;
|
||||||
|
import net.andrewcpu.elevenlabs.model.response.GenerationTypeModel;
|
||||||
|
import net.andrewcpu.elevenlabs.requests.models.GetModelsRequest;
|
||||||
|
|
||||||
|
public class ModelsAPI extends ElevenLabsAPI {
|
||||||
|
|
||||||
|
public GenerationTypeModel[] getAvailableModels() {
|
||||||
|
return sendRequest(new GetModelsRequest());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,67 @@
|
|||||||
|
package net.andrewcpu.elevenlabs.api.impl;
|
||||||
|
|
||||||
|
import net.andrewcpu.elevenlabs.api.ElevenLabsAPI;
|
||||||
|
import net.andrewcpu.elevenlabs.model.projects.Chapter;
|
||||||
|
import net.andrewcpu.elevenlabs.model.projects.ChapterSnapshot;
|
||||||
|
import net.andrewcpu.elevenlabs.model.projects.Project;
|
||||||
|
import net.andrewcpu.elevenlabs.model.projects.ProjectSnapshot;
|
||||||
|
import net.andrewcpu.elevenlabs.model.request.AddProjectRequest;
|
||||||
|
import net.andrewcpu.elevenlabs.requests.projects.*;
|
||||||
|
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class ProjectsAPI extends ElevenLabsAPI {
|
||||||
|
public List<Project> getProjects() {
|
||||||
|
return sendRequest(new GetProjectsRequest()).getProjects();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Project addProject(AddProjectRequest addProjectRequest) {
|
||||||
|
return sendRequest(new PostAddProjectRequest(addProjectRequest)).getProject();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Project getProject(String id) {
|
||||||
|
return sendRequest(new GetProjectByIdRequest(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
public String deleteProject(String projectId) {
|
||||||
|
return sendRequest(new DeleteProjectByIdRequest(projectId));
|
||||||
|
}
|
||||||
|
|
||||||
|
public String convertProject(String projectId) {
|
||||||
|
return sendRequest(new PostConvertProjectRequest(projectId));
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ProjectSnapshot> getProjectSnapshots(String projectId) {
|
||||||
|
return sendRequest(new GetProjectSnapshotsRequest(projectId)).getSnapshots();
|
||||||
|
}
|
||||||
|
|
||||||
|
public InputStream getProjectSnapshotAudioStream(String projectId, String projectSnapshotId) {
|
||||||
|
return sendRequest(new PostStreamProjectSnapshotAudioRequest(projectId, projectSnapshotId));
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Chapter> getChapters(String projectId) {
|
||||||
|
return sendRequest(new GetProjectChaptersRequest(projectId)).getChapters();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Chapter getChapterById(String projectId, String chapterId) {
|
||||||
|
return sendRequest(new GetChapterByIdRequest(projectId, chapterId));
|
||||||
|
}
|
||||||
|
|
||||||
|
public String deleteChapter(String projectId, String chapterId) {
|
||||||
|
return sendRequest(new DeleteChapterByIdRequest(projectId, chapterId));
|
||||||
|
}
|
||||||
|
|
||||||
|
public String convertChapter(String projectId, String chapterId) {
|
||||||
|
return sendRequest(new PostConvertChapterRequest(projectId, chapterId));
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ChapterSnapshot> getChapterSnapshots(String projectId, String chapterId) {
|
||||||
|
return sendRequest(new GetChapterSnapshotsRequest(projectId, chapterId)).getSnapshots();
|
||||||
|
}
|
||||||
|
|
||||||
|
public InputStream getChapterSnapshotAudioStream(String projectId, String chapterId, String chapterSnapshotId) {
|
||||||
|
return sendRequest(new PostStreamChapterSnapshotAudioRequest(projectId, chapterId, chapterSnapshotId));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
package net.andrewcpu.elevenlabs.api.impl;
|
||||||
|
|
||||||
|
import net.andrewcpu.elevenlabs.api.ElevenLabsAPI;
|
||||||
|
import net.andrewcpu.elevenlabs.requests.samples.DeleteSampleRequest;
|
||||||
|
import net.andrewcpu.elevenlabs.requests.samples.GetSampleRequest;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
|
public class SampleAPI extends ElevenLabsAPI {
|
||||||
|
|
||||||
|
public String deleteSample(String voiceId, String sampleId) {
|
||||||
|
return sendRequest(new DeleteSampleRequest(voiceId, sampleId));
|
||||||
|
}
|
||||||
|
|
||||||
|
public File getAudioSample(String voiceId, String sampleId) {
|
||||||
|
return sendRequest(new GetSampleRequest(voiceId, sampleId));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
package net.andrewcpu.elevenlabs.api.impl;
|
||||||
|
|
||||||
|
import net.andrewcpu.elevenlabs.api.ElevenLabsAPI;
|
||||||
|
import net.andrewcpu.elevenlabs.enums.StreamLatencyOptimization;
|
||||||
|
import net.andrewcpu.elevenlabs.model.voice.VoiceSettings;
|
||||||
|
import net.andrewcpu.elevenlabs.requests.sts.PostSpeechToSpeechRequest;
|
||||||
|
import net.andrewcpu.elevenlabs.requests.sts.PostSpeechToSpeechStreamedRequest;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.InputStream;
|
||||||
|
|
||||||
|
public class SpeechToSpeechAPI extends ElevenLabsAPI {
|
||||||
|
public File generateSpeechToSpeech(String voiceId, VoiceSettings voiceSettings, String modelId, File audio) {
|
||||||
|
return generateSpeechToSpeech(voiceId, voiceSettings, modelId, audio, StreamLatencyOptimization.getDefault());
|
||||||
|
}
|
||||||
|
|
||||||
|
public File generateSpeechToSpeech(String voiceId, VoiceSettings voiceSettings, String modelId, File audio, StreamLatencyOptimization latencyOptimization) {
|
||||||
|
return sendRequest(new PostSpeechToSpeechRequest(voiceId, voiceSettings,audio, modelId, latencyOptimization));
|
||||||
|
}
|
||||||
|
|
||||||
|
public InputStream generateSpeechToSpeechStream(String voiceId, VoiceSettings voiceSettings, String modelId, File audio, StreamLatencyOptimization streamLatencyOptimization) {
|
||||||
|
return sendRequest(new PostSpeechToSpeechStreamedRequest(voiceId, voiceSettings, audio, modelId, streamLatencyOptimization));
|
||||||
|
}
|
||||||
|
|
||||||
|
public InputStream generateSpeechToSpeechStream(String voiceId, VoiceSettings voiceSettings, String modelId, File audio) {
|
||||||
|
return generateSpeechToSpeechStream(voiceId, voiceSettings, modelId, audio, StreamLatencyOptimization.getDefault());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
package net.andrewcpu.elevenlabs.api.impl;
|
||||||
|
|
||||||
|
import net.andrewcpu.elevenlabs.api.ElevenLabsAPI;
|
||||||
|
import net.andrewcpu.elevenlabs.enums.GeneratedAudioOutputFormat;
|
||||||
|
import net.andrewcpu.elevenlabs.enums.StreamLatencyOptimization;
|
||||||
|
import net.andrewcpu.elevenlabs.model.request.TextToSpeechRequest;
|
||||||
|
import net.andrewcpu.elevenlabs.model.voice.VoiceSettings;
|
||||||
|
import net.andrewcpu.elevenlabs.requests.tts.PostTextToSpeechRequest;
|
||||||
|
import net.andrewcpu.elevenlabs.requests.tts.PostTextToSpeechStreamedRequest;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.InputStream;
|
||||||
|
|
||||||
|
public class TextToSpeechAPI extends ElevenLabsAPI {
|
||||||
|
|
||||||
|
public File generateTextToSpeech(String voiceId, String text, String modelId, VoiceSettings voiceSettings) {
|
||||||
|
return sendRequest(new PostTextToSpeechRequest(voiceId, new TextToSpeechRequest(text, modelId, voiceSettings)));
|
||||||
|
}
|
||||||
|
|
||||||
|
public File generateTextToSpeech(String voiceId, String text, String modelId, GeneratedAudioOutputFormat outputFormat, StreamLatencyOptimization streamLatencyOptimization, VoiceSettings voiceSettings) {
|
||||||
|
return sendRequest(new PostTextToSpeechRequest(voiceId, new TextToSpeechRequest(text, modelId, voiceSettings), streamLatencyOptimization, outputFormat));
|
||||||
|
}
|
||||||
|
public InputStream generateTextToSpeechStreamed(String voiceId, String text, String modelId, GeneratedAudioOutputFormat outputFormat, StreamLatencyOptimization streamLatencyOptimization, VoiceSettings voiceSettings) {
|
||||||
|
return sendRequest(new PostTextToSpeechStreamedRequest(voiceId, new TextToSpeechRequest(text, modelId, voiceSettings), streamLatencyOptimization, outputFormat));
|
||||||
|
}
|
||||||
|
|
||||||
|
public InputStream generateTextToSpeechStreamed(String voiceId, String text, String modelId, VoiceSettings voiceSettings) {
|
||||||
|
return sendRequest(new PostTextToSpeechStreamedRequest(voiceId, new TextToSpeechRequest(text, modelId, voiceSettings)));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
19
src/main/java/net/andrewcpu/elevenlabs/api/impl/UserAPI.java
Normal file
19
src/main/java/net/andrewcpu/elevenlabs/api/impl/UserAPI.java
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
package net.andrewcpu.elevenlabs.api.impl;
|
||||||
|
|
||||||
|
import net.andrewcpu.elevenlabs.api.ElevenLabsAPI;
|
||||||
|
import net.andrewcpu.elevenlabs.model.user.Subscription;
|
||||||
|
import net.andrewcpu.elevenlabs.model.user.User;
|
||||||
|
import net.andrewcpu.elevenlabs.requests.user.GetSubscriptionRequest;
|
||||||
|
import net.andrewcpu.elevenlabs.requests.user.GetUserRequest;
|
||||||
|
|
||||||
|
public class UserAPI extends ElevenLabsAPI {
|
||||||
|
|
||||||
|
|
||||||
|
public User getUser() {
|
||||||
|
return sendRequest(new GetUserRequest());
|
||||||
|
}
|
||||||
|
|
||||||
|
public Subscription getSubscription() {
|
||||||
|
return sendRequest(new GetSubscriptionRequest());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,55 @@
|
|||||||
|
package net.andrewcpu.elevenlabs.api.impl;
|
||||||
|
|
||||||
|
import net.andrewcpu.elevenlabs.api.ElevenLabsAPI;
|
||||||
|
import net.andrewcpu.elevenlabs.model.response.CreateVoiceResponse;
|
||||||
|
import net.andrewcpu.elevenlabs.model.response.ProjectsModelResponse;
|
||||||
|
import net.andrewcpu.elevenlabs.model.voice.Voice;
|
||||||
|
import net.andrewcpu.elevenlabs.model.voice.VoiceSettings;
|
||||||
|
import net.andrewcpu.elevenlabs.requests.projects.GetProjectsRequest;
|
||||||
|
import net.andrewcpu.elevenlabs.requests.voices.*;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class VoiceAPI extends ElevenLabsAPI {
|
||||||
|
|
||||||
|
public List<Voice> getVoices() {
|
||||||
|
return sendRequest(new GetVoicesRequest()).getVoices();
|
||||||
|
}
|
||||||
|
|
||||||
|
public VoiceSettings getDefaultVoiceSettings() {
|
||||||
|
return sendRequest(new GetDefaultVoiceSettingsRequest());
|
||||||
|
}
|
||||||
|
|
||||||
|
public VoiceSettings getVoiceSettings(String voiceId) {
|
||||||
|
return sendRequest(new GetVoiceSettingsRequest(voiceId));
|
||||||
|
}
|
||||||
|
|
||||||
|
public Voice getVoice(String voiceId) {
|
||||||
|
return sendRequest(new GetVoiceRequest(voiceId));
|
||||||
|
}
|
||||||
|
|
||||||
|
public Voice getVoice(String voiceId, boolean withSettings) {
|
||||||
|
return sendRequest(new GetVoiceRequest(voiceId, withSettings));
|
||||||
|
}
|
||||||
|
|
||||||
|
public ProjectsModelResponse getProjects() {
|
||||||
|
return sendRequest(new GetProjectsRequest());
|
||||||
|
}
|
||||||
|
|
||||||
|
public String deleteVoice(String voiceId) {
|
||||||
|
return sendRequest(new DeleteVoiceRequest(voiceId));
|
||||||
|
}
|
||||||
|
|
||||||
|
public String editVoiceSettings(String voiceId, VoiceSettings settings) {
|
||||||
|
return sendRequest(new PostEditVoiceSettingsRequest(voiceId, settings));
|
||||||
|
}
|
||||||
|
|
||||||
|
public CreateVoiceResponse createVoice(String name, File[] files, String description, Map<String, String> labels) {
|
||||||
|
return sendRequest(new PostAddVoiceRequest(name, files, description, labels));
|
||||||
|
}
|
||||||
|
public String editVoice(String voiceId, String name, File[] files, String description, Map<String, String> labels) {
|
||||||
|
return sendRequest(new PostEditVoiceRequest(voiceId, name, files, description, labels));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
package net.andrewcpu.elevenlabs.api.multipart;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
|
|
||||||
public class MultipartFile extends MultipartFormContent {
|
|
||||||
private final File file;
|
|
||||||
public MultipartFile(String name, File file) {
|
|
||||||
super(name, file);
|
|
||||||
this.file = file;
|
|
||||||
}
|
|
||||||
|
|
||||||
public File getFile() {
|
|
||||||
return file;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
package net.andrewcpu.elevenlabs.api.multipart;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class MultipartForm {
|
|
||||||
private final List<MultipartFormContent> items;
|
|
||||||
public MultipartForm() {
|
|
||||||
items = new ArrayList<>();
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<MultipartFormContent> getItems() {
|
|
||||||
return items;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void push(MultipartFormContent... formContent) {
|
|
||||||
items.addAll(Arrays.asList(formContent));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,35 +0,0 @@
|
|||||||
package net.andrewcpu.elevenlabs.api.multipart;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
|
|
||||||
public class MultipartFormContent {
|
|
||||||
private final String name;
|
|
||||||
private final String filename;
|
|
||||||
private final String value;
|
|
||||||
|
|
||||||
public MultipartFormContent(String name, File file) {
|
|
||||||
this.name = name;
|
|
||||||
this.filename = file.getName();
|
|
||||||
this.value = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public MultipartFormContent(String name, String value) {
|
|
||||||
this.name = name;
|
|
||||||
this.value = value;
|
|
||||||
this.filename = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getName() {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getFilename() {
|
|
||||||
return filename;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public String getValue() {
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,39 +0,0 @@
|
|||||||
package net.andrewcpu.elevenlabs.api.requests;
|
|
||||||
|
|
||||||
import net.andrewcpu.elevenlabs.api.ElevenLabsRequest;
|
|
||||||
import net.andrewcpu.elevenlabs.api.transformers.ResultTransformer;
|
|
||||||
import net.andrewcpu.elevenlabs.enums.HTTPMethod;
|
|
||||||
import org.json.simple.JSONObject;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public abstract class ElevenLabsDeleteRequest<T> extends ElevenLabsRequest<T> {
|
|
||||||
public ElevenLabsDeleteRequest(List<String> parameters, JSONObject body, ResultTransformer<T> resultTransformer) {
|
|
||||||
super(parameters, body, HTTPMethod.DELETE, resultTransformer);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ElevenLabsDeleteRequest(JSONObject body, ResultTransformer<T> resultTransformer) {
|
|
||||||
super(body, HTTPMethod.DELETE, resultTransformer);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public ElevenLabsDeleteRequest(JSONObject body) {
|
|
||||||
super(body, HTTPMethod.DELETE);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ElevenLabsDeleteRequest(List<String> parameters) {
|
|
||||||
super(parameters, HTTPMethod.DELETE);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ElevenLabsDeleteRequest(List<String> parameters, ResultTransformer<T> resultTransformer) {
|
|
||||||
super(parameters, HTTPMethod.DELETE, resultTransformer);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ElevenLabsDeleteRequest() {
|
|
||||||
super(HTTPMethod.DELETE);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ElevenLabsDeleteRequest(ResultTransformer<T> resultTransformer) {
|
|
||||||
super(HTTPMethod.DELETE, resultTransformer);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,37 +0,0 @@
|
|||||||
package net.andrewcpu.elevenlabs.api.requests;
|
|
||||||
|
|
||||||
import net.andrewcpu.elevenlabs.api.ElevenLabsRequest;
|
|
||||||
import net.andrewcpu.elevenlabs.api.transformers.ResultTransformer;
|
|
||||||
import net.andrewcpu.elevenlabs.enums.HTTPMethod;
|
|
||||||
import org.json.simple.JSONObject;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public abstract class ElevenLabsGetRequest<T> extends ElevenLabsRequest<T> {
|
|
||||||
public ElevenLabsGetRequest(List<String> parameters, JSONObject body, ResultTransformer<T> resultTransformer) {
|
|
||||||
super(parameters, body, HTTPMethod.GET, resultTransformer);
|
|
||||||
}
|
|
||||||
public ElevenLabsGetRequest(JSONObject body, ResultTransformer<T> resultTransformer) {
|
|
||||||
super(body, HTTPMethod.GET, resultTransformer);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ElevenLabsGetRequest(JSONObject body) {
|
|
||||||
super(body, HTTPMethod.GET);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ElevenLabsGetRequest(List<String> parameters) {
|
|
||||||
super(parameters, HTTPMethod.GET);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ElevenLabsGetRequest(List<String> parameters, ResultTransformer<T> resultTransformer) {
|
|
||||||
super(parameters, HTTPMethod.GET, resultTransformer);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ElevenLabsGetRequest() {
|
|
||||||
super(HTTPMethod.GET);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ElevenLabsGetRequest( ResultTransformer<T> resultTransformer) {
|
|
||||||
super(HTTPMethod.GET, resultTransformer);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,38 +0,0 @@
|
|||||||
package net.andrewcpu.elevenlabs.api.requests;
|
|
||||||
|
|
||||||
import net.andrewcpu.elevenlabs.api.ElevenLabsRequest;
|
|
||||||
import net.andrewcpu.elevenlabs.api.transformers.ResultTransformer;
|
|
||||||
import net.andrewcpu.elevenlabs.enums.HTTPMethod;
|
|
||||||
import org.json.simple.JSONObject;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public abstract class ElevenLabsPostRequest<T> extends ElevenLabsRequest<T> {
|
|
||||||
public ElevenLabsPostRequest(List<String> parameters, JSONObject body, ResultTransformer<T> resultTransformer) {
|
|
||||||
super(parameters, body, HTTPMethod.POST, resultTransformer);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ElevenLabsPostRequest(JSONObject body) {
|
|
||||||
super(body, HTTPMethod.POST);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ElevenLabsPostRequest(JSONObject body, ResultTransformer<T> resultTransformer) {
|
|
||||||
super(body, HTTPMethod.POST, resultTransformer);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ElevenLabsPostRequest(List<String> parameters) {
|
|
||||||
super(parameters, HTTPMethod.POST);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ElevenLabsPostRequest(List<String> parameters, ResultTransformer<T> resultTransformer) {
|
|
||||||
super(parameters, HTTPMethod.POST, resultTransformer);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ElevenLabsPostRequest() {
|
|
||||||
super(HTTPMethod.POST);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ElevenLabsPostRequest(ResultTransformer<T> resultTransformer) {
|
|
||||||
super(HTTPMethod.POST, resultTransformer);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
package net.andrewcpu.elevenlabs.api.requests.history;
|
|
||||||
|
|
||||||
import net.andrewcpu.elevenlabs.api.requests.ElevenLabsDeleteRequest;
|
|
||||||
import net.andrewcpu.elevenlabs.api.transformers.RequestTransformer;
|
|
||||||
import net.andrewcpu.elevenlabs.enums.ResponseType;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class DeleteHistoryItemRequest extends ElevenLabsDeleteRequest<String> {
|
|
||||||
public DeleteHistoryItemRequest(String historyId) {
|
|
||||||
super(List.of(historyId), RequestTransformer.STRING_RESULT_TRANSFORMER);
|
|
||||||
responseType = (ResponseType.STRING);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getEndpoint() {
|
|
||||||
return "history/{historyItemId}";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
package net.andrewcpu.elevenlabs.api.requests.history;
|
|
||||||
|
|
||||||
import net.andrewcpu.elevenlabs.api.requests.ElevenLabsPostRequest;
|
|
||||||
import net.andrewcpu.elevenlabs.api.transformers.FilePingPongTransformer;
|
|
||||||
import net.andrewcpu.elevenlabs.enums.ResponseType;
|
|
||||||
import org.json.simple.JSONArray;
|
|
||||||
import org.json.simple.JSONObject;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public class DownloadHistoryRequest extends ElevenLabsPostRequest<File> {
|
|
||||||
private static JSONObject getBody(List<String> historyIds) {
|
|
||||||
JSONObject object = new JSONObject();
|
|
||||||
JSONArray array = new JSONArray();
|
|
||||||
array.addAll(historyIds);
|
|
||||||
object.put("history_item_ids", array);
|
|
||||||
return object;
|
|
||||||
}
|
|
||||||
public DownloadHistoryRequest(List<String> historyIds, File outputFile) {
|
|
||||||
super(null, getBody(historyIds), new FilePingPongTransformer(outputFile));
|
|
||||||
responseType = (ResponseType.FILE_STREAM);
|
|
||||||
outputFilePath = (outputFile);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getEndpoint() {
|
|
||||||
return "history/download";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
package net.andrewcpu.elevenlabs.api.requests.history;
|
|
||||||
|
|
||||||
import net.andrewcpu.elevenlabs.api.requests.ElevenLabsGetRequest;
|
|
||||||
import net.andrewcpu.elevenlabs.api.transformers.FilePingPongTransformer;
|
|
||||||
import net.andrewcpu.elevenlabs.enums.ResponseType;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class GetHistoryAudioRequest extends ElevenLabsGetRequest<File> {
|
|
||||||
public GetHistoryAudioRequest(String historyId, File outputFile) {
|
|
||||||
super(List.of(historyId), new FilePingPongTransformer(outputFile));
|
|
||||||
responseType = (ResponseType.FILE_STREAM);
|
|
||||||
outputFilePath = (outputFile);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getEndpoint() {
|
|
||||||
return "history/{historyItemId}/audio";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
package net.andrewcpu.elevenlabs.api.requests.history;
|
|
||||||
|
|
||||||
import net.andrewcpu.elevenlabs.api.requests.ElevenLabsGetRequest;
|
|
||||||
import net.andrewcpu.elevenlabs.api.transformers.RequestTransformer;
|
|
||||||
import net.andrewcpu.elevenlabs.elements.voice.History;
|
|
||||||
|
|
||||||
public class GetHistoryRequest extends ElevenLabsGetRequest<History> {
|
|
||||||
public GetHistoryRequest() {
|
|
||||||
super(RequestTransformer.HISTORY_TRANSFORMER);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getEndpoint() {
|
|
||||||
return "history";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
package net.andrewcpu.elevenlabs.api.requests.samples;
|
|
||||||
|
|
||||||
import net.andrewcpu.elevenlabs.api.requests.ElevenLabsDeleteRequest;
|
|
||||||
import net.andrewcpu.elevenlabs.api.transformers.RequestTransformer;
|
|
||||||
import net.andrewcpu.elevenlabs.enums.ResponseType;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class DeleteSampleRequest extends ElevenLabsDeleteRequest<String> {
|
|
||||||
public DeleteSampleRequest(String voiceId, String sampleId) {
|
|
||||||
super(List.of(voiceId, sampleId), RequestTransformer.STRING_RESULT_TRANSFORMER);
|
|
||||||
responseType = (ResponseType.STRING);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getEndpoint() {
|
|
||||||
return "voices/{voiceId}/samples/{sampleId}";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
package net.andrewcpu.elevenlabs.api.requests.samples;
|
|
||||||
|
|
||||||
import net.andrewcpu.elevenlabs.api.requests.ElevenLabsGetRequest;
|
|
||||||
import net.andrewcpu.elevenlabs.api.transformers.FilePingPongTransformer;
|
|
||||||
import net.andrewcpu.elevenlabs.enums.ResponseType;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class GetAudioSampleRequest extends ElevenLabsGetRequest<File> {
|
|
||||||
public GetAudioSampleRequest(String voiceId, String sampleId, File outputFile) {
|
|
||||||
super(List.of(voiceId, sampleId), new FilePingPongTransformer(outputFile));
|
|
||||||
responseType = (ResponseType.FILE_STREAM);
|
|
||||||
outputFilePath = (outputFile);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getEndpoint() {
|
|
||||||
return "voices/{voiceId}/samples/{sampleId}/audio";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
package net.andrewcpu.elevenlabs.api.requests.user;
|
|
||||||
|
|
||||||
import net.andrewcpu.elevenlabs.api.requests.ElevenLabsGetRequest;
|
|
||||||
import net.andrewcpu.elevenlabs.api.transformers.RequestTransformer;
|
|
||||||
import net.andrewcpu.elevenlabs.elements.user.Subscription;
|
|
||||||
|
|
||||||
public class GetSubscriptionInfoRequest extends ElevenLabsGetRequest<Subscription> {
|
|
||||||
public GetSubscriptionInfoRequest() {
|
|
||||||
super(RequestTransformer.SUBSCRIPTION_TRANSFORMER);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getEndpoint() {
|
|
||||||
return "user/subscription";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
package net.andrewcpu.elevenlabs.api.requests.user;
|
|
||||||
|
|
||||||
import net.andrewcpu.elevenlabs.api.requests.ElevenLabsGetRequest;
|
|
||||||
import net.andrewcpu.elevenlabs.api.transformers.RequestTransformer;
|
|
||||||
import net.andrewcpu.elevenlabs.elements.user.User;
|
|
||||||
|
|
||||||
public class GetUserRequest extends ElevenLabsGetRequest<User> {
|
|
||||||
public GetUserRequest() {
|
|
||||||
super(RequestTransformer.USER_TRANSFORMER);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getEndpoint() {
|
|
||||||
return "user";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,55 +0,0 @@
|
|||||||
package net.andrewcpu.elevenlabs.api.requests.voices;
|
|
||||||
|
|
||||||
import net.andrewcpu.elevenlabs.api.multipart.MultipartFile;
|
|
||||||
import net.andrewcpu.elevenlabs.api.multipart.MultipartForm;
|
|
||||||
import net.andrewcpu.elevenlabs.api.multipart.MultipartFormContent;
|
|
||||||
import net.andrewcpu.elevenlabs.api.requests.ElevenLabsPostRequest;
|
|
||||||
import net.andrewcpu.elevenlabs.api.transformers.RequestTransformer;
|
|
||||||
import net.andrewcpu.elevenlabs.api.transformers.ResultTransformer;
|
|
||||||
import net.andrewcpu.elevenlabs.api.transformers.ResultTransformerAdapter;
|
|
||||||
import net.andrewcpu.elevenlabs.enums.ContentType;
|
|
||||||
import org.json.simple.JSONObject;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.net.URLEncoder;
|
|
||||||
import java.nio.charset.StandardCharsets;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public class CreateVoiceRequest extends ElevenLabsPostRequest<String> {
|
|
||||||
public CreateVoiceRequest(String name, List<File> files, Map<String, String> labels) {
|
|
||||||
super(RequestTransformer.VOICE_ID_TRANSFORMER);
|
|
||||||
buildBody(name, files, labels);
|
|
||||||
}
|
|
||||||
public CreateVoiceRequest(List<String> parameters, String name, List<File> files, Map<String, String> labels) {
|
|
||||||
super(parameters, RequestTransformer.VOICE_ID_TRANSFORMER);
|
|
||||||
buildBody(name, files, labels);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getEndpoint() {
|
|
||||||
return "voices/add";
|
|
||||||
}
|
|
||||||
|
|
||||||
private void buildBody(String name, List<File> files, Map<String, String> labels){
|
|
||||||
this.contentType = ContentType.MULTIPART;
|
|
||||||
this.multipartForm = new MultipartForm();
|
|
||||||
|
|
||||||
JSONObject val = new JSONObject();
|
|
||||||
if(labels != null && labels.size() != 0){
|
|
||||||
for(String key : labels.keySet()){
|
|
||||||
val.put(key, labels.get(key));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
MultipartFormContent nameMultipart = new MultipartFormContent("name", URLEncoder.encode(name, StandardCharsets.UTF_8));
|
|
||||||
MultipartFormContent labelsMultipart = new MultipartFormContent("labels", val.toJSONString());
|
|
||||||
this.multipartForm.push(nameMultipart, labelsMultipart);
|
|
||||||
|
|
||||||
for(File file : files){
|
|
||||||
this.multipartForm.push(new MultipartFile("files", file));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
package net.andrewcpu.elevenlabs.api.requests.voices;
|
|
||||||
|
|
||||||
import net.andrewcpu.elevenlabs.api.requests.ElevenLabsDeleteRequest;
|
|
||||||
import net.andrewcpu.elevenlabs.api.transformers.RequestTransformer;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class DeleteVoiceRequest extends ElevenLabsDeleteRequest<String> {
|
|
||||||
public DeleteVoiceRequest(String voiceId) {
|
|
||||||
super(List.of(voiceId), RequestTransformer.STRING_RESULT_TRANSFORMER);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getEndpoint() {
|
|
||||||
return "voices/{voiceId}";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
package net.andrewcpu.elevenlabs.api.requests.voices;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public class EditVoiceRequest extends CreateVoiceRequest{
|
|
||||||
public EditVoiceRequest(String voiceId, String name, List<File> files, Map<String, String> labels) {
|
|
||||||
super(List.of(voiceId), name, files, labels);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getEndpoint() {
|
|
||||||
return "voices/{voiceId}/edit";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
package net.andrewcpu.elevenlabs.api.requests.voices;
|
|
||||||
|
|
||||||
import net.andrewcpu.elevenlabs.api.ElevenLabsRequest;
|
|
||||||
import net.andrewcpu.elevenlabs.api.transformers.FilePingPongTransformer;
|
|
||||||
import net.andrewcpu.elevenlabs.elements.voice.Voice;
|
|
||||||
import net.andrewcpu.elevenlabs.elements.voice.VoiceSettings;
|
|
||||||
import net.andrewcpu.elevenlabs.enums.HTTPMethod;
|
|
||||||
import net.andrewcpu.elevenlabs.enums.ResponseType;
|
|
||||||
import org.json.simple.JSONObject;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public class GenerateTextToSpeechRequest extends ElevenLabsRequest<File> {
|
|
||||||
|
|
||||||
private static JSONObject buildBody(VoiceSettings settings, String text){
|
|
||||||
JSONObject object = new JSONObject();
|
|
||||||
object.put("text", text);
|
|
||||||
object.put("voice_settings", settings.toJSON());
|
|
||||||
return object;
|
|
||||||
}
|
|
||||||
public GenerateTextToSpeechRequest(Voice voice, VoiceSettings settings, String text, File outputFile){
|
|
||||||
super(List.of(voice.getVoiceId()), buildBody(settings, text), HTTPMethod.POST, new FilePingPongTransformer(outputFile));
|
|
||||||
responseType = (ResponseType.FILE_STREAM);
|
|
||||||
outputFilePath = (outputFile);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getEndpoint() {
|
|
||||||
return "text-to-speech/{voiceId}";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
package net.andrewcpu.elevenlabs.api.requests.voices;
|
|
||||||
|
|
||||||
import net.andrewcpu.elevenlabs.api.requests.ElevenLabsGetRequest;
|
|
||||||
import net.andrewcpu.elevenlabs.api.transformers.RequestTransformer;
|
|
||||||
import net.andrewcpu.elevenlabs.elements.voice.Voice;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class GetVoiceRequest extends ElevenLabsGetRequest<Voice> {
|
|
||||||
public GetVoiceRequest(String voiceId, boolean withSettings) {
|
|
||||||
super(List.of(voiceId, String.valueOf(withSettings)), RequestTransformer.VOICE_TRANSFORMER);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getEndpoint() {
|
|
||||||
return "voices/{voiceId}?with_settings={withSettings}";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
package net.andrewcpu.elevenlabs.api.requests.voices;
|
|
||||||
|
|
||||||
import net.andrewcpu.elevenlabs.api.requests.ElevenLabsGetRequest;
|
|
||||||
import net.andrewcpu.elevenlabs.api.transformers.RequestTransformer;
|
|
||||||
import net.andrewcpu.elevenlabs.elements.voice.Voice;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class GetVoicesRequest extends ElevenLabsGetRequest<List<Voice>> {
|
|
||||||
public GetVoicesRequest() {
|
|
||||||
super(RequestTransformer.VOICE_LIST_TRANSFORMER);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getEndpoint() {
|
|
||||||
return "voices";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
package net.andrewcpu.elevenlabs.api.requests.voices.settings;
|
|
||||||
|
|
||||||
import net.andrewcpu.elevenlabs.api.requests.ElevenLabsGetRequest;
|
|
||||||
import net.andrewcpu.elevenlabs.api.transformers.RequestTransformer;
|
|
||||||
import net.andrewcpu.elevenlabs.elements.voice.VoiceSettings;
|
|
||||||
|
|
||||||
public class GetDefaultVoiceSettingsRequest extends ElevenLabsGetRequest<VoiceSettings> {
|
|
||||||
public GetDefaultVoiceSettingsRequest() {
|
|
||||||
super(RequestTransformer.VOICE_SETTINGS_TRANSFORMER);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getEndpoint() {
|
|
||||||
return "voices/settings/default";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
package net.andrewcpu.elevenlabs.api.requests.voices.settings;
|
|
||||||
|
|
||||||
import net.andrewcpu.elevenlabs.api.requests.ElevenLabsGetRequest;
|
|
||||||
import net.andrewcpu.elevenlabs.api.transformers.RequestTransformer;
|
|
||||||
import net.andrewcpu.elevenlabs.elements.voice.VoiceSettings;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class GetVoiceSettingsRequest extends ElevenLabsGetRequest<VoiceSettings> {
|
|
||||||
public GetVoiceSettingsRequest(String voiceId) {
|
|
||||||
super(List.of(voiceId), RequestTransformer.VOICE_SETTINGS_TRANSFORMER);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getEndpoint() {
|
|
||||||
return "voices/{voiceId}/settings";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
package net.andrewcpu.elevenlabs.api.requests.voices.settings;
|
|
||||||
|
|
||||||
import net.andrewcpu.elevenlabs.api.requests.ElevenLabsPostRequest;
|
|
||||||
import net.andrewcpu.elevenlabs.api.transformers.RequestTransformer;
|
|
||||||
import net.andrewcpu.elevenlabs.elements.voice.VoiceSettings;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class UpdateVoiceSettingsRequest extends ElevenLabsPostRequest<String> {
|
|
||||||
public UpdateVoiceSettingsRequest(String voiceId, VoiceSettings settings){
|
|
||||||
super(List.of(voiceId), settings.toJSON(), RequestTransformer.STRING_RESULT_TRANSFORMER);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getEndpoint() {
|
|
||||||
return "voices/{voiceId}/settings/edit";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
package net.andrewcpu.elevenlabs.api.transformers;
|
|
||||||
|
|
||||||
import net.andrewcpu.elevenlabs.util.DebugLogger;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
|
|
||||||
public class FilePingPongTransformer extends ResultTransformerAdapter<File> {
|
|
||||||
private final File file;
|
|
||||||
|
|
||||||
public FilePingPongTransformer(File file) {
|
|
||||||
this.file = file;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public File transform() {
|
|
||||||
DebugLogger.log(getClass(), file.getAbsolutePath());
|
|
||||||
return file;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
package net.andrewcpu.elevenlabs.api.transformers;
|
|
||||||
|
|
||||||
import net.andrewcpu.elevenlabs.api.transformers.obj.*;
|
|
||||||
import net.andrewcpu.elevenlabs.elements.user.Subscription;
|
|
||||||
import net.andrewcpu.elevenlabs.elements.user.User;
|
|
||||||
import net.andrewcpu.elevenlabs.elements.voice.History;
|
|
||||||
import net.andrewcpu.elevenlabs.elements.voice.Voice;
|
|
||||||
import net.andrewcpu.elevenlabs.elements.voice.VoiceSettings;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class RequestTransformer {
|
|
||||||
public static final ResultTransformer<Voice> VOICE_TRANSFORMER = new VoiceTransformer();
|
|
||||||
public static final ResultTransformer<VoiceSettings> VOICE_SETTINGS_TRANSFORMER = new VoiceSettingTransformer();
|
|
||||||
public static final ResultTransformer<History> HISTORY_TRANSFORMER = new HistoryTransformer();
|
|
||||||
public static final ResultTransformer<User> USER_TRANSFORMER = new UserTransformer();
|
|
||||||
public static final ResultTransformer<Subscription> SUBSCRIPTION_TRANSFORMER = new SubscriptionTransformer();
|
|
||||||
public static final ResultTransformer<List<Voice>> VOICE_LIST_TRANSFORMER = new VoiceListTransformer();
|
|
||||||
public static final ResultTransformer<String> STRING_RESULT_TRANSFORMER = new StringPingPongTransformer();
|
|
||||||
public static final ResultTransformer<String> VOICE_ID_TRANSFORMER = new VoiceIDTransformer();
|
|
||||||
}
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
package net.andrewcpu.elevenlabs.api.transformers;
|
|
||||||
|
|
||||||
import org.json.simple.JSONObject;
|
|
||||||
|
|
||||||
public abstract class ResultTransformer<T> {
|
|
||||||
public abstract T transform(JSONObject object);
|
|
||||||
public abstract T transform(String object);
|
|
||||||
public abstract T transform();
|
|
||||||
}
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
package net.andrewcpu.elevenlabs.api.transformers;
|
|
||||||
|
|
||||||
import org.json.simple.JSONObject;
|
|
||||||
|
|
||||||
public class ResultTransformerAdapter<T> extends ResultTransformer<T> {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public T transform(JSONObject object) {
|
|
||||||
throw new UnsupportedOperationException("transform(JSONObject object) is not defined.");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public T transform(String object) {
|
|
||||||
throw new UnsupportedOperationException("transform(String object) is not defined.");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public T transform() {
|
|
||||||
throw new UnsupportedOperationException("transform() is not defined.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
package net.andrewcpu.elevenlabs.api.transformers;
|
|
||||||
|
|
||||||
import net.andrewcpu.elevenlabs.util.DebugLogger;
|
|
||||||
|
|
||||||
public class StringPingPongTransformer extends ResultTransformerAdapter<String> {
|
|
||||||
@Override
|
|
||||||
public String transform(String object) {
|
|
||||||
DebugLogger.log(getClass(),object);
|
|
||||||
return object;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
package net.andrewcpu.elevenlabs.api.transformers.obj;
|
|
||||||
|
|
||||||
import net.andrewcpu.elevenlabs.api.transformers.ResultTransformerAdapter;
|
|
||||||
import net.andrewcpu.elevenlabs.elements.voice.History;
|
|
||||||
import org.json.simple.JSONObject;
|
|
||||||
|
|
||||||
public class HistoryTransformer extends ResultTransformerAdapter<History> {
|
|
||||||
@Override
|
|
||||||
public History transform(JSONObject object) {
|
|
||||||
return History.fromJSON(object);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
package net.andrewcpu.elevenlabs.api.transformers.obj;
|
|
||||||
|
|
||||||
import net.andrewcpu.elevenlabs.api.transformers.ResultTransformerAdapter;
|
|
||||||
import net.andrewcpu.elevenlabs.elements.user.Subscription;
|
|
||||||
import org.json.simple.JSONObject;
|
|
||||||
|
|
||||||
public class SubscriptionTransformer extends ResultTransformerAdapter<Subscription> {
|
|
||||||
@Override
|
|
||||||
public Subscription transform(JSONObject object) {
|
|
||||||
return Subscription.fromJSON(object);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
package net.andrewcpu.elevenlabs.api.transformers.obj;
|
|
||||||
|
|
||||||
import net.andrewcpu.elevenlabs.api.transformers.ResultTransformerAdapter;
|
|
||||||
import net.andrewcpu.elevenlabs.elements.user.User;
|
|
||||||
import org.json.simple.JSONObject;
|
|
||||||
|
|
||||||
public class UserTransformer extends ResultTransformerAdapter<User> {
|
|
||||||
@Override
|
|
||||||
public User transform(JSONObject object) {
|
|
||||||
return User.fromJSON(object);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
package net.andrewcpu.elevenlabs.api.transformers.obj;
|
|
||||||
|
|
||||||
import net.andrewcpu.elevenlabs.api.transformers.ResultTransformerAdapter;
|
|
||||||
import org.json.simple.JSONObject;
|
|
||||||
|
|
||||||
public class VoiceIDTransformer extends ResultTransformerAdapter<String> {
|
|
||||||
@Override
|
|
||||||
public String transform(JSONObject object) {
|
|
||||||
return object.get("voice_id").toString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
package net.andrewcpu.elevenlabs.api.transformers.obj;
|
|
||||||
|
|
||||||
import net.andrewcpu.elevenlabs.api.transformers.ResultTransformerAdapter;
|
|
||||||
import net.andrewcpu.elevenlabs.elements.voice.Voice;
|
|
||||||
import org.json.simple.JSONArray;
|
|
||||||
import org.json.simple.JSONObject;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class VoiceListTransformer extends ResultTransformerAdapter<List<Voice>> {
|
|
||||||
@Override
|
|
||||||
public List<Voice> transform(JSONObject object) {
|
|
||||||
JSONArray voiceArray = (JSONArray) object.get("voices");
|
|
||||||
List<Voice> voices = new ArrayList<>();
|
|
||||||
|
|
||||||
for (Object o : voiceArray) {
|
|
||||||
JSONObject voiceJson = (JSONObject) o;
|
|
||||||
voices.add(Voice.fromJSON(voiceJson));
|
|
||||||
}
|
|
||||||
|
|
||||||
return voices;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
package net.andrewcpu.elevenlabs.api.transformers.obj;
|
|
||||||
|
|
||||||
import net.andrewcpu.elevenlabs.api.transformers.ResultTransformerAdapter;
|
|
||||||
import net.andrewcpu.elevenlabs.elements.voice.VoiceSettings;
|
|
||||||
import org.json.simple.JSONObject;
|
|
||||||
|
|
||||||
public class VoiceSettingTransformer extends ResultTransformerAdapter<VoiceSettings> {
|
|
||||||
@Override
|
|
||||||
public VoiceSettings transform(JSONObject object) {
|
|
||||||
return VoiceSettings.fromJSON(object);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
package net.andrewcpu.elevenlabs.api.transformers.obj;
|
|
||||||
|
|
||||||
import net.andrewcpu.elevenlabs.api.transformers.ResultTransformerAdapter;
|
|
||||||
import net.andrewcpu.elevenlabs.elements.voice.Voice;
|
|
||||||
import org.json.simple.JSONObject;
|
|
||||||
|
|
||||||
public class VoiceTransformer extends ResultTransformerAdapter<Voice> {
|
|
||||||
@Override
|
|
||||||
public Voice transform(JSONObject object) {
|
|
||||||
return Voice.fromJSON(object);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,79 +0,0 @@
|
|||||||
package net.andrewcpu.elevenlabs.elements;
|
|
||||||
|
|
||||||
import net.andrewcpu.elevenlabs.ElevenLabsAPI;
|
|
||||||
import net.andrewcpu.elevenlabs.elements.voice.Voice;
|
|
||||||
import net.andrewcpu.elevenlabs.exceptions.ElevenLabsException;
|
|
||||||
import net.andrewcpu.elevenlabs.exceptions.ElevenLabsValidationException;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
@SuppressWarnings("UnusedReturnValue")
|
|
||||||
public class VoiceBuilder {
|
|
||||||
private String name = null;
|
|
||||||
private final Map<String, String> labels;
|
|
||||||
private final List<File> files;
|
|
||||||
private String voiceId;
|
|
||||||
|
|
||||||
public static VoiceBuilder fromVoice(Voice voice){
|
|
||||||
VoiceBuilder voiceBuilder = new VoiceBuilder();
|
|
||||||
voiceBuilder.withName(voice.getName());
|
|
||||||
voiceBuilder.withVoiceID(voice.getVoiceId());
|
|
||||||
for(String key : voice.getLabels().keySet()){
|
|
||||||
voiceBuilder.withLabel(key, voice.getLabels().get(key));
|
|
||||||
}
|
|
||||||
return voiceBuilder;
|
|
||||||
}
|
|
||||||
|
|
||||||
public VoiceBuilder() {
|
|
||||||
labels = new HashMap<>();
|
|
||||||
files = new ArrayList<>();
|
|
||||||
voiceId = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public VoiceBuilder withName(String name){
|
|
||||||
this.name = name;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public VoiceBuilder withFile(File file){
|
|
||||||
files.add(file);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public VoiceBuilder withLabel(String key, String value){
|
|
||||||
labels.put(key, value);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public VoiceBuilder removeLabel(String key){
|
|
||||||
labels.remove(key);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public VoiceBuilder removeFile(File file){
|
|
||||||
files.remove(file);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public VoiceBuilder withVoiceID(String id){
|
|
||||||
this.voiceId = id;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Voice edit() throws ElevenLabsException {
|
|
||||||
ElevenLabsAPI.getInstance().editVoice(voiceId, name, labels, files);
|
|
||||||
return ElevenLabsAPI.getInstance().getVoice(voiceId, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Voice create() throws ElevenLabsException {
|
|
||||||
if(files.isEmpty()){
|
|
||||||
throw new ElevenLabsValidationException("Cannot build a voice without any files.");
|
|
||||||
}
|
|
||||||
String voiceId = ElevenLabsAPI.getInstance().createVoice(name, labels, files);
|
|
||||||
return ElevenLabsAPI.getInstance().getVoice(voiceId, true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,190 +0,0 @@
|
|||||||
package net.andrewcpu.elevenlabs.elements.user;
|
|
||||||
|
|
||||||
import net.andrewcpu.elevenlabs.ElevenLabsAPI;
|
|
||||||
import net.andrewcpu.elevenlabs.enums.Status;
|
|
||||||
import net.andrewcpu.elevenlabs.exceptions.ElevenLabsException;
|
|
||||||
import org.json.simple.JSONArray;
|
|
||||||
import org.json.simple.JSONObject;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class Subscription {
|
|
||||||
private final String tier;
|
|
||||||
private final int characterCount;
|
|
||||||
private final int characterLimit;
|
|
||||||
private final boolean canExtendCharacterLimit;
|
|
||||||
private final boolean allowedToExtendCharacterLimit;
|
|
||||||
private final long nextCharacterCountResetUnix;
|
|
||||||
private final int voiceLimit;
|
|
||||||
private final boolean canExtendVoiceLimit;
|
|
||||||
private final boolean canUseInstantVoiceCloning;
|
|
||||||
private final List<AvailableModel> availableModels;
|
|
||||||
private final Status status;
|
|
||||||
private final NextInvoice nextInvoice;
|
|
||||||
|
|
||||||
public static Subscription fromJSON(JSONObject object) {
|
|
||||||
String tier = (String) object.get("tier");
|
|
||||||
int characterCount = ((Long) object.get("character_count")).intValue();
|
|
||||||
int characterLimit = ((Long) object.get("character_limit")).intValue();
|
|
||||||
boolean canExtendCharacterLimit = (Boolean) object.get("can_extend_character_limit");
|
|
||||||
boolean allowedToExtendCharacterLimit = (Boolean) object.get("allowed_to_extend_character_limit");
|
|
||||||
long nextCharacterCountResetUnix = (Long) object.get("next_character_count_reset_unix");
|
|
||||||
int voiceLimit = ((Long) object.get("voice_limit")).intValue();
|
|
||||||
boolean canExtendVoiceLimit = (Boolean) object.get("can_extend_voice_limit");
|
|
||||||
boolean canUseInstantVoiceCloning = (Boolean) object.get("can_use_instant_voice_cloning");
|
|
||||||
List<AvailableModel> availableModels = new ArrayList<>();
|
|
||||||
JSONArray availableModelsJson = (JSONArray) object.get("available_models");
|
|
||||||
for (Object model : availableModelsJson) {
|
|
||||||
JSONObject modelJson = (JSONObject) model;
|
|
||||||
String modelId = (String) modelJson.get("model_id");
|
|
||||||
String displayName = (String) modelJson.get("display_name");
|
|
||||||
List<SupportedLanguage> supportedLanguages = new ArrayList<>();
|
|
||||||
JSONArray supportedLanguagesJson = (JSONArray) modelJson.get("supported_languages");
|
|
||||||
for (Object language : supportedLanguagesJson) {
|
|
||||||
JSONObject languageJson = (JSONObject) language;
|
|
||||||
String isoCode = (String) languageJson.get("iso_code");
|
|
||||||
String languageDisplayName = (String) languageJson.get("display_name");
|
|
||||||
supportedLanguages.add(new SupportedLanguage(isoCode, languageDisplayName));
|
|
||||||
}
|
|
||||||
availableModels.add(new AvailableModel(modelId, displayName, supportedLanguages));
|
|
||||||
}
|
|
||||||
String status = (String) object.get("status");
|
|
||||||
NextInvoice invoice = null;
|
|
||||||
if(object.containsKey("next_invoice")){
|
|
||||||
JSONObject nextInvoiceJson = (JSONObject) object.get("next_invoice");
|
|
||||||
invoice = new NextInvoice(
|
|
||||||
((Long) nextInvoiceJson.get("amount_due_cents")).intValue(),
|
|
||||||
(Long) nextInvoiceJson.get("next_payment_attempt_unix")
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return new Subscription(tier, characterCount, characterLimit, canExtendCharacterLimit, allowedToExtendCharacterLimit, nextCharacterCountResetUnix, voiceLimit, canExtendVoiceLimit, canUseInstantVoiceCloning, availableModels, status, invoice);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static Subscription get() throws ElevenLabsException {
|
|
||||||
return ElevenLabsAPI.getInstance().getSubscription();
|
|
||||||
}
|
|
||||||
|
|
||||||
private Subscription(String tier, int characterCount, int characterLimit, boolean canExtendCharacterLimit, boolean allowedToExtendCharacterLimit,
|
|
||||||
long nextCharacterCountResetUnix, int voiceLimit, boolean canExtendVoiceLimit, boolean canUseInstantVoiceCloning, List<AvailableModel> availableModels,
|
|
||||||
String status, NextInvoice nextInvoice) {
|
|
||||||
this.tier = tier;
|
|
||||||
this.characterCount = characterCount;
|
|
||||||
this.characterLimit = characterLimit;
|
|
||||||
this.canExtendCharacterLimit = canExtendCharacterLimit;
|
|
||||||
this.allowedToExtendCharacterLimit = allowedToExtendCharacterLimit;
|
|
||||||
this.nextCharacterCountResetUnix = nextCharacterCountResetUnix;
|
|
||||||
this.voiceLimit = voiceLimit;
|
|
||||||
this.canExtendVoiceLimit = canExtendVoiceLimit;
|
|
||||||
this.canUseInstantVoiceCloning = canUseInstantVoiceCloning;
|
|
||||||
this.availableModels = availableModels;
|
|
||||||
this.status = Status.valueOf(status.toUpperCase());
|
|
||||||
this.nextInvoice = nextInvoice;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getTier() {
|
|
||||||
return tier;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getCharacterCount() {
|
|
||||||
return characterCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getCharacterLimit() {
|
|
||||||
return characterLimit;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isCanExtendCharacterLimit() {
|
|
||||||
return canExtendCharacterLimit;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isAllowedToExtendCharacterLimit() {
|
|
||||||
return allowedToExtendCharacterLimit;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getNextCharacterCountResetUnix() {
|
|
||||||
return nextCharacterCountResetUnix;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getVoiceLimit() {
|
|
||||||
return voiceLimit;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isCanExtendVoiceLimit() {
|
|
||||||
return canExtendVoiceLimit;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isCanUseInstantVoiceCloning() {
|
|
||||||
return canUseInstantVoiceCloning;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<AvailableModel> getAvailableModels() {
|
|
||||||
return availableModels;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Status getStatus() {
|
|
||||||
return status;
|
|
||||||
}
|
|
||||||
|
|
||||||
public NextInvoice getNextInvoice() {
|
|
||||||
return nextInvoice;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "Subscription{" +
|
|
||||||
"tier='" + tier + '\'' +
|
|
||||||
", characterCount=" + characterCount +
|
|
||||||
", characterLimit=" + characterLimit +
|
|
||||||
", canExtendCharacterLimit=" + canExtendCharacterLimit +
|
|
||||||
", allowedToExtendCharacterLimit=" + allowedToExtendCharacterLimit +
|
|
||||||
", nextCharacterCountResetUnix=" + nextCharacterCountResetUnix +
|
|
||||||
", voiceLimit=" + voiceLimit +
|
|
||||||
", canExtendVoiceLimit=" + canExtendVoiceLimit +
|
|
||||||
", canUseInstantVoiceCloning=" + canUseInstantVoiceCloning +
|
|
||||||
", availableModels=" + availableModels +
|
|
||||||
", status='" + status + '\'' +
|
|
||||||
", nextInvoice=" + nextInvoice +
|
|
||||||
'}';
|
|
||||||
}
|
|
||||||
|
|
||||||
public record AvailableModel(String modelId, String displayName, List<SupportedLanguage> supportedLanguages) {
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "AvailableModel{" +
|
|
||||||
"modelId='" + modelId + '\'' +
|
|
||||||
", displayName='" + displayName + '\'' +
|
|
||||||
", supportedLanguages=" + supportedLanguages +
|
|
||||||
'}';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public record SupportedLanguage(String isoCode, String displayName) {
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "SupportedLanguage{" +
|
|
||||||
"isoCode='" + isoCode + '\'' +
|
|
||||||
", displayName='" + displayName + '\'' +
|
|
||||||
'}';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public record NextInvoice(int amountDueCents, long nextPaymentAttemptUnix) {
|
|
||||||
public Date getNextPaymentAttempt() {
|
|
||||||
return new Date(nextPaymentAttemptUnix);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "NextInvoice{" +
|
|
||||||
"amountDueCents=" + amountDueCents +
|
|
||||||
", nextPaymentAttemptUnix=" + nextPaymentAttemptUnix +
|
|
||||||
'}';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,56 +0,0 @@
|
|||||||
package net.andrewcpu.elevenlabs.elements.user;
|
|
||||||
|
|
||||||
import net.andrewcpu.elevenlabs.ElevenLabsAPI;
|
|
||||||
import net.andrewcpu.elevenlabs.elements.voice.History;
|
|
||||||
import net.andrewcpu.elevenlabs.exceptions.ElevenLabsException;
|
|
||||||
import org.json.simple.JSONObject;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
public class User {
|
|
||||||
private final Subscription subscription;
|
|
||||||
private final boolean isNewUser;
|
|
||||||
private final String apiKey;
|
|
||||||
|
|
||||||
public static User get() throws ElevenLabsException, IOException {
|
|
||||||
return ElevenLabsAPI.getInstance().getUser();
|
|
||||||
}
|
|
||||||
|
|
||||||
public User(Subscription subscription, boolean isNewUser, String xiApiKey) {
|
|
||||||
this.subscription = subscription;
|
|
||||||
this.isNewUser = isNewUser;
|
|
||||||
this.apiKey = xiApiKey;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Subscription getSubscription() {
|
|
||||||
return subscription;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isNewUser() {
|
|
||||||
return isNewUser;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getAPIKey() {
|
|
||||||
return apiKey;
|
|
||||||
}
|
|
||||||
|
|
||||||
public History getHistory() throws IOException, ElevenLabsException {
|
|
||||||
return ElevenLabsAPI.getInstance().getHistory();
|
|
||||||
}
|
|
||||||
public static User fromJSON(JSONObject object) {
|
|
||||||
JSONObject subscriptionJson = (JSONObject) object.get("subscription");
|
|
||||||
Subscription subscription = Subscription.fromJSON(subscriptionJson);
|
|
||||||
boolean isNewUser = (boolean) object.get("is_new_user");
|
|
||||||
String xiApiKey = (String) object.get("xi_api_key");
|
|
||||||
return new User(subscription, isNewUser, xiApiKey);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "User{" +
|
|
||||||
"subscription=" + subscription +
|
|
||||||
", isNewUser=" + isNewUser +
|
|
||||||
", apiKey='" + apiKey + '\'' +
|
|
||||||
'}';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,172 +0,0 @@
|
|||||||
package net.andrewcpu.elevenlabs.elements.voice;
|
|
||||||
|
|
||||||
import net.andrewcpu.elevenlabs.ElevenLabsAPI;
|
|
||||||
import net.andrewcpu.elevenlabs.enums.State;
|
|
||||||
import net.andrewcpu.elevenlabs.exceptions.ElevenLabsException;
|
|
||||||
import org.json.simple.JSONArray;
|
|
||||||
import org.json.simple.JSONObject;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
public record History(List<HistoryItem> history) {
|
|
||||||
public static History fromJSON(JSONObject object) {
|
|
||||||
List<HistoryItem> historyItems = new ArrayList<>();
|
|
||||||
JSONArray historyArray = (JSONArray) object.get("history");
|
|
||||||
History history = new History(new ArrayList<>());
|
|
||||||
for (Object item : historyArray) {
|
|
||||||
JSONObject itemJson = (JSONObject) item;
|
|
||||||
String historyItemId = (String) itemJson.get("history_item_id");
|
|
||||||
String voiceId = (String) itemJson.get("voice_id");
|
|
||||||
String voiceName = (String) itemJson.get("voice_name");
|
|
||||||
String text = (String) itemJson.get("text");
|
|
||||||
long dateUnix = (Long) itemJson.get("date_unix");
|
|
||||||
int characterCountChangeFrom = ((Long) itemJson.get("character_count_change_from")).intValue();
|
|
||||||
int characterCountChangeTo = ((Long) itemJson.get("character_count_change_to")).intValue();
|
|
||||||
String contentType = (String) itemJson.get("content_type");
|
|
||||||
String state = (String) itemJson.get("state");
|
|
||||||
HistoryItem historyItem = new HistoryItem(historyItemId, voiceId, voiceName, text, dateUnix, characterCountChangeFrom, characterCountChangeTo, contentType, state, history);
|
|
||||||
historyItems.add(historyItem);
|
|
||||||
}
|
|
||||||
history.history.addAll(historyItems);
|
|
||||||
return history;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static History get() throws ElevenLabsException {
|
|
||||||
return ElevenLabsAPI.getInstance().getHistory();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public HistoryItem getHistoryItem(String id) {
|
|
||||||
for (HistoryItem item : history) {
|
|
||||||
if (item.getHistoryItemId().equals(id)) {
|
|
||||||
return item;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public File downloadHistory(String[] ids, File file) throws ElevenLabsException {
|
|
||||||
return ElevenLabsAPI.getInstance().downloadHistory(Arrays.stream(ids).toList(), file);
|
|
||||||
}
|
|
||||||
|
|
||||||
public File downloadHistory(List<HistoryItem> historyItems, File file) throws ElevenLabsException {
|
|
||||||
return ElevenLabsAPI.getInstance().downloadHistory(historyItems.stream().map(HistoryItem::getHistoryItemId).collect(Collectors.toList()), file);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "History{" +
|
|
||||||
"history=" + history +
|
|
||||||
'}';
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class HistoryItem {
|
|
||||||
private final String historyItemId;
|
|
||||||
private final String voiceId;
|
|
||||||
private final String voiceName;
|
|
||||||
private final String text;
|
|
||||||
private final long dateUnix;
|
|
||||||
private final int characterCountChangeFrom;
|
|
||||||
private final int characterCountChangeTo;
|
|
||||||
private final String contentType;
|
|
||||||
private final State state;
|
|
||||||
private Voice voice;
|
|
||||||
private final History history;
|
|
||||||
|
|
||||||
HistoryItem(String historyItemId, String voiceId, String voiceName, String text, long dateUnix, int characterCountChangeFrom, int characterCountChangeTo, String contentType, String state, History history) {
|
|
||||||
this.historyItemId = historyItemId;
|
|
||||||
this.voiceId = voiceId;
|
|
||||||
this.voiceName = voiceName;
|
|
||||||
this.text = text;
|
|
||||||
this.dateUnix = dateUnix;
|
|
||||||
this.characterCountChangeFrom = characterCountChangeFrom;
|
|
||||||
this.characterCountChangeTo = characterCountChangeTo;
|
|
||||||
this.contentType = contentType;
|
|
||||||
this.state = State.valueOf(state.toUpperCase());
|
|
||||||
this.history = history;
|
|
||||||
this.voice = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Voice getVoice() {
|
|
||||||
if (voice == null) {
|
|
||||||
try {
|
|
||||||
voice = ElevenLabsAPI.getInstance().getVoice(voiceId);
|
|
||||||
} catch (ElevenLabsException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return voice;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getHistoryItemId() {
|
|
||||||
return historyItemId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getVoiceId() {
|
|
||||||
return voiceId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getVoiceName() {
|
|
||||||
return voiceName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getText() {
|
|
||||||
return text;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getDateUnix() {
|
|
||||||
return dateUnix;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Date getDate() {
|
|
||||||
return new Date(dateUnix);
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getCharacterCountChangeFrom() {
|
|
||||||
return characterCountChangeFrom;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getCharacterCountChangeTo() {
|
|
||||||
return characterCountChangeTo;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getContentType() {
|
|
||||||
return contentType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public State getState() {
|
|
||||||
return state;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String delete() throws ElevenLabsException {
|
|
||||||
String output = ElevenLabsAPI.getInstance().deleteHistoryItem(this);
|
|
||||||
history.history.remove(this);
|
|
||||||
return output;
|
|
||||||
}
|
|
||||||
|
|
||||||
public File downloadAudio(File outputFile) throws ElevenLabsException {
|
|
||||||
return ElevenLabsAPI.getInstance().getHistoryItemAudio(this, outputFile);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "HistoryItem{" +
|
|
||||||
"historyItemId='" + historyItemId + '\'' +
|
|
||||||
", voiceId='" + voiceId + '\'' +
|
|
||||||
", voiceName='" + voiceName + '\'' +
|
|
||||||
", text='" + text + '\'' +
|
|
||||||
", dateUnix=" + dateUnix +
|
|
||||||
", characterCountChangeFrom=" + characterCountChangeFrom +
|
|
||||||
", characterCountChangeTo=" + characterCountChangeTo +
|
|
||||||
", contentType='" + contentType + '\'' +
|
|
||||||
", state='" + state + '\'' +
|
|
||||||
", voice=" + voice +
|
|
||||||
'}';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,84 +0,0 @@
|
|||||||
package net.andrewcpu.elevenlabs.elements.voice;
|
|
||||||
|
|
||||||
import net.andrewcpu.elevenlabs.ElevenLabsAPI;
|
|
||||||
import net.andrewcpu.elevenlabs.exceptions.ElevenLabsException;
|
|
||||||
import org.json.simple.JSONObject;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
|
|
||||||
public class Sample {
|
|
||||||
private final String sampleId;
|
|
||||||
private final String fileName;
|
|
||||||
private final String mimeType;
|
|
||||||
private final long sizeBytes;
|
|
||||||
private final String hash;
|
|
||||||
private Voice voice;
|
|
||||||
|
|
||||||
static Sample fromJSON(JSONObject object) {
|
|
||||||
String sampleId = (String) object.get("sample_id");
|
|
||||||
String fileName = (String) object.get("file_name");
|
|
||||||
String mimeType = (String) object.get("mime_type");
|
|
||||||
int sizeBytes = ((Long) object.get("size_bytes")).intValue();
|
|
||||||
String hash = (String) object.get("hash");
|
|
||||||
|
|
||||||
return new Sample(sampleId, fileName, mimeType, sizeBytes, hash);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private Sample(String sampleId, String fileName, String mimeType, long sizeBytes, String hash) {
|
|
||||||
this.sampleId = sampleId;
|
|
||||||
this.fileName = fileName;
|
|
||||||
this.mimeType = mimeType;
|
|
||||||
this.sizeBytes = sizeBytes;
|
|
||||||
this.hash = hash;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Voice getVoice() {
|
|
||||||
return voice;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setVoice(Voice voice) {
|
|
||||||
this.voice = voice;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getSampleId() {
|
|
||||||
return sampleId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getFileName() {
|
|
||||||
return fileName;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public String getMimeType() {
|
|
||||||
return mimeType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getSizeBytes() {
|
|
||||||
return sizeBytes;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getHash() {
|
|
||||||
return hash;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String delete() throws ElevenLabsException {
|
|
||||||
return ElevenLabsAPI.getInstance().deleteSample(voice,this);
|
|
||||||
}
|
|
||||||
|
|
||||||
public File downloadAudio(File outputFile) throws ElevenLabsException {
|
|
||||||
return ElevenLabsAPI.getInstance().getSampleAudio(voice, this, outputFile);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "Sample{" +
|
|
||||||
"sampleId='" + sampleId + '\'' +
|
|
||||||
", fileName='" + fileName + '\'' +
|
|
||||||
", mimeType='" + mimeType + '\'' +
|
|
||||||
", sizeBytes=" + sizeBytes +
|
|
||||||
", hash='" + hash + '\'' +
|
|
||||||
", voice=" + voice +
|
|
||||||
'}';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,179 +0,0 @@
|
|||||||
package net.andrewcpu.elevenlabs.elements.voice;
|
|
||||||
|
|
||||||
import net.andrewcpu.elevenlabs.ElevenLabsAPI;
|
|
||||||
import net.andrewcpu.elevenlabs.elements.VoiceBuilder;
|
|
||||||
import net.andrewcpu.elevenlabs.exceptions.ElevenLabsException;
|
|
||||||
import net.andrewcpu.elevenlabs.exceptions.ElevenLabsValidationException;
|
|
||||||
import org.json.simple.JSONArray;
|
|
||||||
import org.json.simple.JSONObject;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public class Voice {
|
|
||||||
private final String voiceId;
|
|
||||||
private final String name;
|
|
||||||
private final List<Sample> samples;
|
|
||||||
private final String category;
|
|
||||||
private final Map<String, String> labels;
|
|
||||||
private final String previewUrl;
|
|
||||||
private final List<String> availableForTiers;
|
|
||||||
private VoiceSettings voiceSettings;
|
|
||||||
private boolean hasSettings;
|
|
||||||
|
|
||||||
|
|
||||||
public static Voice fromJSON(JSONObject object) {
|
|
||||||
String voiceId = (String) object.get("voice_id");
|
|
||||||
String name = (String) object.get("name");
|
|
||||||
List<Sample> samples = new ArrayList<>();
|
|
||||||
if(object.containsKey("samples") && object.get("samples") != null){
|
|
||||||
JSONArray samplesJson = (JSONArray) object.get("samples");
|
|
||||||
for (Object sampleObj : samplesJson) {
|
|
||||||
JSONObject sampleJson = (JSONObject) sampleObj;
|
|
||||||
samples.add(Sample.fromJSON(sampleJson));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
String category = (String) object.get("category");
|
|
||||||
JSONObject labelsJson = (JSONObject) object.get("labels");
|
|
||||||
Map<String, String> labels = new HashMap<>();
|
|
||||||
for (Object key : labelsJson.keySet()) {
|
|
||||||
String labelName = (String) key;
|
|
||||||
String labelValue = (String) labelsJson.get(labelName);
|
|
||||||
labels.put(labelName, labelValue);
|
|
||||||
}
|
|
||||||
String previewUrl = (String) object.get("preview_url");
|
|
||||||
JSONArray availableForTiersJson = (JSONArray) object.get("available_for_tiers");
|
|
||||||
List<String> availableForTiers = new ArrayList<>();
|
|
||||||
for (Object tier : availableForTiersJson) {
|
|
||||||
availableForTiers.add((String) tier);
|
|
||||||
}
|
|
||||||
double stab = -1;
|
|
||||||
double sim = -1;
|
|
||||||
if(object.containsKey("settings") && object.get("settings") != null){
|
|
||||||
JSONObject settingsJson = (JSONObject) object.get("settings");
|
|
||||||
VoiceSettings settings = new VoiceSettings(((Double) settingsJson.get("stability")),
|
|
||||||
((Double) settingsJson.get("similarity_boost")));
|
|
||||||
stab = settings.getStability();
|
|
||||||
sim = settings.getSimilarityBoost();
|
|
||||||
}
|
|
||||||
|
|
||||||
Voice voice = new Voice(voiceId, name, samples, category, labels, previewUrl, availableForTiers, stab, sim);
|
|
||||||
voice.hasSettings = stab != -1;
|
|
||||||
voice.getSamples().forEach(s -> s.setVoice(voice));
|
|
||||||
return voice;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static List<Voice> getVoices() throws ElevenLabsException {
|
|
||||||
return ElevenLabsAPI.getInstance().getVoices();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Voice get(String voiceId) throws ElevenLabsException {
|
|
||||||
Voice voice = ElevenLabsAPI.getInstance().getVoice(voiceId);
|
|
||||||
voice.hasSettings = true;
|
|
||||||
return voice;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Voice get(String voiceId, boolean withSettings) throws ElevenLabsException {
|
|
||||||
Voice voice = ElevenLabsAPI.getInstance().getVoice(voiceId, withSettings);
|
|
||||||
voice.hasSettings = withSettings;
|
|
||||||
return voice;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private Voice(String voiceId, String name, List<Sample> samples, String category, Map<String, String> labels, String previewUrl, List<String> availableForTiers, double stability, double similarityBoost) {
|
|
||||||
this.voiceId = voiceId;
|
|
||||||
this.name = name;
|
|
||||||
this.samples = samples;
|
|
||||||
this.category = category;
|
|
||||||
this.labels = labels;
|
|
||||||
this.previewUrl = previewUrl;
|
|
||||||
this.availableForTiers = availableForTiers;
|
|
||||||
this.voiceSettings = new VoiceSettings(stability, similarityBoost);
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getVoiceId() {
|
|
||||||
return voiceId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getName() {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<Sample> getSamples() {
|
|
||||||
return samples;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getCategory() {
|
|
||||||
return category;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Map<String, String> getLabels() {
|
|
||||||
return labels;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getPreviewUrl() {
|
|
||||||
return previewUrl;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<String> getAvailableForTiers() {
|
|
||||||
return availableForTiers;
|
|
||||||
}
|
|
||||||
|
|
||||||
public VoiceSettings getVoiceSettings() {
|
|
||||||
return voiceSettings;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String delete() throws IOException, ElevenLabsException {
|
|
||||||
return ElevenLabsAPI.getInstance().deleteVoice(getVoiceId());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void fetchSettings() throws IOException, ElevenLabsException {
|
|
||||||
this.voiceSettings = ElevenLabsAPI.getInstance().getVoiceSettings(getVoiceId());
|
|
||||||
hasSettings = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public VoiceBuilder builder() {
|
|
||||||
return VoiceBuilder.fromVoice(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
public String updateVoiceSettings(VoiceSettings settings) throws ElevenLabsException {
|
|
||||||
String response = ElevenLabsAPI.getInstance().editVoice(this, settings);
|
|
||||||
if(response != null){
|
|
||||||
this.voiceSettings = settings;
|
|
||||||
hasSettings = true;
|
|
||||||
return response;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}//todo figure out what this endpoint returns. String is not description, but docs don't have the info
|
|
||||||
|
|
||||||
public File generate(String text, VoiceSettings voiceSettings, File output) throws ElevenLabsException {
|
|
||||||
return ElevenLabsAPI.getInstance().getTextToSpeech(text, this, voiceSettings,output);
|
|
||||||
}
|
|
||||||
|
|
||||||
public File generate(String text, File output) throws ElevenLabsException, IOException {
|
|
||||||
if(!hasSettings){
|
|
||||||
throw new ElevenLabsValidationException("Cannot use default voice settings for " + voiceId + " because this object does not have VoiceSettings");
|
|
||||||
}
|
|
||||||
return generate(text, voiceSettings, output);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "Voice{" +
|
|
||||||
"voiceId='" + voiceId + '\'' +
|
|
||||||
", name='" + name + '\'' +
|
|
||||||
", samples=" + samples +
|
|
||||||
", category='" + category + '\'' +
|
|
||||||
", labels=" + labels +
|
|
||||||
", previewUrl='" + previewUrl + '\'' +
|
|
||||||
", availableForTiers=" + availableForTiers +
|
|
||||||
", voiceSettings=" + voiceSettings +
|
|
||||||
'}';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,55 +0,0 @@
|
|||||||
package net.andrewcpu.elevenlabs.elements.voice;
|
|
||||||
|
|
||||||
import net.andrewcpu.elevenlabs.ElevenLabsAPI;
|
|
||||||
import net.andrewcpu.elevenlabs.exceptions.ElevenLabsException;
|
|
||||||
import org.json.simple.JSONObject;
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public class VoiceSettings {
|
|
||||||
private double stability;
|
|
||||||
private double similarityBoost;
|
|
||||||
|
|
||||||
public static VoiceSettings fromJSON(JSONObject object){
|
|
||||||
return new VoiceSettings((double)object.get("stability"), (double)object.get("similarity"));
|
|
||||||
}
|
|
||||||
public static VoiceSettings getDefaultVoiceSettings() throws ElevenLabsException {
|
|
||||||
return ElevenLabsAPI.getInstance().getDefaultVoiceSettings();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public VoiceSettings(double stability, double similarityBoost) {
|
|
||||||
this.stability = stability;
|
|
||||||
this.similarityBoost = similarityBoost;
|
|
||||||
}
|
|
||||||
|
|
||||||
public double getStability() {
|
|
||||||
return stability;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setStability(double stability) {
|
|
||||||
this.stability = stability;
|
|
||||||
}
|
|
||||||
|
|
||||||
public double getSimilarityBoost() {
|
|
||||||
return similarityBoost;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSimilarityBoost(double similarityBoost) {
|
|
||||||
this.similarityBoost = similarityBoost;
|
|
||||||
}
|
|
||||||
|
|
||||||
public JSONObject toJSON() {
|
|
||||||
JSONObject object = new JSONObject();
|
|
||||||
object.put("stability", stability);
|
|
||||||
object.put("similarity_boost", similarityBoost);
|
|
||||||
return object;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "VoiceSettings{" +
|
|
||||||
"stability=" + stability +
|
|
||||||
", similarityBoost=" + similarityBoost +
|
|
||||||
'}';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
package net.andrewcpu.elevenlabs.enums;
|
|
||||||
|
|
||||||
public enum ContentType {
|
|
||||||
JSON("application/json"), MULTIPART("multipart/form-data");
|
|
||||||
private final String type;
|
|
||||||
|
|
||||||
ContentType(String type) {
|
|
||||||
this.type = type;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getType() {
|
|
||||||
return type;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
package net.andrewcpu.elevenlabs.enums;
|
||||||
|
|
||||||
|
public enum GeneratedAudioOutputFormat {
|
||||||
|
MP3_44100_64,
|
||||||
|
MP3_44100_96,
|
||||||
|
MP3_44100_128,
|
||||||
|
MP3_44100_192,
|
||||||
|
PCM_16000,
|
||||||
|
PCM_22050,
|
||||||
|
PCM_24000,
|
||||||
|
PCM_44100,
|
||||||
|
ULAW_8000;
|
||||||
|
|
||||||
|
|
||||||
|
// Method to get the default value
|
||||||
|
public static GeneratedAudioOutputFormat getDefault() {
|
||||||
|
return MP3_44100_128;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
package net.andrewcpu.elevenlabs.enums;
|
|
||||||
|
|
||||||
public enum HTTPMethod {
|
|
||||||
POST,
|
|
||||||
GET,
|
|
||||||
PUT,
|
|
||||||
DELETE
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
package net.andrewcpu.elevenlabs.enums;
|
||||||
|
|
||||||
|
public enum HttpRequestType {
|
||||||
|
POST, GET, PUT, DELETE
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
package net.andrewcpu.elevenlabs.enums;
|
||||||
|
|
||||||
|
public enum ProjectOutputQuality {
|
||||||
|
STANDARD,
|
||||||
|
HIGH,
|
||||||
|
ULTRA;
|
||||||
|
|
||||||
|
public static ProjectOutputQuality getDefault() {
|
||||||
|
return STANDARD;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
package net.andrewcpu.elevenlabs.enums;
|
|
||||||
|
|
||||||
public enum ResponseType {
|
|
||||||
JSON,
|
|
||||||
FILE_STREAM,
|
|
||||||
STRING
|
|
||||||
}
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
package net.andrewcpu.elevenlabs.enums;
|
|
||||||
|
|
||||||
public enum State {
|
|
||||||
CREATED,
|
|
||||||
DELETED,
|
|
||||||
PROCESSING
|
|
||||||
}
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
package net.andrewcpu.elevenlabs.enums;
|
|
||||||
|
|
||||||
public enum Status {
|
|
||||||
TRIALING,
|
|
||||||
ACTIVE,
|
|
||||||
INCOMPLETE,
|
|
||||||
INCOMPLETE_EXPIRED,
|
|
||||||
PAST_DUE,
|
|
||||||
CANCELED,
|
|
||||||
UNPAID,
|
|
||||||
FREE
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
package net.andrewcpu.elevenlabs.enums;
|
||||||
|
|
||||||
|
public enum StreamLatencyOptimization {
|
||||||
|
//0 - default mode (no latency optimizations)
|
||||||
|
NONE(0),
|
||||||
|
//1 - normal latency optimizations (about 50% of possible latency improvement of option 3)
|
||||||
|
NORMAL(1),
|
||||||
|
//2 - strong latency optimizations (about 75% of possible latency improvement of option 3)
|
||||||
|
STRONG(2),
|
||||||
|
// 3 - max latency optimizations
|
||||||
|
MAX_TEXT_NORMALIZATION(3),
|
||||||
|
// 3 - max latency optimizations with text normalizer turned off
|
||||||
|
MAX_NO_TEXT_NORMALIZATION(4);
|
||||||
|
private final int value;
|
||||||
|
|
||||||
|
StreamLatencyOptimization(int value) {
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static StreamLatencyOptimization getDefault() {
|
||||||
|
return NONE;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
package net.andrewcpu.elevenlabs.exceptions;
|
|
||||||
|
|
||||||
public class ElevenLabsAPINotInitiatedException extends ElevenLabsException{
|
|
||||||
public ElevenLabsAPINotInitiatedException() {
|
|
||||||
super("ElevenLabs API has not been initiated.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
package net.andrewcpu.elevenlabs.exceptions;
|
|
||||||
|
|
||||||
public abstract class ElevenLabsException extends Exception{
|
|
||||||
public ElevenLabsException(String message) {
|
|
||||||
super(message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
package net.andrewcpu.elevenlabs.exceptions;
|
|
||||||
|
|
||||||
import org.json.simple.JSONArray;
|
|
||||||
import org.json.simple.JSONObject;
|
|
||||||
|
|
||||||
public class ElevenLabsExceptionBuilder {
|
|
||||||
public static ElevenLabsValidationException build(JSONObject errorResponse) {
|
|
||||||
StringBuilder message = new StringBuilder();
|
|
||||||
if(errorResponse.get("detail") instanceof JSONObject detail) {
|
|
||||||
message.append(detail.get("status")).append(" ").append(detail.get("message"));
|
|
||||||
}
|
|
||||||
else if(errorResponse.get("detail") instanceof JSONArray details){
|
|
||||||
for(Object detailObject : details){
|
|
||||||
JSONObject detail = (JSONObject)detailObject;
|
|
||||||
String locStr = ((JSONArray)detail.get("loc")).get(0).toString();
|
|
||||||
int locInt = (int)(((JSONArray)detail.get("loc")).get(1));
|
|
||||||
message.append(detail.get("type").toString())
|
|
||||||
.append(": ")
|
|
||||||
.append(detail.get("msg").toString()).append(" at ").append(locStr).append(":").append(locInt)
|
|
||||||
.append("\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return new ElevenLabsValidationException(message.toString().trim());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
package net.andrewcpu.elevenlabs.exceptions;
|
|
||||||
|
|
||||||
public class ElevenLabsValidationException extends ElevenLabsException{
|
|
||||||
public ElevenLabsValidationException(String message) {
|
|
||||||
super(message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
package net.andrewcpu.elevenlabs.exceptions;
|
||||||
|
|
||||||
|
public class RequestException extends Exception {
|
||||||
|
public RequestException(String message) {
|
||||||
|
super(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package net.andrewcpu.elevenlabs.exceptions;
|
||||||
|
|
||||||
|
import net.andrewcpu.elevenlabs.model.error.ValidationError;
|
||||||
|
|
||||||
|
public class ValidationException extends RequestException{
|
||||||
|
public ValidationException(ValidationError validationError) {
|
||||||
|
super(validationError.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
package net.andrewcpu.elevenlabs.model;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||||
|
|
||||||
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
|
public class ElevenModel {
|
||||||
|
|
||||||
|
}
|
||||||
39
src/main/java/net/andrewcpu/elevenlabs/model/Language.java
Normal file
39
src/main/java/net/andrewcpu/elevenlabs/model/Language.java
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
package net.andrewcpu.elevenlabs.model;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
|
||||||
|
public class Language {
|
||||||
|
@JsonProperty("language_id")
|
||||||
|
private String languageId;
|
||||||
|
|
||||||
|
@JsonProperty("name")
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
public Language(String languageId, String name) {
|
||||||
|
this.languageId = languageId;
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Language() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
public String getLanguageId() {
|
||||||
|
return languageId;
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@JsonIgnore
|
||||||
|
public String toString() {
|
||||||
|
return "Language{" +
|
||||||
|
"languageId='" + languageId + '\'' +
|
||||||
|
", name='" + name + '\'' +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
package net.andrewcpu.elevenlabs.model.error;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import net.andrewcpu.elevenlabs.model.ElevenModel;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class ValidationError extends ElevenModel {
|
||||||
|
@JsonProperty("detail")
|
||||||
|
private List<ValidationErrorDetail> details;
|
||||||
|
|
||||||
|
public ValidationError(List<ValidationErrorDetail> details) {
|
||||||
|
this.details = details;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ValidationError() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
public List<ValidationErrorDetail> getDetails() {
|
||||||
|
return details;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@JsonIgnore
|
||||||
|
public String toString() {
|
||||||
|
return "ValidationError{" +
|
||||||
|
"details=" + details +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
package net.andrewcpu.elevenlabs.model.error;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import net.andrewcpu.elevenlabs.model.ElevenModel;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class ValidationErrorDetail extends ElevenModel {
|
||||||
|
@JsonProperty("loc")
|
||||||
|
private List locations;
|
||||||
|
|
||||||
|
@JsonProperty("msg")
|
||||||
|
private String message;
|
||||||
|
|
||||||
|
@JsonProperty("type")
|
||||||
|
private String type;
|
||||||
|
|
||||||
|
public ValidationErrorDetail(List locations, String message, String type) {
|
||||||
|
this.locations = locations;
|
||||||
|
this.message = message;
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ValidationErrorDetail() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
public List getLocations() {
|
||||||
|
return locations;
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
public String getMessage() {
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
public String getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "ValidationErrorDetail{" +
|
||||||
|
"locations=" + locations +
|
||||||
|
", message='" + message + '\'' +
|
||||||
|
", type='" + type + '\'' +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,101 @@
|
|||||||
|
package net.andrewcpu.elevenlabs.model.history;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import net.andrewcpu.elevenlabs.model.ElevenModel;
|
||||||
|
|
||||||
|
public class Feedback extends ElevenModel {
|
||||||
|
@JsonProperty("thumbs_up")
|
||||||
|
private boolean thumbsUp;
|
||||||
|
|
||||||
|
@JsonProperty("feedback")
|
||||||
|
private String feedback;
|
||||||
|
|
||||||
|
@JsonProperty("emotions")
|
||||||
|
private boolean emotions;
|
||||||
|
|
||||||
|
@JsonProperty("inaccurate_clone")
|
||||||
|
private boolean inaccurateClone;
|
||||||
|
|
||||||
|
@JsonProperty("glitches")
|
||||||
|
private boolean glitches;
|
||||||
|
|
||||||
|
@JsonProperty("audio_quality")
|
||||||
|
private boolean audioQuality;
|
||||||
|
|
||||||
|
@JsonProperty("other")
|
||||||
|
private boolean other;
|
||||||
|
|
||||||
|
@JsonProperty("review_status")
|
||||||
|
private String reviewStatus;
|
||||||
|
|
||||||
|
|
||||||
|
public Feedback(boolean thumbsUp, String feedback, boolean emotions, boolean inaccurateClone, boolean glitches, boolean audioQuality, boolean other, String reviewStatus) {
|
||||||
|
this.thumbsUp = thumbsUp;
|
||||||
|
this.feedback = feedback;
|
||||||
|
this.emotions = emotions;
|
||||||
|
this.inaccurateClone = inaccurateClone;
|
||||||
|
this.glitches = glitches;
|
||||||
|
this.audioQuality = audioQuality;
|
||||||
|
this.other = other;
|
||||||
|
this.reviewStatus = reviewStatus;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Feedback() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
public boolean isThumbsUp() {
|
||||||
|
return thumbsUp;
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
public String getFeedback() {
|
||||||
|
return feedback;
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
public boolean isEmotions() {
|
||||||
|
return emotions;
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
public boolean isInaccurateClone() {
|
||||||
|
return inaccurateClone;
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
public boolean isGlitches() {
|
||||||
|
return glitches;
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
public boolean isAudioQuality() {
|
||||||
|
return audioQuality;
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
public boolean isOther() {
|
||||||
|
return other;
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
public String getReviewStatus() {
|
||||||
|
return reviewStatus;
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "Feedback{" +
|
||||||
|
"thumbsUp=" + thumbsUp +
|
||||||
|
", feedback='" + feedback + '\'' +
|
||||||
|
", emotions=" + emotions +
|
||||||
|
", inaccurateClone=" + inaccurateClone +
|
||||||
|
", glitches=" + glitches +
|
||||||
|
", audioQuality=" + audioQuality +
|
||||||
|
", other=" + other +
|
||||||
|
", reviewStatus='" + reviewStatus + '\'' +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,76 @@
|
|||||||
|
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.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class History extends ElevenModel {
|
||||||
|
|
||||||
|
public static History get() {
|
||||||
|
return ElevenLabs.getHistoryAPI().getHistory();
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonProperty("history")
|
||||||
|
private List<HistoryItem> historyItems;
|
||||||
|
|
||||||
|
@JsonProperty("last_history_item_id")
|
||||||
|
private String lastHistoryItemId;
|
||||||
|
|
||||||
|
@JsonProperty("has_more")
|
||||||
|
private boolean hasMore;
|
||||||
|
|
||||||
|
public History(List<HistoryItem> historyItems) {
|
||||||
|
this.historyItems = historyItems;
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
public String getLastHistoryItemId() {
|
||||||
|
return lastHistoryItemId;
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
public boolean isHasMore() {
|
||||||
|
return hasMore;
|
||||||
|
}
|
||||||
|
|
||||||
|
public File downloadHistory(String... historyIds) {
|
||||||
|
return ElevenLabs.getHistoryAPI().getHistoryItemAudio(historyIds);
|
||||||
|
}
|
||||||
|
|
||||||
|
public File downloadHistory(HistoryItem... items) {
|
||||||
|
return ElevenLabs.getHistoryAPI().getHistoryItemAudio(Arrays.stream(items).map(HistoryItem::getHistoryItemId).toArray(String[]::new));
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "History{" +
|
||||||
|
"historyItems=" + historyItems +
|
||||||
|
", lastHistoryItemId='" + lastHistoryItemId + '\'' +
|
||||||
|
", hasMore=" + hasMore +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,152 @@
|
|||||||
|
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 {
|
||||||
|
@JsonProperty("history_item_id")
|
||||||
|
private String historyItemId;
|
||||||
|
|
||||||
|
@JsonProperty("request_id")
|
||||||
|
private String requestId;
|
||||||
|
|
||||||
|
@JsonProperty("voice_id")
|
||||||
|
private String voiceId;
|
||||||
|
|
||||||
|
@JsonProperty("voice_name")
|
||||||
|
private String voiceName;
|
||||||
|
|
||||||
|
@JsonProperty("text")
|
||||||
|
private String text;
|
||||||
|
|
||||||
|
@JsonProperty("date_unix")
|
||||||
|
private long dateUnix;
|
||||||
|
|
||||||
|
@JsonProperty("character_count_change_from")
|
||||||
|
private int characterCountChangeFrom;
|
||||||
|
|
||||||
|
@JsonProperty("character_count_change_to")
|
||||||
|
private int characterCountChangeTo;
|
||||||
|
|
||||||
|
@JsonProperty("content_type")
|
||||||
|
private String contentType;
|
||||||
|
|
||||||
|
@JsonProperty("state")
|
||||||
|
private String state;
|
||||||
|
|
||||||
|
@JsonProperty("settings")
|
||||||
|
private Map<String, Object> settings;
|
||||||
|
|
||||||
|
@JsonProperty("feedback")
|
||||||
|
private Feedback feedback;
|
||||||
|
|
||||||
|
public HistoryItem(String historyItemId, String requestId, String voiceId, String voiceName, String text, long dateUnix, int characterCountChangeFrom, int characterCountChangeTo, String contentType, String state, Map<String, Object> settings, Feedback feedback) {
|
||||||
|
this.historyItemId = historyItemId;
|
||||||
|
this.requestId = requestId;
|
||||||
|
this.voiceId = voiceId;
|
||||||
|
this.voiceName = voiceName;
|
||||||
|
this.text = text;
|
||||||
|
this.dateUnix = dateUnix;
|
||||||
|
this.characterCountChangeFrom = characterCountChangeFrom;
|
||||||
|
this.characterCountChangeTo = characterCountChangeTo;
|
||||||
|
this.contentType = contentType;
|
||||||
|
this.state = state;
|
||||||
|
this.settings = settings;
|
||||||
|
this.feedback = feedback;
|
||||||
|
}
|
||||||
|
|
||||||
|
public HistoryItem() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
public String getHistoryItemId() {
|
||||||
|
return historyItemId;
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
public String getRequestId() {
|
||||||
|
return requestId;
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
public String getVoiceId() {
|
||||||
|
return voiceId;
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
public String getVoiceName() {
|
||||||
|
return voiceName;
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
public String getText() {
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
public long getDateUnix() {
|
||||||
|
return dateUnix;
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
public int getCharacterCountChangeFrom() {
|
||||||
|
return characterCountChangeFrom;
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
public int getCharacterCountChangeTo() {
|
||||||
|
return characterCountChangeTo;
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
public String getContentType() {
|
||||||
|
return contentType;
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
public String getState() {
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
public Map<String, Object> getSettings() {
|
||||||
|
return settings;
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
public Feedback getFeedback() {
|
||||||
|
return feedback;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String delete() {
|
||||||
|
return ElevenLabs.getHistoryAPI().deleteHistoryItem(historyItemId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public File downloadAudio() {
|
||||||
|
return ElevenLabs.getHistoryAPI().getHistoryItemAudio(historyItemId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "HistoryItem{" +
|
||||||
|
"historyItemId='" + historyItemId + '\'' +
|
||||||
|
", requestId='" + requestId + '\'' +
|
||||||
|
", voiceId='" + voiceId + '\'' +
|
||||||
|
", voiceName='" + voiceName + '\'' +
|
||||||
|
", text='" + text + '\'' +
|
||||||
|
", dateUnix=" + dateUnix +
|
||||||
|
", characterCountChangeFrom=" + characterCountChangeFrom +
|
||||||
|
", characterCountChangeTo=" + characterCountChangeTo +
|
||||||
|
", contentType='" + contentType + '\'' +
|
||||||
|
", state='" + state + '\'' +
|
||||||
|
", settings=" + settings +
|
||||||
|
", feedback=" + feedback +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
package net.andrewcpu.elevenlabs.model.history;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import net.andrewcpu.elevenlabs.model.ElevenModel;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class HistoryItemList extends ElevenModel {
|
||||||
|
@JsonProperty("history_item_ids")
|
||||||
|
private List<String> historyIds;
|
||||||
|
|
||||||
|
public HistoryItemList(List<String> historyIds) {
|
||||||
|
this.historyIds = historyIds;
|
||||||
|
}
|
||||||
|
|
||||||
|
public HistoryItemList() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
public List<String> getHistoryIds() {
|
||||||
|
return historyIds;
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "HistoryItemList{" +
|
||||||
|
"historyIds=" + historyIds +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,107 @@
|
|||||||
|
package net.andrewcpu.elevenlabs.model.projects;
|
||||||
|
|
||||||
|
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 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")
|
||||||
|
private String chapterId;
|
||||||
|
|
||||||
|
@JsonProperty("name")
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
@JsonProperty("last_conversion_date_unix")
|
||||||
|
private long lastConversionDateUnix;
|
||||||
|
|
||||||
|
@JsonProperty("conversion_progress")
|
||||||
|
private double conversionProgress;
|
||||||
|
|
||||||
|
@JsonProperty("can_be_downloaded")
|
||||||
|
private boolean canBeDownloaded;
|
||||||
|
|
||||||
|
@JsonProperty("state")
|
||||||
|
private String state;
|
||||||
|
|
||||||
|
@JsonProperty("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 +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,55 @@
|
|||||||
|
package net.andrewcpu.elevenlabs.model.projects;
|
||||||
|
|
||||||
|
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.InputStream;
|
||||||
|
|
||||||
|
public class ChapterSnapshot extends Snapshot {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public InputStream getAudioStream() {
|
||||||
|
return ElevenLabs.getProjectsAPI().getChapterSnapshotAudioStream(projectId, chapterId, chapterSnapshotId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ChapterSnapshot() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ChapterSnapshot(String chapterSnapshotId, String projectId, String chapterId, long createdAtUnix, String name) {
|
||||||
|
super(projectId, createdAtUnix, name);
|
||||||
|
this.chapterSnapshotId = chapterSnapshotId;
|
||||||
|
this.chapterId = chapterId;
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonProperty("chapter_snapshot_id")
|
||||||
|
private String chapterSnapshotId;
|
||||||
|
|
||||||
|
@JsonProperty("chapter_id")
|
||||||
|
private String chapterId;
|
||||||
|
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
public String getChapterSnapshotId() {
|
||||||
|
return chapterSnapshotId;
|
||||||
|
}
|
||||||
|
@JsonIgnore
|
||||||
|
public String getChapterId() {
|
||||||
|
return chapterId;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@JsonIgnore
|
||||||
|
public String toString() {
|
||||||
|
return "ChapterSnapshot{" +
|
||||||
|
"chapterSnapshotId='" + chapterSnapshotId + '\'' +
|
||||||
|
", projectId='" + projectId + '\'' +
|
||||||
|
", chapterId='" + chapterId + '\'' +
|
||||||
|
", createdAtUnix=" + createdAtUnix +
|
||||||
|
", name='" + name + '\'' +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,171 @@
|
|||||||
|
package net.andrewcpu.elevenlabs.model.projects;
|
||||||
|
|
||||||
|
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.request.AddProjectRequest;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class Project extends ElevenModel {
|
||||||
|
|
||||||
|
public static List<Project> 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")
|
||||||
|
private String projectId;
|
||||||
|
|
||||||
|
@JsonProperty("name")
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
@JsonProperty("create_date_unix")
|
||||||
|
private long unixCreateDate;
|
||||||
|
|
||||||
|
@JsonProperty("default_title_voice_id")
|
||||||
|
private String defaultTitleVoiceId;
|
||||||
|
|
||||||
|
@JsonProperty("default_paragraph_voice_id")
|
||||||
|
private String defaultParagraphVoiceId;
|
||||||
|
|
||||||
|
@JsonProperty("default_model_id")
|
||||||
|
private String defaultModelId;
|
||||||
|
|
||||||
|
@JsonProperty("last_conversion_date_unix")
|
||||||
|
private long lastConversionDateUnix;
|
||||||
|
|
||||||
|
@JsonProperty("can_be_downloaded")
|
||||||
|
private boolean canBeDownloaded;
|
||||||
|
|
||||||
|
@JsonProperty("state")
|
||||||
|
private String state;
|
||||||
|
|
||||||
|
@JsonProperty("chapters")
|
||||||
|
private List<Chapter> chapters;
|
||||||
|
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
public String getProjectId() {
|
||||||
|
return projectId;
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
public long getUnixCreateDate() {
|
||||||
|
return unixCreateDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
public String getDefaultTitleVoiceId() {
|
||||||
|
return defaultTitleVoiceId;
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
public String getDefaultParagraphVoiceId() {
|
||||||
|
return defaultParagraphVoiceId;
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
public String getDefaultModelId() {
|
||||||
|
return defaultModelId;
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
public long getLastConversionDateUnix() {
|
||||||
|
return lastConversionDateUnix;
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
public boolean isCanBeDownloaded() {
|
||||||
|
return canBeDownloaded;
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
public String getState() {
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
public List<Chapter> getChapters() {
|
||||||
|
return chapters;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@JsonIgnore
|
||||||
|
public String toString() {
|
||||||
|
return "Project{" +
|
||||||
|
"projectId='" + projectId + '\'' +
|
||||||
|
", name='" + name + '\'' +
|
||||||
|
", unixCreateDate=" + unixCreateDate +
|
||||||
|
", defaultTitleVoiceId='" + defaultTitleVoiceId + '\'' +
|
||||||
|
", defaultParagraphVoiceId='" + defaultParagraphVoiceId + '\'' +
|
||||||
|
", defaultModelId='" + defaultModelId + '\'' +
|
||||||
|
", lastConversionDateUnix=" + lastConversionDateUnix +
|
||||||
|
", canBeDownloaded=" + canBeDownloaded +
|
||||||
|
", state='" + state + '\'' +
|
||||||
|
", chapters=" + chapters +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
package net.andrewcpu.elevenlabs.model.projects;
|
||||||
|
|
||||||
|
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.InputStream;
|
||||||
|
|
||||||
|
public class ProjectSnapshot extends Snapshot {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public InputStream getAudioStream() {
|
||||||
|
return ElevenLabs.getProjectsAPI().getProjectSnapshotAudioStream(projectId, projectSnapshotId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ProjectSnapshot() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ProjectSnapshot(String projectSnapshotId, String projectId, long createdAtUnix, String name) {
|
||||||
|
super(projectId, createdAtUnix, name);
|
||||||
|
this.projectSnapshotId = projectSnapshotId;
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonProperty("project_snapshot_id")
|
||||||
|
private String projectSnapshotId;
|
||||||
|
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
public String getProjectSnapshotId() {
|
||||||
|
return projectSnapshotId;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "ProjectSnapshot{" +
|
||||||
|
"projectSnapshotId='" + projectSnapshotId + '\'' +
|
||||||
|
", projectId='" + projectId + '\'' +
|
||||||
|
", createdAtUnix=" + createdAtUnix +
|
||||||
|
", name='" + name + '\'' +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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 + '\'' +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,62 @@
|
|||||||
|
package net.andrewcpu.elevenlabs.model.projects;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import net.andrewcpu.elevenlabs.model.ElevenModel;
|
||||||
|
|
||||||
|
public class Statistics extends ElevenModel {
|
||||||
|
@JsonProperty("characters_unconverted")
|
||||||
|
private int charactersUnconverted;
|
||||||
|
|
||||||
|
@JsonProperty("characters_converted")
|
||||||
|
private int charactersConverted;
|
||||||
|
|
||||||
|
@JsonProperty("paragraphs_converted")
|
||||||
|
private int paragraphsConverted;
|
||||||
|
|
||||||
|
@JsonProperty("paragraphs_unconverted")
|
||||||
|
private int paragraphsUnconverted;
|
||||||
|
|
||||||
|
|
||||||
|
public Statistics(int charactersUnconverted, int charactersConverted, int paragraphsConverted, int paragraphsUnconverted) {
|
||||||
|
this.charactersUnconverted = charactersUnconverted;
|
||||||
|
this.charactersConverted = charactersConverted;
|
||||||
|
this.paragraphsConverted = paragraphsConverted;
|
||||||
|
this.paragraphsUnconverted = paragraphsUnconverted;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Statistics() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
public int getCharactersUnconverted() {
|
||||||
|
return charactersUnconverted;
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
public int getCharactersConverted() {
|
||||||
|
return charactersConverted;
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
public int getParagraphsConverted() {
|
||||||
|
return paragraphsConverted;
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
public int getParagraphsUnconverted() {
|
||||||
|
return paragraphsUnconverted;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@JsonIgnore
|
||||||
|
public String toString() {
|
||||||
|
return "Statistics{" +
|
||||||
|
"charactersUnconverted=" + charactersUnconverted +
|
||||||
|
", charactersConverted=" + charactersConverted +
|
||||||
|
", paragraphsConverted=" + paragraphsConverted +
|
||||||
|
", paragraphsUnconverted=" + paragraphsUnconverted +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,118 @@
|
|||||||
|
package net.andrewcpu.elevenlabs.model.request;
|
||||||
|
|
||||||
|
import net.andrewcpu.elevenlabs.enums.ProjectOutputQuality;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
|
public class AddProjectRequest {
|
||||||
|
private String name;
|
||||||
|
private String fromUrl;
|
||||||
|
private File fromDocument;
|
||||||
|
private String defaultTitleVoiceId;
|
||||||
|
private String defaultParagraphVoiceId;
|
||||||
|
private String defaultModelId;
|
||||||
|
private ProjectOutputQuality projectOutputQuality;
|
||||||
|
private String title;
|
||||||
|
private String author;
|
||||||
|
private String isbnNumber;
|
||||||
|
private boolean acxVolumeNormalization;
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public AddProjectRequest setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFromUrl() {
|
||||||
|
return fromUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
public AddProjectRequest setFromUrl(String fromUrl) {
|
||||||
|
this.fromUrl = fromUrl;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public File getFromDocument() {
|
||||||
|
return fromDocument;
|
||||||
|
}
|
||||||
|
|
||||||
|
public AddProjectRequest setFromDocument(File fromDocument) {
|
||||||
|
this.fromDocument = fromDocument;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDefaultTitleVoiceId() {
|
||||||
|
return defaultTitleVoiceId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public AddProjectRequest setDefaultTitleVoiceId(String defaultTitleVoiceId) {
|
||||||
|
this.defaultTitleVoiceId = defaultTitleVoiceId;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDefaultParagraphVoiceId() {
|
||||||
|
return defaultParagraphVoiceId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public AddProjectRequest setDefaultParagraphVoiceId(String defaultParagraphVoiceId) {
|
||||||
|
this.defaultParagraphVoiceId = defaultParagraphVoiceId;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDefaultModelId() {
|
||||||
|
return defaultModelId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public AddProjectRequest setDefaultModelId(String defaultModelId) {
|
||||||
|
this.defaultModelId = defaultModelId;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ProjectOutputQuality getProjectOutputQuality() {
|
||||||
|
return projectOutputQuality;
|
||||||
|
}
|
||||||
|
|
||||||
|
public AddProjectRequest setProjectOutputQuality(ProjectOutputQuality projectOutputQuality) {
|
||||||
|
this.projectOutputQuality = projectOutputQuality;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTitle() {
|
||||||
|
return title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public AddProjectRequest setTitle(String title) {
|
||||||
|
this.title = title;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAuthor() {
|
||||||
|
return author;
|
||||||
|
}
|
||||||
|
|
||||||
|
public AddProjectRequest setAuthor(String author) {
|
||||||
|
this.author = author;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getIsbnNumber() {
|
||||||
|
return isbnNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
public AddProjectRequest setIsbnNumber(String isbnNumber) {
|
||||||
|
this.isbnNumber = isbnNumber;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isAcxVolumeNormalization() {
|
||||||
|
return acxVolumeNormalization;
|
||||||
|
}
|
||||||
|
|
||||||
|
public AddProjectRequest setAcxVolumeNormalization(boolean acxVolumeNormalization) {
|
||||||
|
this.acxVolumeNormalization = acxVolumeNormalization;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,118 @@
|
|||||||
|
package net.andrewcpu.elevenlabs.model.request;
|
||||||
|
|
||||||
|
import net.andrewcpu.elevenlabs.model.ElevenModel;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
|
public class CreateAudioNativeProjectRequest extends ElevenModel {
|
||||||
|
private String name;
|
||||||
|
private String image;
|
||||||
|
private String author;
|
||||||
|
private boolean small;
|
||||||
|
private String textColor;
|
||||||
|
private String backgroundColor;
|
||||||
|
private Integer sessionization;
|
||||||
|
private String voiceId;
|
||||||
|
private String modelId;
|
||||||
|
private File file;
|
||||||
|
private boolean autoConvert;
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CreateAudioNativeProjectRequest setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getImage() {
|
||||||
|
return image;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CreateAudioNativeProjectRequest setImage(String image) {
|
||||||
|
this.image = image;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAuthor() {
|
||||||
|
return author;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CreateAudioNativeProjectRequest setAuthor(String author) {
|
||||||
|
this.author = author;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isSmall() {
|
||||||
|
return small;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CreateAudioNativeProjectRequest setSmall(boolean small) {
|
||||||
|
this.small = small;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTextColor() {
|
||||||
|
return textColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CreateAudioNativeProjectRequest setTextColor(String textColor) {
|
||||||
|
this.textColor = textColor;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getBackgroundColor() {
|
||||||
|
return backgroundColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CreateAudioNativeProjectRequest setBackgroundColor(String backgroundColor) {
|
||||||
|
this.backgroundColor = backgroundColor;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getSessionization() {
|
||||||
|
return sessionization;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CreateAudioNativeProjectRequest setSessionization(Integer sessionization) {
|
||||||
|
this.sessionization = sessionization;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getVoiceId() {
|
||||||
|
return voiceId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CreateAudioNativeProjectRequest setVoiceId(String voiceId) {
|
||||||
|
this.voiceId = voiceId;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getModelId() {
|
||||||
|
return modelId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CreateAudioNativeProjectRequest setModelId(String modelId) {
|
||||||
|
this.modelId = modelId;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public File getFile() {
|
||||||
|
return file;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CreateAudioNativeProjectRequest setFile(File file) {
|
||||||
|
this.file = file;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isAutoConvert() {
|
||||||
|
return autoConvert;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CreateAudioNativeProjectRequest setAutoConvert(boolean autoConvert) {
|
||||||
|
this.autoConvert = autoConvert;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
package net.andrewcpu.elevenlabs.model.request;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import net.andrewcpu.elevenlabs.model.ElevenModel;
|
||||||
|
import net.andrewcpu.elevenlabs.model.voice.VoiceSettings;
|
||||||
|
|
||||||
|
public class TextToSpeechRequest extends ElevenModel {
|
||||||
|
@JsonProperty("text")
|
||||||
|
private String text;
|
||||||
|
|
||||||
|
@JsonProperty("model_id")
|
||||||
|
private String modelId;
|
||||||
|
|
||||||
|
@JsonProperty("voice_settings")
|
||||||
|
private VoiceSettings voiceSettings;
|
||||||
|
|
||||||
|
public TextToSpeechRequest(String text, String modelId, VoiceSettings voiceSettings) {
|
||||||
|
this.text = text;
|
||||||
|
this.modelId = modelId;
|
||||||
|
this.voiceSettings = voiceSettings;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TextToSpeechRequest() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
public String getText() {
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
public String getModelId() {
|
||||||
|
return modelId;
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
public VoiceSettings getVoiceSettings() {
|
||||||
|
return voiceSettings;
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "TextToSpeechRequest{" +
|
||||||
|
"text='" + text + '\'' +
|
||||||
|
", modelId='" + modelId + '\'' +
|
||||||
|
", voiceSettings=" + voiceSettings +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
package net.andrewcpu.elevenlabs.model.response;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import net.andrewcpu.elevenlabs.model.ElevenModel;
|
||||||
|
import net.andrewcpu.elevenlabs.model.projects.ChapterSnapshot;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class ChapterSnapshotsModelResponse extends ElevenModel {
|
||||||
|
|
||||||
|
public ChapterSnapshotsModelResponse(List<ChapterSnapshot> snapshots) {
|
||||||
|
this.snapshots = snapshots;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ChapterSnapshotsModelResponse() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonProperty("snapshots")
|
||||||
|
private List<ChapterSnapshot> snapshots;
|
||||||
|
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
public List<ChapterSnapshot> getSnapshots() {
|
||||||
|
return snapshots;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@JsonIgnore
|
||||||
|
public String toString() {
|
||||||
|
return "ChapterSnapshotsModelResponse{" +
|
||||||
|
"snapshots=" + snapshots +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
package net.andrewcpu.elevenlabs.model.response;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import net.andrewcpu.elevenlabs.model.ElevenModel;
|
||||||
|
import net.andrewcpu.elevenlabs.model.projects.Chapter;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class ChaptersModelResponse extends ElevenModel {
|
||||||
|
@JsonProperty("chapters")
|
||||||
|
private List<Chapter> chapters;
|
||||||
|
|
||||||
|
public ChaptersModelResponse(List<Chapter> chapters) {
|
||||||
|
this.chapters = chapters;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ChaptersModelResponse() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
public List<Chapter> getChapters() {
|
||||||
|
return chapters;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@JsonIgnore
|
||||||
|
public String toString() {
|
||||||
|
return "ChaptersModelResponse{" +
|
||||||
|
"chapters=" + chapters +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
package net.andrewcpu.elevenlabs.model.response;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import net.andrewcpu.elevenlabs.model.ElevenModel;
|
||||||
|
|
||||||
|
public class CreateAudioEnabledProjectModelResponse extends ElevenModel {
|
||||||
|
@JsonProperty("project_id")
|
||||||
|
private String projectId;
|
||||||
|
|
||||||
|
@JsonProperty("converting")
|
||||||
|
private boolean converting;
|
||||||
|
|
||||||
|
@JsonProperty("html_snippet")
|
||||||
|
private String htmlSnippet;
|
||||||
|
|
||||||
|
public CreateAudioEnabledProjectModelResponse(String projectId, boolean converting, String htmlSnippet) {
|
||||||
|
this.projectId = projectId;
|
||||||
|
this.converting = converting;
|
||||||
|
this.htmlSnippet = htmlSnippet;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CreateAudioEnabledProjectModelResponse() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
public String getProjectId() {
|
||||||
|
return projectId;
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
public boolean isConverting() {
|
||||||
|
return converting;
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
public String getHtmlSnippet() {
|
||||||
|
return htmlSnippet;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@JsonIgnore
|
||||||
|
public String toString() {
|
||||||
|
return "CreateAudioEnabledProjectModelResponse{" +
|
||||||
|
"projectId='" + projectId + '\'' +
|
||||||
|
", converting=" + converting +
|
||||||
|
", htmlSnippet='" + htmlSnippet + '\'' +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
package net.andrewcpu.elevenlabs.model.response;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import net.andrewcpu.elevenlabs.model.ElevenModel;
|
||||||
|
|
||||||
|
public class CreateVoiceResponse extends ElevenModel {
|
||||||
|
@JsonProperty("voice_id")
|
||||||
|
private String voiceId;
|
||||||
|
|
||||||
|
public CreateVoiceResponse(String voiceId) {
|
||||||
|
this.voiceId = voiceId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CreateVoiceResponse() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
public String getVoiceId() {
|
||||||
|
return voiceId;
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "CreateVoiceResponse{" +
|
||||||
|
"voiceId='" + voiceId + '\'' +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,163 @@
|
|||||||
|
package net.andrewcpu.elevenlabs.model.response;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import net.andrewcpu.elevenlabs.model.ElevenModel;
|
||||||
|
import net.andrewcpu.elevenlabs.model.Language;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class GenerationTypeModel extends ElevenModel {
|
||||||
|
@JsonProperty("model_id")
|
||||||
|
private String modelId;
|
||||||
|
|
||||||
|
@JsonProperty("name")
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
@JsonProperty("can_be_finetuned")
|
||||||
|
private boolean canBeFinetuned;
|
||||||
|
|
||||||
|
@JsonProperty("can_do_text_to_speech")
|
||||||
|
private boolean canDoTextToSpeech;
|
||||||
|
|
||||||
|
@JsonProperty("can_do_voice_conversion")
|
||||||
|
private boolean canDoVoiceConversion;
|
||||||
|
|
||||||
|
@JsonProperty("can_use_style")
|
||||||
|
private boolean canUseStyle;
|
||||||
|
|
||||||
|
@JsonProperty("can_use_speaker_boost")
|
||||||
|
private boolean canUseSpeakerBoost;
|
||||||
|
|
||||||
|
@JsonProperty("serves_pro_voices")
|
||||||
|
private boolean servesProVoices;
|
||||||
|
|
||||||
|
@JsonProperty("token_cost_factor")
|
||||||
|
private int tokenCostFactor;
|
||||||
|
|
||||||
|
@JsonProperty("description")
|
||||||
|
private String description;
|
||||||
|
|
||||||
|
@JsonProperty("requires_alpha_access")
|
||||||
|
private boolean requiresAlphaAccess;
|
||||||
|
|
||||||
|
@JsonProperty("max_characters_request_free_user")
|
||||||
|
private int maxCharactersRequestFreeUser;
|
||||||
|
@JsonProperty("max_characters_request_subscribed_user")
|
||||||
|
private int maxCharactersRequestSubscribedUser;
|
||||||
|
|
||||||
|
@JsonProperty("languages")
|
||||||
|
private List<Language> languages;
|
||||||
|
|
||||||
|
public GenerationTypeModel(String modelId, String name, boolean canBeFinetuned, boolean canDoTextToSpeech, boolean canDoVoiceConversion, boolean canUseStyle, boolean canUseSpeakerBoost, boolean servesProVoices, int tokenCostFactor, String description, boolean requiresAlphaAccess, int maxCharactersRequestFreeUser, int maxCharactersRequestSubscribedUser, List<Language> languages) {
|
||||||
|
this.modelId = modelId;
|
||||||
|
this.name = name;
|
||||||
|
this.canBeFinetuned = canBeFinetuned;
|
||||||
|
this.canDoTextToSpeech = canDoTextToSpeech;
|
||||||
|
this.canDoVoiceConversion = canDoVoiceConversion;
|
||||||
|
this.canUseStyle = canUseStyle;
|
||||||
|
this.canUseSpeakerBoost = canUseSpeakerBoost;
|
||||||
|
this.servesProVoices = servesProVoices;
|
||||||
|
this.tokenCostFactor = tokenCostFactor;
|
||||||
|
this.description = description;
|
||||||
|
this.requiresAlphaAccess = requiresAlphaAccess;
|
||||||
|
this.maxCharactersRequestFreeUser = maxCharactersRequestFreeUser;
|
||||||
|
this.maxCharactersRequestSubscribedUser = maxCharactersRequestSubscribedUser;
|
||||||
|
this.languages = languages;
|
||||||
|
}
|
||||||
|
|
||||||
|
public GenerationTypeModel() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
public String getModelId() {
|
||||||
|
return modelId;
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
public boolean isCanBeFinetuned() {
|
||||||
|
return canBeFinetuned;
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
public boolean isCanDoTextToSpeech() {
|
||||||
|
return canDoTextToSpeech;
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
public boolean isCanDoVoiceConversion() {
|
||||||
|
return canDoVoiceConversion;
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
public int getTokenCostFactor() {
|
||||||
|
return tokenCostFactor;
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
public String getDescription() {
|
||||||
|
return description;
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
public List<Language> getLanguages() {
|
||||||
|
return languages;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
public boolean isCanUseStyle() {
|
||||||
|
return canUseStyle;
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
public boolean isCanUseSpeakerBoost() {
|
||||||
|
return canUseSpeakerBoost;
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
public boolean isServesProVoices() {
|
||||||
|
return servesProVoices;
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
public boolean isRequiresAlphaAccess() {
|
||||||
|
return requiresAlphaAccess;
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
public int getMaxCharactersRequestFreeUser() {
|
||||||
|
return maxCharactersRequestFreeUser;
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
public int getMaxCharactersRequestSubscribedUser() {
|
||||||
|
return maxCharactersRequestSubscribedUser;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@JsonIgnore
|
||||||
|
public String toString() {
|
||||||
|
return "GenerationTypeModel{" +
|
||||||
|
"modelId='" + modelId + '\'' +
|
||||||
|
", name='" + name + '\'' +
|
||||||
|
", canBeFinetuned=" + canBeFinetuned +
|
||||||
|
", canDoTextToSpeech=" + canDoTextToSpeech +
|
||||||
|
", canDoVoiceConversion=" + canDoVoiceConversion +
|
||||||
|
", canUseStyle=" + canUseStyle +
|
||||||
|
", canUseSpeakerBoost=" + canUseSpeakerBoost +
|
||||||
|
", servesProVoices=" + servesProVoices +
|
||||||
|
", tokenCostFactor=" + tokenCostFactor +
|
||||||
|
", description='" + description + '\'' +
|
||||||
|
", requiresAlphaAccess=" + requiresAlphaAccess +
|
||||||
|
", maxCharactersRequestFreeUser=" + maxCharactersRequestFreeUser +
|
||||||
|
", maxCharactersRequestSubscribedUser=" + maxCharactersRequestSubscribedUser +
|
||||||
|
", languages=" + languages +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
package net.andrewcpu.elevenlabs.model.response;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import net.andrewcpu.elevenlabs.model.ElevenModel;
|
||||||
|
import net.andrewcpu.elevenlabs.model.projects.Project;
|
||||||
|
|
||||||
|
public class ProjectModelResponse extends ElevenModel {
|
||||||
|
@JsonProperty("project")
|
||||||
|
private Project project;
|
||||||
|
|
||||||
|
public ProjectModelResponse(Project project) {
|
||||||
|
this.project = project;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ProjectModelResponse() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
public Project getProject() {
|
||||||
|
return project;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@JsonIgnore
|
||||||
|
public String toString() {
|
||||||
|
return "ProjectModelResponse{" +
|
||||||
|
"project=" + project +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
package net.andrewcpu.elevenlabs.model.response;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import net.andrewcpu.elevenlabs.model.ElevenModel;
|
||||||
|
import net.andrewcpu.elevenlabs.model.projects.ProjectSnapshot;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class ProjectSnapshotsModelResponse extends ElevenModel {
|
||||||
|
@JsonProperty("snapshots")
|
||||||
|
private List<ProjectSnapshot> projectSnapshots;
|
||||||
|
|
||||||
|
|
||||||
|
public ProjectSnapshotsModelResponse(List<ProjectSnapshot> projectSnapshots) {
|
||||||
|
this.projectSnapshots = projectSnapshots;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ProjectSnapshotsModelResponse() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
public List<ProjectSnapshot> getSnapshots() {
|
||||||
|
return projectSnapshots;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@JsonIgnore
|
||||||
|
public String toString() {
|
||||||
|
return "ProjectSnapshotsModelResponse{" +
|
||||||
|
"snapshots=" + projectSnapshots +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
package net.andrewcpu.elevenlabs.model.response;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import net.andrewcpu.elevenlabs.model.ElevenModel;
|
||||||
|
import net.andrewcpu.elevenlabs.model.projects.Project;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class ProjectsModelResponse extends ElevenModel {
|
||||||
|
@JsonProperty("projects")
|
||||||
|
private List<Project> projects;
|
||||||
|
|
||||||
|
public ProjectsModelResponse(List<Project> projects) {
|
||||||
|
this.projects = projects;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ProjectsModelResponse() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
public List<Project> getProjects() {
|
||||||
|
return projects;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@JsonIgnore
|
||||||
|
public String toString() {
|
||||||
|
return "ProjectsModelResponse{" +
|
||||||
|
"projects=" + projects +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
package net.andrewcpu.elevenlabs.model.response;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import net.andrewcpu.elevenlabs.model.ElevenModel;
|
||||||
|
import net.andrewcpu.elevenlabs.model.voice.Voice;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class VoiceModelResponse extends ElevenModel {
|
||||||
|
@JsonProperty("voices")
|
||||||
|
private List<Voice> voices;
|
||||||
|
|
||||||
|
public VoiceModelResponse(List<Voice> voices) {
|
||||||
|
this.voices = voices;
|
||||||
|
}
|
||||||
|
|
||||||
|
public VoiceModelResponse() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
public List<Voice> getVoices() {
|
||||||
|
return voices;
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "VoiceModelResponse{" +
|
||||||
|
"voices=" + voices +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user